شاشة#
مقدمة#
تتحكم طرق الشاشة في كيفية عرض الدماغ (الجيل الثاني) للنصوص والأرقام والرسومات على شاشته المدمجة.
أما بالنسبة للرسم، فإن دقة الدماغ تبلغ 160 × 108 بكسل.
تستخدم هذه الصفحة الاسم brain كمثال لاسم Brain. استبدله بالاسم الذي قمت بتكوينه حسب الحاجة.
فيما يلي قائمة بجميع الطرق:
طباعة المؤشر — ضع النص واطبعه.
print— يطبع النص أو الأرقام أو قيم المتغيرات في موضع المؤشر الحالي.set_cursor— ينقل المؤشر إلى صف وعمود محددين.next_row— ينقل المؤشر إلى العمود 1 من الصف التالي.clear_row— يمسح صفًا من النص.row— تُرجع الصف الذي سيتم فيه طباعة النص.column— تُرجع العمود الذي سيتم طباعة النص فيه.print_at— يطبع النص أو الأرقام أو قيم المتغيرات عند إحداثيات x و y محددة.get_string_width— تُرجع عرض السلسلة بالبكسل باستخدام الخط الحالي.get_string_height— تُرجع ارتفاع السلسلة بالبكسل باستخدام الخط الحالي.
المُعدِّلات — تغيير إعدادات الشاشة والألوان وسلوك الرسم.
clear_screen— يمسح الشاشة من جميع الرسومات والنصوص.set_font— يحدد الخط للنص المطبوع.set_pen_width— يحدد سمك الخطوط المرسومة ومخططات الأشكال.set_pen_color— يحدد لون النص والبكسلات والخطوط ومخططات الأشكال.set_fill_color— يحدد لون التعبئة للأشكال المرسومة وخلفيات النصوص المطبوعة.set_origin— يحدد الأصل المستخدم للطباعة والرسم القائم على الإحداثيات.
ارسم — أضف رسومات إلى الشاشة.
draw_pixel— يرسم بكسل واحد عند إحداثية معينة.draw_line— يرسم خطًا بين نقطتين.draw_rectangle— يرسم مستطيلاً.draw_circle— يرسم دائرة.set_clip_region— يقيد مكان ظهور الرسومات والنصوص.render— يقوم بتحديث شاشة الدماغ بالنصوص والرسومات فقط عند استدعائها.
بصمة المؤشر#
print#
print prints text, numbers, or variable values on the Brain screen at the current cursor position and font.
Usage:
brain.screen.print(text, precision, opaque)
حدود |
وصف |
|---|---|
|
النص أو الرقم أو قيمة المتغير المراد طباعتها على الشاشة. |
|
اختياري. عدد المنازل العشرية المراد عرضها عند عرض الأرقام. يجب كتابة هذا كمعامل مُسمى، على سبيل المثال: |
|
Optional. |
# Display a message at the starting
# cursor position
brain.screen.print("Hello, Robot!")

# Display a percentage with 4 decimal
# places and a blue background
brain.screen.set_fill_color(Color.BLUE)
brain.screen.print((42/100), precision = 4, opaque = True)
set_cursor#
set_cursor moves the cursor to a specific row and column on the Brain screen. The next print call will start printing at that location. How many rows and columns can comfortably fit depends on the selected font.
Monospaced fonts have characters that are all the same width, making text placement consistent. In contrast, proportional fonts vary in character width, so some letters take up more space than others. However, regardless of which type is used, set_cursor positions the cursor based on row and column size, not font style. The font size can be adjusted using set_font.
Usage:
brain.screen.set_cursor(row, column)
حدود |
وصف |
|---|---|
|
الصف الذي سيتم تحريك المؤشر إليه. |
|
العمود الذي سيتم تحريك المؤشر إليه. |
# Repeatedly print the Brain's timer at
# the top left of the screen
while True:
brain.screen.print(brain.timer.time(SECONDS))
brain.screen.next_row()
wait(1, SECONDS)
brain.screen.clear_screen()
brain.screen.set_cursor(1, 1)

