Οθόνη#

Εισαγωγή#

The screen class is derived from the brain base class. It controls how the IQ (1st gen) Brain displays text and values on its built-in screen.

Η οθόνη IQ (1ης γενιάς) Brain υποστηρίζει έως και 5 γραμμές και 21 στήλες κειμένου.

Ο εγκέφαλος VEX IQ (1ης γενιάς) με αριθμημένη επικάλυψη πλέγματος (στήλες 1–21 και γραμμές 1–5). Κόκκινες γραμμές επικάλυψης επισημαίνουν τη δομή πλέγματος, με βέλη που επισημαίνουν τη Στήλη 1, τη Στήλη 21, τη Σειρά 1, τη Σειρά 2 και τη Σειρά 5. Η πρώτη σειρά εμφανίζει τους αριθμούς από 1 έως 21 στην κορυφή.

Πρόσβαση#

The screen class can be accessed by:

Brain.Screen

Σημειώσεις#

  • The screen object is provided by the Brain. It is not constructed directly.

  • Projects use a single global Brain object, so screen functions are called using Brain.Screen.

Παράδειγμα#

/* This constructor is required when using VS Code.
A Brain is generated automatically at the start of
VEXcode projects. */

// Create the Brain
brain Brain = brain();

// Print text to the Brain screen
Brain.Screen.print("Hello!");

Συναρτήσεις Μελών#

The screen class includes the following member functions:

  • print — Prints formatted text, numbers, or Boolean values to the Brain screen.

  • setCursor — Moves the text cursor to a specified row and column.

  • newLine — Clears the remainder of the current line and moves the cursor to the next line.

  • clearLine — Clears the remainder of the current line or clears a specified line.

  • row — Returns the row where text will be printed.

  • column — Returns the column where text will be printed.

  • getStringHeight — Returns the height of a string in pixels using the current font.

  • getStringWidth — Returns the width of a string in pixels using the current font.

  • printAt — Prints formatted text at an x, y pixel location (optionally opaque).

  • clearScreen — Clears the entire screen (optionally to a specified color).

  • setFont — Sets the font used for printing on the screen.

  • setPenWidth — Sets the thickness of drawn lines and shape outlines.

  • setPenColor — Sets the color of text, pixels, lines, and shape outlines.

  • setFillColor — Sets the fill color for drawn shapes and printed text backgrounds.

  • setOrigin — Sets the origin used for screen coordinates.

  • setClipRegion — Restricts screen output to a rectangular region.

  • drawPixel — Draws one pixel at a coordinate.

  • drawLine — Draws a line between two points.

  • drawRectangle — Draws a rectangle at an x, y location with a specified size.

  • drawCircle — Draws a circle at an x, y location with a specified radius.

  • render — Enables double buffering or renders the back buffer to the screen.

Before calling any screen member functions, a brain instance must be created, as shown below:

// Create the Brain
brain Brain = brain();

print#

Εμφανίζει κείμενο, αριθμούς ή λογικές τιμές στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions

1 Εκτυπώνει μορφοποιημένο κείμενο χρησιμοποιώντας κυριολεκτικές συμβολοσειρές ή συμβολοσειρές τύπου C μόνο για ανάγνωση.

void print(
    const char* format,
    ... );

2 Εκτυπώνει μορφοποιημένο κείμενο χρησιμοποιώντας τροποποιήσιμους πίνακες χαρακτήρων.

void print(
    char* format,
    ... );

Parameters

Παράμετρος

Τύπος

Περιγραφή

format

const char*

A format string provided as a string literal or read-only C-style string (for example, “Score: %d”).

format

char*

Μια συμβολοσειρά μορφοποίησης που παρέχεται ως τροποποιήσιμος πίνακας χαρακτήρων.

Μία ή περισσότερες πρόσθετες τιμές που εισάγονται στη συμβολοσειρά μορφοποίησης, διαχωρισμένες με κόμματα.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes Examples
// Display a message at the starting cursor
Brain.Screen.print("Hello, Robot!");

