Οθόνη#

Εισαγωγή#

The screen class is derived from the brain base class. It controls how the EXP Brain shows text, numbers, and graphics on its screen.

Η οθόνη του EXP Brain έχει έναν καθορισμένο αριθμό γραμμών και στηλών που μπορούν να χρησιμοποιηθούν κατά την εκτύπωση κειμένου στην οθόνη της.

By default, the font for printing to the Brain is mono20 which has 7 rows and 20 columns.

Για το σχέδιο, η ανάλυση του Brain είναι 159 x 107 pixel.

Ένα διάγραμμα πλέγματος με ετικέτες της οθόνης VEX Brain που δείχνει γραμμές, στήλες, διαστάσεις pixel και συντεταγμένες, με κόκκινες γραμμές που σκιαγραφούν το πλέγμα.

Πρόσβαση#

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 EXP 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.

  • drawImageFromFile — Draws an image from an SD card file onto the screen.

  • 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 EXP Brain
brain Brain = brain();

print#

Εμφανίζει κείμενο, αριθμούς ή λογικές τιμές στην οθόνη EXP 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!");

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει την ένδειξη Hello, Robot! τυπωμένη στην οθόνη στην επάνω αριστερή γωνία με λευκό κείμενο.

setCursor#

Moves the cursor to a specific row and column on the EXP 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
  • Affects where subsequent text output begins when using print.

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

  • The default font (mono20) uses 12 rows and 48 columns.

  • Calling setCursor affects the position of subsequent text output only.

Examples
// Display text starting at Row 3 Column 10
Brain.Screen.setCursor(3, 10);
Brain.Screen.print("R3, C10");

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει τη Γραμμή 3, Στήλη 12, τυπωμένη στο πάνω μέρος κοντά στο κέντρο της οθόνης, σε αυτήν τη θέση.

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("Line 1");
Brain.Screen.newLine();
Brain.Screen.print("Line 2");

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει δύο γραμμές λευκού κειμένου στην επάνω αριστερή γωνία. Η επάνω γραμμή αναφέρει τη Γραμμή 1 και η δεύτερη γραμμή ακριβώς από κάτω αναφέρει τη Γραμμή 2.

clearLine#

Διαγράφει κείμενο από μια σειρά στην οθόνη EXP 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.

  • The hue parameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

Ένας χρωματικός κύκλος που δείχνει το εύρος των χρωμάτων από 0 έως 359, όπου το κόκκινο είναι 0, το πράσινο είναι 120 και το μπλε είναι 240.

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#

Επιστρέφει τη γραμμή όπου θα εκτυπωθεί το κείμενο στην οθόνη EXP 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, 10);
Brain.Screen.print(Brain.Screen.row());

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει το κείμενο 3 με λευκά χρώματα στο επάνω αριστερό τεταρτημόριο της οθόνης, στη θέση 10 της στήλης 3 της σειράς 3.

column#

Επιστρέφει τη στήλη όπου θα εκτυπωθεί το κείμενο στην οθόνη EXP 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.setCursor(3, 10);
Brain.Screen.print(Brain.Screen.column());

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει το κείμενο 10 με λευκά χρώματα στο επάνω αριστερό τεταρτημόριο της οθόνης, στη θέση 10 της στήλης 3 της σειράς 3.

getStringHeight#

Επιστρέφει το ύψος, σε pixel, μιας συμβολοσειράς όταν αποδίδεται στην οθόνη EXP 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, μιας συμβολοσειράς όταν αποδίδεται στην οθόνη EXP 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#

Εκτυπώνει κείμενο, αριθμούς ή λογικές τιμές σε μια συγκεκριμένη συντεταγμένη στην οθόνη EXP 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
  • The hue parameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

Ένας χρωματικός κύκλος που δείχνει το εύρος των χρωμάτων από 0 έως 359, όπου το κόκκινο είναι 0, το πράσινο είναι 120 και το μπλε είναι 240.

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(blue);

setFont#

Ορίζει τη γραμματοσειρά που χρησιμοποιείται για το κείμενο που εμφανίζεται στην οθόνη EXP 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.

