画面#
導入#
スクリーンメソッドは、VEX AIMコーディングロボットが画面上にテキスト、数字、グラフィックを表示する方法、および画面の押下に対してロボットがどのように反応するかを制御します。
以下にすべてのメソッドの一覧を示します。
タッチ操作 – 画面のタッチを検知し、反応します。
pressingを押している – 現在画面が押されているかどうかを返します。x_position– 最後に画面が押されたときの x 座標を返します。y_position– 最後に画面が押されたときの y 座標を返します。
カーソル印刷 – 行/列方式でテキストを表示します。
print– 現在のカーソル位置にテキスト、数値、または変数値を出力します。set_cursor– カーソルを特定の行と列に移動します。next_row– カーソルを次の行の 1 列目に移動します。clear_row– テキストの行をクリアします。get_row– 現在のカーソル行を返します。get_column– 現在のカーソル列を返します。
XYプリント – 画面上の特定座標にテキストを表示します。
print_at– 特定の x 座標と y 座標にテキスト、数値、または変数値を出力します。set_origin– 座標ベースの印刷と描画に使用される原点を設定します。
ミューテーター – 画面をクリアするか、視覚設定を更新します。
clear_screen– 画面上のすべての描画とテキストを消去します。set_font– 印刷テキストのフォントを設定します。set_pen_width– 描画された線と図形の輪郭の太さを設定します。set_pen_color– テキスト、ピクセル、線、図形の輪郭の色を設定します。set_fill_color– 描画された図形と印刷されたテキストの背景の塗りつぶしの色を設定します。
描画 – 画面にグラフィックや画像を追加します。
draw_pixel– 特定の x 座標と y 座標にピクセルを描画します。draw_line– 2点間に線を描画します。draw_rectangle– 長方形を描画します。draw_circle– 円を描画します。show_file– アップロードされた画像を表示します。set_clip_region– 描画とテキストが表示される場所を制限します。
コールバック – 画面が押されたとき、または離されたときに実行される関数。
触る#
pressing#
pressing 返され、ロボットの画面が現在押されているかどうかを示すブール値が返されます。
True– 画面が押されています。False– 画面が押されていません。
Usage:
robot.screen.pressing()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Turn LEDs white only while the screen is pressed.
while True:
if robot.screen.pressing():
robot.led.on(ALL_LEDS, WHITE)
else:
robot.led.off(ALL_LEDS)
wait(50, MSEC)
# Display different messages after the screen is pressed
while not robot.screen.pressing():
wait(5, MSEC)
robot.screen.print("First message!")
robot.screen.next_row()
# Lift finger to press the screen again
while robot.screen.pressing():
wait(5, MSEC)
while not robot.screen.pressing():
wait(5, MSEC)
robot.screen.print("Second message!")
robot.screen.next_row()
x_position#
x_position は、最後に画面が押されたときの x 座標を 0 (左) から 240 (右) までの整数として返します。
Usage:robot.screen.x_position()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Display the x-coordinate of where
# the screen is pressed
while True:
if robot.screen.pressing():
robot.screen.clear_screen()
robot.screen.print(robot.screen.x_position())
wait (50, MSEC)
y_position#
y_position は、最後に画面が押されたときの y 座標を 0 (上) から 240 (下) までの整数として返します。
Usage:robot.screen.y_position()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Display the y-coordinate of where
# the screen is pressed
while True:
if robot.screen.pressing():
robot.screen.clear_screen()
robot.screen.print(robot.screen.y_position())
wait (50, MSEC)
カーソル印字#
print#
print は、現在の カーソル位置 と フォント にテキスト、数値、または変数値をロボットの画面に表示します。
Usage:robot.screen.print(text)
パラメータ |
説明 |
|---|---|
|
画面に表示するテキスト、数値、または変数値。 |
# Display a message at the starting cursor position
robot.screen.print("Hello, Robot!")