setCursor#

Moves the cursor to a specific row and column on the IQ (1st gen) Brain screen. The next print call will start printing at that location.

Available Functions
void setCursor(
  int32_t row, 
  int32_t col );

Parameters

Παράμετρος

Τύπος

Περιγραφή

row

int32_t

Η γραμμή στην οποία θα μετακινηθεί ο κέρσορας.

col

int32_t

Η στήλη στην οποία θα μετακινηθεί ο κέρσορας.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes Examples
// Print at row 3 column 7
Brain.Screen.setCursor(3, 7);
Brain.Screen.print("VEXcode!");

Η οθόνη IQ (1ης γενιάς) Brain που εμφανίζει κεντρικό κείμενο που γράφει "VEXcode!".

newLine#

Μετακινεί τον κέρσορα στην αρχή της επόμενης γραμμής στην οθόνη Brain.

Available Functions
void newLine();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • If the cursor is in the middle of a sentence, newLine will clear the rest of the row after the cursor before moving to the next row.

  • After calling newLine, the cursor is positioned at the first column of the next line.

  • The cursor position and row numbering are set using setCursor.

Examples
// Display two lines of text
Brain.Screen.print("First message");
Brain.Screen.newLine();
Brain.Screen.print("Second message");

Η οθόνη IQ (1ης γενιάς) Brain που εμφανίζει το «Πρώτο Μήνυμα» και το «Δεύτερο Μήνυμα», σε ξεχωριστές γραμμές.

clearLine#

Διαγράφει κείμενο από μια σειρά στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions

1 Διαγράφει το υπόλοιπο της τρέχουσας γραμμής από τη θέση του κέρσορα.

void clearLine();

2 Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας το τρέχον διαμορφωμένο χρώμα γεμίσματος.

void clearLine(
    int number );

3 Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.

void clearLine(
    int          number,
    const color& color );

4 Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.

void clearLine(
    int         number,
    const char* color );

5 Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας μια τιμή απόχρωσης.

void clearLine(
    int number,
    int hue );

Parameters

Παράμετρος

Τύπος

Περιγραφή

number

int

The row number to clear. Row numbering starts at 1.

color

const color&

Clears the row using a color object. Predefined colors include:

  • black
  • white
  • red
  • green
  • blue
  • yellow
  • orange
  • purple
  • cyan
  • transparent
This can also use a custom color object.

color

const char*