Η οθόνη του εγκεφάλου εκτύπωσε αριθμούς και γράμματα με γραμματοσειρά mono 12. Δείχνει από το Α έως το Ω και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, αναγράφονται 9 σειρές, 26 στήλες.
mono12

Η οθόνη του εγκεφάλου εκτύπωσε αριθμούς και γράμματα με γραμματοσειρά mono μεγέθους 15. Δείχνει από το A έως το T και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, αναγράφεται 7 σειρές, 22 στήλες.
mono15

Η οθόνη του εγκεφάλου εκτύπωσε αριθμούς και γράμματα με γραμματοσειρά mono 20. Δείχνει από το A έως το P και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, αναγράφει 5 σειρές, 16 στήλες.
mono20

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά mono 30. Εμφανίζει από A έως J. Στο κάτω μέρος της οθόνης, αναγράφει R:3 C:10.
mono30

Η οθόνη του εγκεφάλου εκτύπωσε αριθμούς και γράμματα με γραμματοσειρά mono 40. Στο κάτω μέρος της οθόνης, αναγράφεται R:2 C:8.
mono40

Ο εγκέφαλος εκτύπωσε αριθμούς και γράμματα με γραμματοσειρά mono μεγέθους 60. Εμφανίζεται μόνο το MON60.
mono60

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους prop 20. Δείχνει από το A έως το W και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, λέει 5 σειρές, 16 στήλες.
prop20

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους prop 30. Δείχνει από το A έως το P. Στο κάτω μέρος της οθόνης, γράφει R:3 C:10.
prop30

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους prop 40. Στο κάτω μέρος της οθόνης, γράφει R:2 C:8.
prop40

Οι αριθμοί και τα γράμματα του TThe Brain εκτυπώθηκαν με μεταξοτυπία σε γραμματοσειρά prop 60. Εμφανίζεται μόνο το PROP60.
prop60

Return Values

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

Examples
// Print larger text
Brain.Screen.setFont(mono40);
Brain.Screen.print("VEX");

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει λευκό κείμενο που διαβάζει VEX σε μεγαλύτερη γραμματοσειρά από την προεπιλεγμένη, στην επάνω αριστερή γωνία.

setPenWidth#

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

Available Functions
void setPenWidth(
  uint32_t width );

Parameters

Παράμετρος

Τύπος

Περιγραφή

width

uint32_t

Το πλάτος της πένας σε pixel ως εύρος από 0 έως 32.

Return Values

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

Notes Examples
// Draw a rectangle with a pen width of 10
Brain.Screen.setPenWidth(10);
Brain.Screen.drawRectangle(20, 20, 75, 50);

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει ένα ορθογώνιο με παχιά περιγράμματα τυπωμένα στην αριστερή πλευρά της οθόνης.

setPenColor#

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

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
This can also use a custom color object.

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
  • The default pen color at the start of a project is white.

  • The pen color is used for outlines of shapes (such as with drawCircle or drawRectangle), text and numeric output (with print and printAt), and individual pixels drawn with drawPixel.

  • The hue parameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

Ένας χρωματικός κύκλος που δείχνει το εύρος των χρωμάτων από 0 έως 359, όπου το κόκκινο είναι 0, το πράσινο είναι 120 και το μπλε είναι 240.

Examples
// Draw a rectangle with orange borders
Brain.Screen.setPenColor(orange);
Brain.Screen.drawRectangle(20, 20, 75, 50);

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει ένα ορθογώνιο σχεδιασμένο με πορτοκαλί χρώμα στην αριστερή πλευρά της οθόνης.

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
This can also use a custom color object.

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
  • The default fill color at the start of a project is black.

  • The fill color is used for interior of shapes (such as with drawCircle or drawRectangle).

  • The fill color is used as the background color for printed text (such as with print and printAt).

    • If transparent is used with printed text, the background will be black.

  • The hue parameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

Ένας χρωματικός κύκλος που δείχνει το εύρος των χρωμάτων από 0 έως 359, όπου το κόκκινο είναι 0, το πράσινο είναι 120 και το μπλε είναι 240.