next_row#
next_row ينقل المؤشر إلى العمود 1 في الصف التالي على شاشة Brain.
Usage:
brain.screen.next_row()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Display two lines of text
brain.screen.print("Line 1")
brain.screen.next_row()
brain.screen.print("Line 2")

clear_row#
clear_row يمسح صفًا واحدًا من النص على شاشة الدماغ.
Usage:
brain.screen.clear_row(row, color)
حدود |
وصف |
|---|---|
صف |
اختياري. الصف المراد مسحه. القيمة الافتراضية هي صف المؤشر الحالي. |
لون |
Optional. The color to apply to the cleared row. Options include:
|
# Display text on two rows
brain.screen.print("This text stays")
brain.screen.next_row()
brain.screen.print("This disappears")
# Wait 3 seconds before clearing
# only the second row
wait(3, SECONDS)
brain.screen.clear_row()
# Turn the 5th row green
brain.screen.clear_row(5, Color.GREEN)
row#
row تُرجع الصف الذي سيتم فيه طباعة النص كعدد صحيح.
Usage:
brain.screen.row()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Set cursor to (3,2) and print
# row number
brain.screen.set_cursor(3, 2)
brain.screen.print(brain.screen.row())

column#
العمود column يُرجع العمود الذي سيتم فيه طباعة النص كرقم صحيح.
Usage:
brain.screen.column()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Set cursor to (3,2) and print
# column number
brain.screen.set_cursor(3, 2)
brain.screen.print(brain.screen.column())

print_at#
تقوم الدالة print_at بطباعة النصوص أو الأرقام أو قيم المتغيرات على شاشة Brain عند إحداثيات x و y محددة بالبكسل، باستخدام الخط font والأصل origin المُحددين حاليًا. تتجاهل هذه الدالة موضع المؤشر الحالي.
Usage:
brain.screen.print_at(text, x, y, precision, opaque)
حدود |
وصف |
|---|---|
|
النص أو الرقم أو قيمة المتغير المراد طباعتها. |
|
إحداثيات x المراد طباعتها كمعامل رئيسي، أي: |
|
إحداثيات y المراد طباعتها كمعامل رئيسي، أي: |
|
اختياري. عدد المنازل العشرية المراد عرضها عند عرض الأرقام. يجب كتابة هذا كمعامل مُسمى، على سبيل المثال: |
|
Optional. |
# Print the number 1 on the Brain's screen at position (100, 40)
brain.screen.print_at(1, x=100, y=40)

# Display 1/3 with 3 decimal places and a blue background
brain.screen.set_fill_color(Color.BLUE)
brain.screen.print_at((1/3), x=100, y=40, precision=3, opaque=True)
get_string_width#
get_string_width returns the width of a string in pixels as an integer, as it would appear on the Brain’s screen. The width varies depending on the string’s length and the current font.
Usage:
brain.screen.get_string_width(string)
حدود |
وصف |
|---|---|
|
الخيط المراد قياسه. |
get_string_height#
get_string_height returns the height of a string in pixels as an integer, as it would appear on the Brain screen. The height varies depending on the string’s length and the current font.
Usage:
brain.screen.get_string_height(string)
حدود |
وصف |
|---|---|
|
الخيط المراد قياسه. |
المتحولون#
clear_screen#
clear_screen يمسح جميع الرسومات والنصوص من شاشة الدماغ.
Usage:
brain.screen.clear_screen(color)
حدود |
وصف |
|---|---|
|
Optional. Sets the screen color. Options include:
|
# Draw a circle and clear it after
# 2 seconds
brain.screen.draw_circle(80, 50, 20)
wait(2, SECONDS)
brain.screen.clear_screen()
# Turn the screen red
brain.screen.clear_screen(Color.RED)