set_cursor#
set_cursor は、テキストカーソルをロボットの画面上の特定の行と列に移動します。次の print 呼び出しで、その位置から印刷が開始されます。収まる行数と列数は、選択したフォントによって異なります。デフォルトの等幅中フォントでは、画面には最大 8 行と 13 列がはっきりと表示されます。この範囲を超えて配置されたテキストは、途切れたり、読みにくくなったりする可能性があります。
等幅フォントは文字の幅がすべて同じなので、テキストの配置が一定になります。一方、プロポーショナルフォントは文字の幅が異なるため、文字によって占めるスペースが異なります。ただし、どちらのタイプを使用する場合でも、 set_cursor フォントスタイルではなく、行と列のサイズに基づいてカーソルを配置します。フォントサイズは set_font を使用して調整できます。
Usage:robot.screen.set_cursor(row, column)
パラメータ |
説明 |
|---|---|
|
カーソルを移動する行。 |
|
カーソルを移動させる列。 |
# Display text starting at Row 3 Column 2
robot.screen.set_cursor(3, 2)
robot.screen.print("Row 3, Column 2")

next_row#
next_row 、ロボットの画面上の次の行の 1 列目にカーソルを移動します。
Usage:robot.screen.next_row()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Display two lines of text
robot.screen.print("Line 1")
robot.screen.next_row()
robot.screen.print("Line 2")

clear_row#
clear_row は、ロボットの画面上のテキストの 1 行を消去します。
Usage:robot.screen.clear_row(row, color)
パラメータ |
説明 |
|---|---|
|
オプション。クリアする行を整数で指定します。デフォルトは現在のカーソル行です。 |
|
Optional. The color to apply to the cleared row. Options include:
|
# Display text on two rows
robot.screen.print("This text stays")
robot.screen.next_row()
robot.screen.print("This text disappears")
# Wait 3 seconds before clearing only the second row
wait(3, SECONDS)
robot.screen.clear_row()
# Turn the 5th row green
robot.screen.clear_row(5, GREEN)

get_row#
get_row は、テキストが印刷される現在の行を整数として返します。
Usage:robot.screen.get_row()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Set cursor to (3,2) and print row number
robot.screen.set_cursor(3, 2)
robot.screen.print(robot.screen.get_row())

get_column#
get_column は、テキストが整数として出力される現在の列を返します。
Usage:robot.screen.get_column()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Set cursor to (3,2) and print column number
robot.screen.set_cursor(3, 2)
robot.screen.print(robot.screen.get_column())

XYプリント#
print_at#
print_at prints text, numbers, or variable values on the robot’s screen at a specific x and y coordinate in pixels, using the currently set font and origin. x sets how far from the left side the text begins, and y sets where the bottom of the letters sit. This method disregards the current cursor position.

注: 赤い円は、AIMロボットの円形スクリーンに表示される座標を示しています。赤い円の外側にある座標は0~240の範囲内ですが、スクリーンには表示されません。
Usage:
robot.screen.print_at(text, x, y)
パラメータ |
説明 |
|---|---|
|
画面に表示するテキスト、数値、または変数値。 |
|
テキストの水平位置を、0~240ピクセルの整数で指定します。0は左端、240は右端です。 |
|
テキストの垂直位置を、0~240ピクセルの整数で指定します。0が上端、240が下端です。 |
# Display a message in the middle of the screen
robot.screen.print_at("Hello, Robot!", x=40, y=120)

set_origin#
set_origin は、ロボットの画面上での描画および座標ベースの印刷に使用される原点を設定します。デフォルトでは、原点は画面の左上隅です。
Usage:
robot.screen.set_origin(x, y)
パラメータ |
説明 |
|---|---|
|
原点として設定する新しいx座標。0から240までの整数で指定します。 |
|
原点として設定する新しいy座標。0から240までの整数で指定します。 |
# Set the origin to the center of the screen
robot.screen.set_origin(120, 120)
# Draw a rectangle at the new origin
robot.screen.draw_rectangle(0, 0, 80, 40)

変異誘発者#
clear_screen#
clear_screen 、ロボットの画面上のすべての描画とテキストを消去します。デフォルトでは、カーソル位置も1行目、1列目にリセットされます。
Usage:
robot.screen.clear_screen(color)
パラメータ |
説明 |
|---|---|
|
Optional. Sets the screen color. Options include:
|
# Draw a circle, and clear it after 2 seconds
robot.screen.draw_circle(120, 120, 60)
wait(2, SECONDS)
robot.screen.clear_screen()
# Set the background color of the screen to red
robot.screen.clear_screen(RED)