Examples
// Draw a rectangle filled with purple
  Brain.Screen.setFillColor(purple);
  Brain.Screen.drawRectangle(20, 20, 75, 50);

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει ένα ορθογώνιο γεμάτο με μωβ στην αριστερή πλευρά της οθόνης.

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

drawPixel#

Σχεδιάζει ένα pixel στην οθόνη EXP 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
  • Pixels are drawn using the current pen color set with setPenColor.

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

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

Examples
// Draw the pixels marking the corners of a square
Brain.Screen.drawPixel(50, 50);
Brain.Screen.drawPixel(50, 75);
Brain.Screen.drawPixel(75, 50);
Brain.Screen.drawPixel(75, 75);

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain που δείχνει μια συλλογή από pixel που δείχνουν τις γωνίες ενός τετραγώνου κοντά στο κέντρο της οθόνης.

drawLine#

Σχεδιάζει μια ευθεία γραμμή που συνδέει δύο σημεία στην οθόνη EXP 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
  • Lines are drawn using the current pen color set with setPenColor.

  • 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);

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain δείχνει μια λεπτή διαγώνια γραμμή στο κέντρο, από την επάνω αριστερή γωνία έως την κάτω δεξιά γωνία.

drawRectangle#

Σχεδιάζει ένα ορθογώνιο στην οθόνη EXP 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
  • The rectangle outline is drawn using the current pen color set with setPenColor.

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

  • When no color parameter is provided, the rectangle interior is filled using the current fill color set with setFillColor.

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

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

  • The hue parameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

Ένας χρωματικός κύκλος που δείχνει το εύρος των χρωμάτων από 0 έως 359, όπου το κόκκινο είναι 0, το πράσινο είναι 120 και το μπλε είναι 240.

Examples
// Draw a rectangle on the screen
Brain.Screen.drawRectangle(20, 20, 80, 30);

Ένα στιγμιότυπο οθόνης της οθόνης του EXP Brain δείχνει ένα ορθογώνιο με ένα λεπτό λευκό περίγραμμα τυπωμένο στο επάνω αριστερό τεταρτημόριο.

drawCircle#

Σχεδιάζει έναν κύκλο στην οθόνη EXP 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
  • The circle outline is drawn using the current pen color set with setPenColor.

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

  • When no color parameter is provided, the circle interior is filled using the current fill color set with setFillColor.

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

  • The hue parameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

Ένας χρωματικός κύκλος που δείχνει το εύρος των χρωμάτων από 0 έως 359, όπου το κόκκινο είναι 0, το πράσινο είναι 120 και το μπλε είναι 240.

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

Ένα στιγμιότυπο οθόνης της οθόνης EXP Brain δείχνει έναν κύκλο με ένα λεπτό λευκό περίγραμμα στο κέντρο.

drawImageFromFile#

Σχεδιάζει μια εικόνα στην οθόνη EXP Brain χρησιμοποιώντας ένα αρχείο εικόνας που είναι αποθηκευμένο στην κάρτα SD.

Available Functions
bool drawImageFromFile(
  const char* name,
  int x,
  int y );

Parameters

Παράμετρος

Τύπος

Περιγραφή

name

const char*

The filename of the image on the SD card. The file must have a .bmp or .png extension.

x

int

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

y

int

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

Return Values

Returns a Boolean indicating whether the image was successfully drawn:

  • true — The image was successfully loaded and drawn on the screen.
  • false — The image could not be drawn (for example, if the file does not exist or is invalid).

Notes
  • Supported image formats are .bmp and .png.

  • The image file size must not exceed 512 KB.

    • Συνιστάται η κωδικοποίηση RLE 8-bit για την ελαχιστοποίηση του μεγέθους του αρχείου.

  • Οι μέγιστες υποστηριζόμενες διαστάσεις εικόνας είναι το μέγεθος της οθόνης Brain (περίπου 159 x 107 pixel).

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

Examples
// Draw a bmp file on the Brain's screen at coordinate 0, 0
Brain.Screen.drawImageFromFile("test_image.bmp", 0, 0);

render#

Enables double buffering for the Brain’s screen. Once called, any drawing functions (like text, shapes, or images) 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();