set_font#
set_font sets the font used for displaying text on the Brain screen. This font will apply to all text printed with print or print_at. The default font at the start of a project is MONO20.
Usage:
brain.screen.set_font(fontname)
المعلمة |
وصف |
|---|---|
|
يُحدد الخط إلى أحد الخيارات التالية:
PROP30PROP40 |
|
|
|
|---|---|---|
|
|
|
|
|
|
|
# Display two different fonts on
# two separate lines
brain.screen.set_font(FontType.MONO20)
brain.screen.print("Mono Medium")
brain.screen.next_row()
brain.screen.set_font(FontType.PROP20)
brain.screen.print("Prop Medium")

set_pen_width#
set_pen_width يحدد سمك الخطوط المرسومة ومخططات الأشكال.
Usage:
brain.screen.set_pen_width(width)
المعلمة |
وصف |
|---|---|
|
عرض القلم، بالبكسل، من 0 إلى 32. |
# Draw two circles with
# different pen widths
brain.screen.draw_circle(40, 70, 20)
brain.screen.set_pen_width(5)
brain.screen.draw_circle(100, 70, 20)

set_pen_color#
set_pen_color يحدد لون النص والبكسلات والخطوط ومخططات الأشكال.
Usage:
brain.screen.set_pen_color(color)
المعلمة |
وصف |
|---|---|
|
Optional. The pen and font color to use. Options include:
|
# Draw two rectangles with
# different colors
brain.screen.draw_rectangle(100, 50, 10, 20)
brain.screen.set_pen_color(Color.BLUE)
brain.screen.draw_rectangle(50, 50, 10, 20)

set_fill_color#
set_fill_color يحدد لون التعبئة المستخدم عند رسم الأشكال.
Usage:
brain.screen.set_fill_color(color)
المعلمة |
وصف |
|---|---|
|
Optional. The fill color to use. Options include:
|
# Draw a yellow circle
brain.screen.set_fill_color(Color.YELLOW)
brain.screen.draw_circle(50, 50, 20)

set_origin#
يُحدد الخيار set_origin نقطة الأصل المستخدمة للرسم والطباعة القائمة على الإحداثيات على شاشة Brain. افتراضيًا، تكون نقطة الأصل هي الزاوية العلوية اليسرى للشاشة.
Usage:
brain.screen.set_origin(x, y)
المعلمة |
وصف |
|---|---|
|
الإحداثي السيني الجديد الذي سيتم تعيينه كنقطة أصل، معطاة كعدد صحيح من 0 إلى 159. |
|
إحداثي y الجديد الذي سيتم تعيينه كنقطة أصل، معطاة كعدد صحيح من 0 إلى 107. |
# Draw a line with the origin set to (50, 50)
brain.screen.set_origin(50, 50)
brain.screen.draw_line(1, 1, 159, 107)

يرسم#
draw_pixel#
draw_pixel draws one pixel at the selected x and y coordinate using the current pen color.
Usage:
brain.screen.draw_pixel(x, y)
المعلمة |
وصف |
|---|---|
|
إحداثي x حيث سيتم رسم البكسل، معطاة كعدد صحيح من 0 إلى 159. |
|
إحداثي y حيث سيتم رسم البكسل، معطاة كعدد صحيح من 0 إلى 107. |
# Draw one pixel at the center
# of the screen
brain.screen.draw_pixel(80, 50)
![]()
draw_line#
draw_line يرسم خطًا من إحداثيات الشاشة الأولى (x1, y1) إلى إحداثيات الشاشة الثانية (x2, y2) باستخدام عرض القلم ولون القلم.
تستخدم إحداثيات x و y الأصل الافتراضي (0، 0) ما لم يتم تعيين أصل مختلف باستخدام set_origin.
Usage:
brain.screen.draw_line(x1, y1, x2, y2)
المعلمة |
وصف |
|---|---|
|
إحداثي البداية للخط على المحور السيني، معطاة كعدد صحيح من 0 إلى 159. |
|
إحداثي y الابتدائي للخط، معطاة كعدد صحيح من 0 إلى 107. |
|
إحداثي س النهائي للخط، معطاة كعدد صحيح من 0 إلى 159. |
|
إحداثي y النهائي للخط، معطاة كعدد صحيح من 0 إلى 107. |
# Draw a line from the top left to
# bottom right of the screen
brain.screen.draw_line(0, 0, 159, 107)