Clears the row using a hexadecimal color value (for example, “#000000”).

hue

int

Clears the row using an integer hue value in the range 0359, representing degrees around a color wheel.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η διαγραφή μιας γραμμής δεν αλλάζει την τρέχουσα θέση του κέρσορα.

  • The cursor position and row numbering are set using setCursor.

  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

Examples
// Display text on two rows
Brain.Screen.print("This text stays");
Brain.Screen.newLine();
Brain.Screen.print("This disappears");

// Wait 3 seconds before clearing row 2
wait(3, seconds);
Brain.Screen.clearLine(2);

row#

Επιστρέφει την τρέχουσα θέση της γραμμής του κέρσορα στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions
int32_t row();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Returns an int32_t representing the row where text will be printed.

Η αρίθμηση γραμμών ξεκινά από το 1.

Notes
  • Η θέση του κέρσορα βασίζεται στην τρέχουσα γραμματοσειρά οθόνης .

  • Η επιστρεφόμενη τιμή υποδεικνύει πού θα εμφανιστεί η επόμενη εκτυπωμένη έξοδος.

  • The row value changes when text is printed or when setCursor is called.

Examples
// Display the cursor's current row
Brain.Screen.setCursor(3, 12);
Brain.Screen.print("row: ", Brain.Screen.row());

column#

Επιστρέφει τη στήλη όπου θα εκτυπωθεί το κείμενο στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions
int32_t column();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Returns an int32_t representing the column where text will be printed.

Η αρίθμηση στηλών ξεκινά από το 1.

Notes
  • Η θέση του κέρσορα βασίζεται στην τρέχουσα γραμματοσειρά οθόνης .

  • Η επιστρεφόμενη τιμή υποδεικνύει πού θα εμφανιστεί η επόμενη εκτυπωμένη έξοδος.

  • The column value changes when text is printed or when setCursor is called.

Examples
// Display the cursor's current column
Brain.Screen.print("column: ", Brain.Screen.column());

getStringHeight#

Επιστρέφει το ύψος, σε pixel, μιας συμβολοσειράς όταν αποδίδεται στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions
int32_t getStringHeight( 
    const char* cstr );

Parameters

Παράμετρος

Τύπος

Περιγραφή

cstr

const char*

The text to be measured, provided as a C-style string (for example, “Hello”).

Return Values

Returns an int32_t representing the height of the string in pixels when rendered on the Brain screen.

Notes
  • Το επιστρεφόμενο ύψος εξαρτάται από την τρέχουσα επιλεγμένη γραμματοσειρά οθόνης .

  • Αυτή η συνάρτηση μετρά τη συμβολοσειρά χωρίς να την απεικονίζει στην οθόνη.

  • Το επιστρεφόμενο ύψος αντικατοπτρίζει τον τρόπο με τον οποίο θα εμφανιζόταν η συμβολοσειρά κατά την εκτύπωση.

getStringWidth#

Επιστρέφει το πλάτος, σε pixel, μιας συμβολοσειράς όταν αποδίδεται στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions
int32_t getStringWidth( 
    const char* cstr );

Parameters

Παράμετρος

Τύπος

Περιγραφή

cstr

const char*

The text to be measured, provided as a C-style string (for example, “Hello”).

Return Values

Returns an int32_t representing the width of the string in pixels when rendered on the Brain screen.

Notes

printAt#

Εκτυπώνει κείμενο, αριθμούς ή λογικές τιμές σε μια συγκεκριμένη συντεταγμένη στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions

1 Εκτυπώνει τη μορφοποιημένη έξοδο στην καθορισμένη θέση pixel.

void printAt(
    int32_t    x,
    int32_t    y,
    const char* format,
    ... );

2 Εκτυπώνει τη μορφοποιημένη έξοδο στην καθορισμένη θέση pixel και ορίζει εάν το φόντο κειμένου είναι αδιαφανές ή διαφανές.

void printAt(
    int32_t    x,
    int32_t    y,
    bool       bOpaque,
    const char* format,
    ... );

Parameters

Παράμετρος

Τύπος

Περιγραφή

x

int32_t

Η θέση x για εκτύπωση, με αναφορά στην αρχή της οθόνης.

y

int32_t

Η θέση y για εκτύπωση, με αναφορά στην αρχή της οθόνης.

bOpaque

bool

Controls whether the printed text is drawn opaquely or transparently:

  • true — The background of the printed text is filled using the current fill color.
  • false — The text is drawn transparently and the background is not filled.

format

const char*

A format string that controls what is printed on the screen (for example, “Score: %d”).

Μία ή περισσότερες πρόσθετες τιμές που εισάγονται στη συμβολοσειρά μορφοποίησης, διαχωρισμένες με κόμματα.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • The x and y coordinates are relative to the current screen origin, which can be changed using setOrigin.

  • Το τυπωμένο κείμενο χρησιμοποιεί την τρέχουσα γραμματοσειρά οθόνης .

  • Το εκτυπωμένο κείμενο χρησιμοποιεί το τρέχον χρώμα πένας .

  • Όταν χρησιμοποιείτε μια συμβολοσειρά μορφοποίησης, ο αριθμός και οι τύποι των τιμών που διαβιβάζονται πρέπει να ταιριάζουν με τους προσδιοριστές μορφής στη συμβολοσειρά.

Examples
// Print the number 1 at pixel (100, 40)
Brain.Screen.printAt(100, 40, 1);

clearScreen#

Διαγράφει όλα τα σχέδια και το κείμενο από την οθόνη του Εγκεφάλου.

Available Functions

1 Μαυρίζει την οθόνη.

void clearScreen();

2 Καθαρίζει την οθόνη χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.

void clearScreen(
    const color& color );

3 Καθαρίζει την οθόνη χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.

void clearScreen(
    const char* color );

4 Καθαρίζει την οθόνη χρησιμοποιώντας μια τιμή απόχρωσης.

void clearScreen(
    int hue );

Parameters

Παράμετρος

Τύπος

Περιγραφή

color

const color&

Clears the screen using a color object. Predefined colors include:

  • black
  • white
  • red
  • green
  • blue
  • yellow
  • orange
  • purple
  • cyan
  • transparent
This can also use a custom color object.

color

const char*

Clears the screen using a hexadecimal color value represented as a string (for example, “#000000”).

hue

int

Clears the screen using an integer hue value in the range 0359, representing degrees around a color wheel.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

Examples
// Clear screen after 2 seconds
Brain.Screen.print("VEXcode");
wait(2, seconds);
Brain.Screen.clearScreen();


// Clear screen to blue after 2 seconds
Brain.Screen.print("VEXcode");
wait(2, seconds);
Brain.Screen.clearScreen(red);

setFont#

Ορίζει τη γραμματοσειρά που χρησιμοποιείται για το κείμενο που εμφανίζεται στην οθόνη IQ (1ης γενιάς) Brain.

This controls the font applied to subsequent text output when using screen text functions such as print.

Available Functions
void setFont(
  fontType font );

Parameters

Παράμετρος

Τύπος

Περιγραφή

font

fontType

Sets the font to one of the following:

  • mono12
  • mono15
  • mono20
  • mono30
  • mono40
  • mono60
  • prop20
  • prop30
  • prop40
  • prop60
These options are shown below.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Examples
// Display two different fonts on
// two separate lines
Brain.Screen.setFont(mono20);
Brain.Screen.print("Mono Medium");
Brain.Screen.newLine();
Brain.Screen.setFont(prop20);
Brain.Screen.print("Prop Medium");

setPenWidth#

Ορίζει το πάχος των γραμμών που σχεδιάζονται και των περιγραμμάτων σχήματος.

Available Functions
void setPenWidth(
  uint32_t width );

Parameters

Παράμετρος

Τύπος

Περιγραφή

width

uint32_t

Το πλάτος της πένας, σε pixel, κυμαίνεται από 0 έως 32.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes Examples
// Draw a circle with a pen width of 5
Brain.Screen.drawCircle(40, 70, 20);
Brain.Screen.setPenWidth(5);
Brain.Screen.drawCircle(100, 70, 20);

setPenColor#

Ορίζει το χρώμα κειμένου, pixel, γραμμών και περιγραμμάτων σχήματος.

Available Functions

1 Ορίζει το χρώμα της πένας χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.

void setPenColor(
    const color& color );

2 Ορίζει το χρώμα της πένας χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.

void setPenColor(
    const char* color );

3 Ορίζει το χρώμα της πένας χρησιμοποιώντας μια τιμή απόχρωσης.

void setPenColor(
    int hue );

Parameters

Παράμετρος

Τύπος

Περιγραφή

color

const color&

Sets the pen color using a color object. Predefined colors include:

  • black
  • white
  • red
  • green
  • blue
  • yellow
  • orange
  • purple
  • cyan
  • transparent

color

const char*

Sets the pen color using a hexadecimal color value represented as a string (for example, “#FF0000”).

hue

int

Sets the pen color using an integer hue value in the range 0359, representing degrees around a color wheel (for example, 0 is red, 120 is green, and 240 is blue).

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

Examples
Brain.Screen.drawRectangle(100, 50, 10, 20);
Brain.Screen.setPenColor(blue);
Brain.Screen.drawRectangle(50, 50, 10, 20);

setFillColor#

Ορίζει το χρώμα γεμίσματος που χρησιμοποιείται κατά τη σχεδίαση σχημάτων.

Available Functions

1 Ορίζει το χρώμα γεμίσματος χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.

void setFillColor(
    const color& color );

2 Ορίζει το χρώμα γεμίσματος χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.

void setFillColor(
    const char* color );

3 Ορίζει το χρώμα γεμίσματος χρησιμοποιώντας μια τιμή απόχρωσης.

void setFillColor(
    int hue );

Parameters

Παράμετρος

Τύπος

Περιγραφή

color

const color&

Sets the fill color using a color object. Predefined colors include:

  • black
  • white
  • red
  • green
  • blue
  • yellow
  • orange
  • purple
  • cyan
  • transparent

color

const char*

Sets the fill color using a hexadecimal color value represented as a string (for example, “#00FF00”).

hue

int

Sets the fill color using an integer hue value in the range 0359, representing degrees around a color wheel (for example, 0 is red, 120 is green, and 240 is blue).

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

Examples
// Draw a circle filled with yellow
Brain.Screen.setFillColor(yellow);
Brain.Screen.drawCircle(50, 50, 20);

setOrigin#

Ορίζει την προέλευση που χρησιμοποιείται για τη σχεδίαση γραφικών στην οθόνη του εγκεφάλου.

Available Functions
void setOrigin(
  int32_t x,
  int32_t y );

Parameters

Παράμετρος

Τύπος

Περιγραφή

x

int32_t

Η θέση x της αρχής των αξόνων σε σχέση με την επάνω αριστερή γωνία της οθόνης του εγκεφάλου από 0 έως 159.

y

int32_t

Η θέση y της αρχής των αξόνων σε σχέση με την επάνω αριστερή γωνία της οθόνης του εγκεφάλου από 0 έως 107.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η προεπιλεγμένη αρχή είναι η επάνω αριστερή γωνία της οθόνης στη συντεταγμένη (0, 0).

  • The origin applies to coordinate functions such as drawLine, drawRectangle, drawCircle, and printAt.

  • Η προέλευση παραμένει σε ισχύ μέχρι να αλλάξει ξανά ή να γίνει επαναφορά του έργου.

setClipRegion#

Ορίζει μια ορθογώνια περιοχή στην οθόνη όπου θα περιορίζονται όλα τα σχέδια και το κείμενο. Δεν θα εμφανίζεται κανένα περιεχόμενο εκτός αυτής της περιοχής.

Available Functions
void setClipRegion(
  int x,
  int y,
  int width,
  int height );

Parameters

Παράμετρος

Τύπος

Περιγραφή

x

int

Η συντεταγμένη x της επάνω αριστερής γωνίας της περιοχής αποκοπής, που δίνεται ως ακέραιος αριθμός από 0 έως 159.

y

int

Η συντεταγμένη y της επάνω αριστερής γωνίας της περιοχής αποκοπής, που δίνεται ως ακέραιος αριθμός από 0 έως 107.

width

int

Το πλάτος της περιοχής κλιπ σε pixel, που δίνεται ως ακέραιος αριθμός από 0 έως 159.

height

int

Το ύψος της περιοχής κλιπ σε pixel, που δίνεται ως ακέραιος αριθμός από 0 έως 107.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Οι συναρτήσεις σχεδίασης εξακολουθούν να εκτελούνται ακόμη και αν βρίσκονται εκτός της περιοχής κλιπ, αλλά μόνο το τμήμα εντός της περιοχής είναι ορατό.

  • The x and y coordinates are relative to the current screen origin, which can be changed using setOrigin.

  • Η περιοχή αποκοπής ισχύει μόνο για το τρέχον νήμα.

  • Ο ορισμός μιας νέας περιοχής κλιπ αντικαθιστά οποιαδήποτε προηγουμένως ορισμένη περιοχή κλιπ για το τρέχον νήμα.

Examples
// Restrict text and drawings to a specific region
Brain.Screen.setClipRegion(0, 0, 120, 120);
Brain.Screen.drawRectangle(60, 60, 100, 100, red);
Brain.Screen.printAt(60, 60, "Cut off!");

drawPixel#

Σχεδιάζει ένα μόνο pixel στην οθόνη IQ (1ης γενιάς) Brain στην καθορισμένη θέση pixel x και y.

Available Functions
void drawPixel(
  int x,
  int y );

Parameters

Παράμετρος

Τύπος

Περιγραφή

x

int

Η συντεταγμένη x όπου θα σχεδιαστεί το εικονοστοιχείο, η οποία δίνεται ως ακέραιος αριθμός από 0 έως 159.

y

int

Η συντεταγμένη y όπου θα σχεδιαστεί το εικονοστοιχείο, η οποία δίνεται ως ακέραιος αριθμός από 0 έως 107.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

  • The x and y coordinates are relative to the current screen origin, which can be set using setOrigin.

  • Εάν η καθορισμένη θέση του pixel βρίσκεται εκτός των ορίων της οθόνης, το pixel δεν σχεδιάζεται.

Examples
// Draw one pixel at the center 
// of the screen
Brain.Screen.drawPixel(80, 50);

drawLine#

Σχεδιάζει μια ευθεία γραμμή που συνδέει δύο σημεία στην οθόνη IQ (1ης γενιάς) Brain.

Available Functions
void drawLine(
  int x1,
  int y1,
  int x2,
  int y2 );

Parameters

Παράμετρος

Τύπος

Περιγραφή

x1

int

Η αρχική συντεταγμένη x της γραμμής, που δίνεται ως ακέραιος αριθμός από 0 έως 159.

y1

int

Η αρχική συντεταγμένη y της γραμμής, που δίνεται ως ακέραιος αριθμός από 0 έως 107.

x2

int

Η τελική συντεταγμένη x της γραμμής, που δίνεται ως ακέραιος αριθμός από 0 έως 159.

y2

int

Η τελική συντεταγμένη y της γραμμής, η οποία δίνεται ως ακέραιος αριθμός από 0 έως 107.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

  • The width of the line is determined by the current pen width set with setPenWidth.

  • The x and y coordinates are relative to the current screen origin, which can be set using setOrigin.

  • Εάν οποιοδήποτε τμήμα της γραμμής βρίσκεται εκτός των ορίων της οθόνης, σχεδιάζεται μόνο το ορατό τμήμα.

Examples
// Draw a line from the top left to 
// bottom right of the screen
Brain.Screen.drawLine(0, 0, 159, 107);

drawRectangle#

Σχεδιάζει ένα ορθογώνιο στην οθόνη IQ (1ης γενιάς) Brain στην καθορισμένη θέση και μέγεθος.

Available Functions

1 Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας το τρέχον διαμορφωμένο χρώμα γεμίσματος.

void drawRectangle(
    int x,
    int y,
    int width,
    int height );

2 Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.

void drawRectangle(
    int           x,
    int           y,
    int           width,
    int           height,
    const color&  color );

3 Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.

void drawRectangle(
    int           x,
    int           y,
    int           width,
    int           height,
    const char*   color );

4 Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας μια τιμή απόχρωσης.

void drawRectangle(
    int x,
    int y,
    int width,
    int height,
    int hue );

Parameters

Παράμετρος

Τύπος

Περιγραφή

x

int

Η συντεταγμένη x της επάνω αριστερής γωνίας του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 159.

y

int

Η συντεταγμένη y της επάνω αριστερής γωνίας του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 107.

width

int

Το πλάτος του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 159.

height

int

Το ύψος του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 107.

color

const color&

Fills the rectangle using a color object. Predefined colors include:

  • black
  • white
  • red
  • green
  • blue
  • yellow
  • orange
  • purple
  • cyan
  • transparent
This can also use a custom color object.

color

const char*

Fills the rectangle using a hexadecimal color value (for example, “#FF0000”).

hue

int

Fills the rectangle using a hue value in the range 0359.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

  • The outline thickness is determined by the current pen width set with setPenWidth.

  • The x and y coordinates are relative to the current screen origin, which can be changed using setOrigin.

  • Εάν οποιοδήποτε τμήμα του ορθογωνίου βρίσκεται εκτός των ορίων της οθόνης, σχεδιάζεται μόνο το ορατό τμήμα.

Examples
// Draw a red rectangle on the screen
Brain.Screen.drawRectangle(25, 25, 100, 50, red);

drawCircle#

Σχεδιάζει έναν κύκλο στην οθόνη IQ (1ης γενιάς) Brain στην καθορισμένη θέση και ακτίνα.

Available Functions

1 Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας το τρέχον διαμορφωμένο χρώμα γεμίσματος.

void drawCircle(
    int x,
    int y,
    int radius );

2 Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.

void drawCircle(
    int           x,
    int           y,
    int           radius,
    const color&  color );

3 Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.

void drawCircle(
    int           x,
    int           y,
    int           radius,
    const char*   color );

4 Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας μια τιμή απόχρωσης.

void drawCircle(
    int x,
    int y,
    int radius,
    int hue );

Parameters

Παράμετρος

Τύπος

Περιγραφή

x

int

Η συντεταγμένη x του κέντρου του κύκλου, που δίνεται ως ακέραιος αριθμός από 0 έως 159.

y

int

Η συντεταγμένη y του κέντρου του κύκλου, που δίνεται ως ακέραιος αριθμός από 0 έως 107.

radius

int

Η ακτίνα του κύκλου, που δίνεται ως ακέραιος αριθμός από 0 έως 107 pixel.

color

const color&

Fills the circle using a color object. Predefined colors include:

  • black
  • white
  • red
  • green
  • blue
  • yellow
  • orange
  • purple
  • cyan
  • transparent
This can also use a custom color object.

color

const char*

Fills the circle using a hexadecimal color value (for example, “#FF0000”).

hue

int

Fills the circle using a hue value in the range 0359.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η οθόνη IQ (1ης γενιάς) Brain είναι μονόχρωμη, επομένως τα συγκεκριμένα χρώματα δεν θα εμφανίζονται στην οθόνη.

  • The outline thickness is determined by the current pen width set with setPenWidth.

  • The x and y coordinates are relative to the current screen origin, which can be changed using setOrigin.

Examples
// Draw a green circle on the screen
Brain.Screen.drawCircle(80, 50, 20, green);

render#

Enables double buffering for the Brain’s screen. Once called, any drawing functions (like text or shapes) will no longer appear immediately for the rest of the project. Instead, updates will only be shown when render is used again. This allows for smoother and more controlled screen updates, but means nothing will be visible until render is used.

Available Functions

1 Ενεργοποιεί τη διπλή προσωρινή αποθήκευση ή αποδίδει την προσωρινή αποθήκευση στην οθόνη.

bool render();

2 Αποδίδει το back buffer στην οθόνη με έλεγχο της συμπεριφοράς κάθετου συγχρονισμού και προαιρετική εκτέλεση χρονοδιαγράμματος.

bool render(
    bool bVsyncWait,
    bool bRunScheduler = true );

Parameters

Παράμετρος

Τύπος

Περιγραφή

bVsyncWait

bool

  • true — Wait for the screen’s vertical refresh before rendering to reduce visual tearing.
  • false — Do not wait for the screen’s vertical refresh before rendering.

bRunScheduler

bool

Optional.

  • true (default) — Allow background tasks to run while waiting to render.
  • false — Do not allow background tasks to run while waiting to render.

Return Values

Returns a Boolean indicating whether the saved drawings in the buffer were successfully rendered to the screen:

  • true — The drawings were successfully rendered on the screen.
  • false — The drawings could not be rendered on the screen.
  • Notes
    • Calling render will require render to be used for the rest of the project.

    Examples
    Brain.Screen.render();
    
    // Draw text to the back buffer
    Brain.Screen.print("Render later...");
    
    // Wait for a screen press to render drawings
    while (!Brain.Screen.pressing()) {
      wait(20, msec);
    }
    Brain.Screen.render();