set_font#
set_font は、ロボットの画面にテキストを表示するために使用されるフォントを設定します。このフォントは、print または print_at で印刷されるすべてのテキストに適用されます。プロジェクト開始時のデフォルトフォントは MONO24です。
Usage:
robot.screen.set_font(fontname)
パラメータ |
説明 |
|---|---|
|
フォントを以下のいずれかに設定します:
PROP60 |
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
# Display text using a larger font
robot.screen.set_font(MONO40)
robot.screen.print("VEX")

set_pen_width#
set_pen_width は、描画される線と図形の輪郭の太さを設定します。
Usage:
robot.screen.set_pen_width(width)
パラメータ |
説明 |
|---|---|
|
ペンの幅(ピクセル単位)。0~32の範囲で指定します。 |
# Draw a rectangle with a pen width of 10
robot.screen.set_pen_width(10)
robot.screen.draw_rectangle(50, 50, 130, 60)

set_pen_color#
set_pen_color は、テキスト、ピクセル、線、および図形の輪郭の色を設定します。
Usage:
robot.screen.set_pen_color(color)
パラメータ |
説明 |
|---|---|
|
オプション。使用するペンとフォントの色。オプションには、
|
# Draw a rectangle with a red pen
robot.screen.set_pen_color(RED)
robot.screen.draw_rectangle(50, 50, 130, 60)

set_fill_color#
set_fill_color は、図形を描画するとき、および印刷されたテキストが背景を使用するときに使用される塗りつぶしの色を設定します。
Usage:robot.screen.set_fill_color(color)
パラメータ |
説明 |
|---|---|
|
Optional. The fill color to use. Options include:
|
# Draw two orange rectangles
robot.screen.set_fill_color(ORANGE)
robot.screen.draw_rectangle(50, 50, 100, 60)
robot.screen.draw_rectangle(50, 130, 100, 60)

# Display text with a purple background
robot.screen.set_fill_color(PURPLE)
robot.screen.print("Highlight")

描く#
draw_pixel#
draw_pixel 、現在の ペンカラー を使用して、選択された x 座標と y 座標に 1 つのピクセルを描画します。
Usage:
robot.screen.draw_pixel(x, y)
パラメータ |
説明 |
|---|---|
|
ピクセルが描画されるx座標。0から240までの整数で指定します。 |
|
ピクセルが描画されるy座標。0から240までの整数で指定します。 |
# Draw a pixel at the center of the screen
robot.screen.draw_pixel(120, 120)
![]()
draw_line#
draw_line は、現在の ペン幅 と ペン色 を使用して、最初の画面座標 (x1, y1) から 2 番目の画面座標 (x2, y2) 線を描画します。
x座標とy座標は、set_originを使用して別の原点が設定されていない限り、デフォルトの原点(0, 0)を使用します。
Usage:
robot.screen.draw_line(x1, y1, x2, y2)
パラメータ |
説明 |
|---|---|
|
直線の開始位置を示すx座標。0から240までの整数で指定します。 |
|
直線の開始y座標。0から240までの整数で指定します。 |
|
直線の終点のx座標。0から240までの整数で指定します。 |
|
直線の終点のy座標。0から240までの整数で指定します。 |
# Draw a line from the top left to bottom right of the screen
robot.screen.draw_line(0, 0, 240, 240)

draw_rectangle#
draw_rectangle 、左上隅が選択された (x, y) 座標にあり、指定された幅と高さでサイズが決まる長方形を描画します。サイズはすべてピクセル単位で測定されます。長方形の輪郭は、現在の ペン幅 と ペン色 を使用して描画されます。オプションの color パラメータが使用されない限り、内部は現在の 塗りつぶし色 で塗りつぶされます。
x座標とy座標は、set_originを使用して別の原点が設定されていない限り、デフォルトの原点(0, 0)を使用します。
Usage:robot.screen.draw_rectangle(x, y, width, height, color)
パラメータ |
説明 |
|---|---|
|
長方形の左上隅のx座標。0から240までの整数で表されます。 |
|
長方形の左上隅のy座標。0から240までの整数で表されます。 |
|
長方形の幅。0から240までの整数で指定します。 |
|
長方形の高さ。0から240までの整数で指定します。 |
|
Optional. The fill color of the rectangle. Options include:
|
# Draw a red rectangle on the screen
robot.screen.draw_rectangle(50, 50, 130, 60, RED)