draw_rectangle#
draw_rectangle draws a rectangle with its top-left corner at the selected (x, y) coordinate and a size determined by the given width and height, all measured in pixels. The rectangle’s outline is drawn using the current pen width and pen color. The interior is filled with the current fill color, unless the optional color parameter is used.
تستخدم إحداثيات x و y الأصل الافتراضي (0,0) ما لم يتم تعيين أصل مختلف باستخدام set_origin.
Usage:
brain.screen.draw_rectangle(x, y, width, height, color)
المعلمة |
وصف |
|---|---|
|
الإحداثي السيني للزاوية العلوية اليسرى للمستطيل، معطاة كعدد صحيح من 0 إلى 159. |
|
إحداثي y للزاوية العلوية اليسرى للمستطيل، معطاة كعدد صحيح من 0 إلى 107. |
|
عرض المستطيل بالبكسل. |
|
ارتفاع المستطيل بالبكسل. |
|
Optional. The fill color of the rectangle. Options include:
|
# Draw a red rectangle on the screen
brain.screen.draw_rectangle(25, 25, 100, 50, Color.RED)

draw_circle#
draw_circle draws a circle with its center at the selected (x, y) coordinate and a size determined by the given radius, all measured in pixels. The circle’s outline is drawn using the current pen width and pen color. The interior is filled with the current fill color, unless the optional color parameter is used.
تستخدم إحداثيات x و y الأصل الافتراضي (0,0) ما لم يتم تعيين أصل مختلف باستخدام set_origin.
Usage:
brain.screen.draw_circle(x, y, radius, color)
المعلمة |
وصف |
|---|---|
|
الإحداثي السيني لمركز الدائرة، معطاة كعدد صحيح من 0 إلى 159. |
|
إحداثي y لمركز الدائرة، معطاة كعدد صحيح من 0 إلى 107. |
|
نصف قطر الدائرة بالبكسل. |
|
Optional. The fill color of the circle. Options include:
|
# Draw a green circle on the screen
brain.screen.draw_circle(80, 50, 20, Color.GREEN)

set_clip_region#
يُحدد set_clip_region منطقة مستطيلة على الشاشة حيث سيتم حصر جميع الرسومات والنصوص. ولن يتم عرض أي محتوى خارج هذه المنطقة.
Usage:
brain.screen.set_clip_region(x, y, width, height)
المعلمة |
وصف |
|---|---|
|
إحداثيات x للزاوية العلوية اليسرى لمنطقة القص، معطاة كعدد صحيح أو عدد عشري من 0 إلى 159. |
|
إحداثيات y للزاوية العلوية اليسرى لمنطقة القص، معطاة كعدد صحيح أو عدد عشري من 0 إلى 107. |
|
عرض منطقة القص بالبكسل. |
|
ارتفاع منطقة القص بالبكسل. |
# Restrict text and drawings to a specific region
brain.screen.set_clip_region(0, 0, 120, 120)
brain.screen.draw_rectangle(60, 60, 100, 100, Color.RED)
brain.screen.print_at("Cut off!", x=60, y=60)

render#
يُفعّل الأمر renderrender ) مرة أخرى. يتيح هذا تحديثات أكثر سلاسة وتحكمًا للشاشة، ولكنه يعني أنه لن يكون أي شيء مرئيًا حتى يتم استخدام الأمر `render ).
Usage:
brain.screen.render()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Render text after moving
brain.screen.render()
brain.screen.print("Render later...")
drivetrain.drive_for(FORWARD, 100, MM)
drivetrain.turn_for(RIGHT, 90, DEGREES)
brain.screen.render()









