Προσαρμοσμένα χρώματα#
Εισαγωγή#
Το VEX AIR Drone υποστηρίζει τη χρήση προσαρμοσμένων χρωμάτων για τη σχεδίαση και την εκτύπωση κειμένου. Τα προσαρμοσμένα χρώματα μπορούν να δημιουργηθούν χρησιμοποιώντας τιμές RGB ή δεκαεξαδικούς κωδικούς. Τα προσαρμοσμένα χρώματα περιλαμβάνουν επίσης μεθόδους για την ενημέρωση χρωματικών αντικειμένων κατά τη διάρκεια ενός έργου.
Παρακάτω είναι μια λίστα με τους διαθέσιμους κατασκευαστές:
Constructors – Create a new Color object.
Color(value)– Creates a color using a hex string (e.g."#FFF700") or hex integer (e.g.0xFFF700).Color(r, g, b)– Creates a color using red, green, and blue values.
Μεταλλαγμένοι – Ενημέρωση ενός υπάρχοντος αντικειμένου Color.
rgb– Sets a created color object to a new color using RGB values.hsv– Sets a created color object to a new color using hue, saturation, and brightness values.web– Sets a created color object to a new color using a web hex color string (e.g."#32C8B6").
Getters – Επιστρέφει την τιμή απόχρωσης ή κορεσμού ενός χρωματικού αντικειμένου.
saturation– Returns the saturation value for a custom color.hue– Returns the hue value for a custom color.
Δημιουργία προσαρμοσμένου χρώματος#
To use a custom color, you must first create a Color object using one of the following constructors:
Hexadecimal String#
Δημιουργεί ένα χρώμα χρησιμοποιώντας μια συμβολοσειρά χρώματος ιστού (δεκαεξαδικός κώδικας).
Usage:
Color(value)
Παράμετρος |
Περιγραφή |
|---|---|
|
A six-digit hexidecimal code as a string (e.g., |
# Construct a yellow Color "yellow" using a
# hexadecimal string
yellow = Color("#FFF700")
controller.screen.set_pen_color(yellow)
controller.screen.print("My Yellow")
Hexadecimal Integer#
Δημιουργεί ένα χρώμα χρησιμοποιώντας έναν εξαψήφιο δεκαεξαδικό ακέραιο αριθμό.
Usage:
Color(value)
Παράμετρος |
Περιγραφή |
|---|---|
|
A six-digit integer in hexadecimal format (e.g., |
# Construct a yellow Color "yellow" using a
# hexadecimal integer
yellow = Color(0xFFF700)
controller.screen.set_pen_color(yellow)
controller.screen.print("My Yellow")
RGB#
Δημιουργεί ένα χρώμα χρησιμοποιώντας ξεχωριστές τιμές κόκκινου, πράσινου και μπλε.
Usage:
Color(r, g, b)
Παράμετρος |
Περιγραφή |
|---|---|
|
Ένας ακέραιος αριθμός από 0 έως 255 που αντιπροσωπεύει το κόκκινο στοιχείο. |
|
Ένας ακέραιος αριθμός από 0 έως 255 που αντιπροσωπεύει το πράσινο στοιχείο. |
|
Ένας ακέραιος αριθμός από 0 έως 255 που αντιπροσωπεύει το μπλε στοιχείο. |
# Construct a yellow Color "yellow" using
# RGB values
yellow = Color(255, 247, 0)
controller.screen.set_pen_color(yellow)
controller.screen.print("My Yellow")
Μεταλλάκτες#
These methods update the color of an existing Color object. To use them, assign a Color to a variable when creating it, then call the method on that variable to change its color.
rgb#
rgb updates the color of an existing Color object using RGB values.
Usage:
variable_name.rgb(r, g, b)
Παράμετροι |
Περιγραφή |
|---|---|
|
Ένας ακέραιος αριθμός από 0 έως 255 που αντιπροσωπεύει το κόκκινο στοιχείο του χρώματος. |
|
Ένας ακέραιος αριθμός από 0 έως 255 που αντιπροσωπεύει το πράσινο στοιχείο του χρώματος. |
|
Ένας ακέραιος αριθμός από 0 έως 255 που αντιπροσωπεύει το μπλε στοιχείο του χρώματος. |
# Create a custom teal color
my_fill_color = Color(50, 200, 180)
# Draw a teal rectangle
controller.screen.draw_rectangle(x=30, y=70, width=80, height=50, color=my_fill_color)
# Draw a magenta rectangle
my_fill_color.rgb(170, 40, 150)
controller.screen.draw_rectangle(x=130, y=70, width=80, height=50, color=my_fill_color)
hsv#
hsv updates the color of an existing Color object using HSV values.
Note: hsv can only be used to change a Color object that has already been created. It cannot be used to create a new Color Object.
Usage:
variable_name.hsv(h, s, v)
Παράμετροι |
Περιγραφή |
|---|---|
|
Ένας ακέραιος αριθμός από 0 έως 359 που αντιπροσωπεύει την απόχρωση του χρώματος. |
|
Μια κινητή τιμή από 0,0 έως 1,0 που αντιπροσωπεύει τον κορεσμό του χρώματος. |
|
Μια κινητή τιμή από 0,0 έως 1,0 που αντιπροσωπεύει τη φωτεινότητα του χρώματος. |
# Create a custom teal color
my_fill_color = Color(50, 200, 180)
# Draw a teal rectangle
controller.screen.draw_rectangle(x=30, y=70, width=80, height=50, color=my_fill_color)
# Draw a magenta rectangle
my_fill_color.hsv(300, 0.75, 0.78)
controller.screen.draw_rectangle(x=130, y=70, width=80, height=50, color=my_fill_color)
web#
web updates the color of an existing Color object using a web color (hex code).
Usage:
variable_name.web(value)
Παράμετροι |
Περιγραφή |
|---|---|
|
A web color as a string (hex code) (e.g., |
# Create a custom teal color
my_fill_color = Color("#32C8B6")
# Draw a teal rectangle
controller.screen.draw_rectangle(x=30, y=70, width=80, height=50, color=my_fill_color)
# Draw a magenta rectangle
my_fill_color.web("#AA2896")
controller.screen.draw_rectangle(x=130, y=70, width=80, height=50, color=my_fill_color)
Αποκτητές#
saturation#
saturation returns the saturation value for a custom color as a float from 0 to 1.
Usage:
my_color.saturation()
Replace my_color with the name of the custom color object.
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Create a custom teal color
color_teal = Color(50, 200, 180)
# Display the saturation value of teal
controller.screen.print(color_teal.saturation())
hue#
hue returns the hue value for a custom color as a float from 0 to 359.
Usage:
my_color.hue()
Replace my_color with the name of the custom color object.
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Create a custom teal color
color_teal = Color(50, 200, 180)
# Display the hue value of teal
controller.screen.print(color_teal.hue())