draw_circle#
draw_circle は、選択された (x, y) 座標を中心とし、指定された半径でサイズが決定される円を描画します。サイズはすべてピクセル単位で測定されます。円の輪郭は、現在の ペン幅 と ペン色 を使用して描画されます。オプションの color パラメータが使用されない限り、内部は現在の 塗りつぶし色 で塗りつぶされます。
x座標とy座標は、set_originを使用して別の原点が設定されていない限り、デフォルトの原点(0, 0)を使用します。
Usage:robot.screen.draw_circle(x, y, radius, color)
パラメータ |
説明 |
|---|---|
|
円の中心のx座標。0から240までの整数で表されます。 |
|
円の中心のy座標。0から240までの整数で表されます。 |
|
円の半径。0~240ピクセルの整数で指定します。 |
|
Optional. The fill color of the circle. Options include:
|
# Draw a green circle on the screen
robot.screen.draw_circle(120, 120, 40, GREEN)

show_file#
show_file は、ロボットの画面にカスタムアップロードされた画像を表示します。その位置は、画像の基準点に基づいて、 x y、および center パラメータを使用して設定されます。
Usage:
robot.screen.show_file(file, x, y, center)
パラメータ |
説明 |
|---|---|
|
使用するカスタムイメージ( |
|
画像の水平方向のオフセット値をピクセル単位の整数で指定します。正の値は右方向への移動、負の値は左方向への移動を示します。 |
|
画像の垂直方向のオフセット値。ピクセル単位の整数で指定します。正の値は下方向へ、負の値は上方向へ移動させます。 |
|
オプション |
# Display uploaded Image 1 in the top left corner
robot.screen.show_file(IMAGE1, 0, 0)
# Show the same image on both sides of the screen
# Image size is 120 x 120
robot.screen.show_file(IMAGE1, 65, 0, center=True)
robot.screen.show_file(IMAGE1, -65, 0, center=True)
set_clip_region#
set_clip_region 画面上の矩形領域を定義し、そこにすべての描画とテキストが収まるようにします。この領域外のコンテンツは表示されません。
Usage:
robot.screen.set_clip_region(x, y, width, height)
パラメータ |
説明 |
|---|---|
|
クリップ領域の左上隅の x 座標を、0 から 240 までの小数 ( |
|
クリップ領域の左上隅のy座標を、0から240までの小数( |
|
クリップ領域の幅をピクセル単位で表したもので、0から240までの小数( |
|
クリップ領域の高さ(ピクセル単位)。0から240までの小数( |
# Restrict text and drawings to a specific region
robot.screen.set_clip_region(0, 0, 120, 120)
robot.screen.draw_rectangle(60, 60, 100, 100, RED)
robot.screen.print_at("Cut off!", x=60, y=60)

コールバック#
pressed#
pressed 押され、ロボットの画面が押されたときに呼び出されるメソッドが登録されます。
Usage:robot.screen.pressed(callback, arg)
パラメータ |
説明 |
|---|---|
|
コントローラー画面が押されたときに実行されるように事前に定義された 関数。 |
|
Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information. |
# Set the LEDs to green when the screen is pressed.
def screen_touched():
robot.led.on(ALL_LEDS, GREEN)
robot.screen.pressed(screen_touched)
released#
released ロボットのスクリーンが解放されたときに呼び出されるメソッドを登録します。
Usage:robot.screen.released(callback, arg)
パラメータ |
説明 |
|---|---|
|
コントローラー画面が押されたときに実行されるように事前に定義された 関数。 |
|
Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information. |
# Set the LEDs to blue when the screen is released.
def screen_released():
robot.led.on(ALL_LEDS, BLUE)
robot.screen.released(screen_released)










