画面#
導入#
スクリーンメソッドは、VEX AIRドローンコントローラーが画面上にテキスト、数字、グラフィック、画像を表示する方法、および画面のタップ操作に反応する方法を制御します。
利用可能なメソッドの一覧は以下のとおりです。
カーソル印刷 – テキストを表示し、印刷カーソルを管理します。
print– 現在のカーソル位置にテキスト、数値、または変数値を出力します。set_cursor– カーソルを特定の行と列に移動します。next_row– カーソルを次の行の 1 列目に移動します。clear_row– テキストの行をクリアします。get_row– テキストが印刷される行を返します。get_column– テキストが印刷される列を返します。
XYプリント – ピクセル単位の座標でテキストを印刷します。
print_at– 特定の x 座標と y 座標にテキスト、数値、または変数値を出力します。set_origin– 座標ベースの印刷と描画に使用される原点を設定します。
ミューテーター – 画面設定、色、描画動作を変更します。
clear_screen– コントローラー画面からすべての描画、テキスト、および画像を消去します。wait_for_render– 画面描画を後からレンダリングする動作に切り替えます。set_font– 印刷テキストのフォントを設定します。set_pen_width– 描画された線と図形の輪郭の太さを設定します。set_pen_color– テキスト、ピクセル、線、図形の輪郭の色を設定します。set_text_fill_color– 印刷されたテキストの背景の塗りつぶしの色を設定します。set_fill_color– 描画された図形の塗りつぶしの色を設定します。
描画 – 画面にグラフィックや画像を追加します。
draw_pixel– 特定の x および y 位置に 1 つのピクセルを描画します。draw_line– 2点間に線を描画します。draw_rectangle– 現在のペンと塗りつぶしの色を使用して長方形を描画します。draw_circle– 現在のペンと塗りつぶしの色を使用して円を描画します。show_file– アップロードされた画像を描画します。
タッチ操作 – 画面のタッチを検知し、反応します。
pressingを押している – 現在画面が押されているかどうかを返します。x_position– 最後に画面が押されたときの x 座標を返します。y_position– 最後に画面が押されたときの y 座標を返します。
コールバック – 画面が押されたとき、または離されたときに実行される関数。
カーソル印字#
print#
print は、現在の カーソル位置 と フォント のコントローラ画面にテキスト、数値、または変数値を印刷します。
Usage:
controller.screen.print(text)
パラメータ |
説明 |
|---|---|
|
画面に表示するテキスト、数値、または変数値。 |
|
オプション。印刷テキスト間の区切り文字。デフォルトでは、 |
|
オプション。最後に印刷されたテキストの後に追加される文字列。デフォルトでは、 |
|
オプション。浮動小数点数を整数として出力する際の小数点以下の桁数。デフォルトでは、精度 |
# Display a message at the starting cursor position.
controller.screen.print("Time to fly!")

# Display the first 2 decimals of pi
controller.screen.print(3.1415, precision = 2)

set_cursor#
set_cursor は、コントローラ画面上の特定の行と列にカーソルを移動します。次の print 呼び出しで、その位置から印刷が開始されます。行と列の間隔は、選択されたフォントを考慮して設定されます。デフォルトの等幅中フォントでは、画面には最大 18 行、53 列までがはっきりと表示されます。この範囲を超えて配置されたテキストは、途中で切れたり、読みにくくなったりする可能性があります。
Usage:
controller.screen.set_cursor(row, col)
パラメータ |
説明 |
|---|---|
|
カーソルを移動する行。 |
|
カーソルを移動させる列。 |
# Display text starting at Row 7 Column 25.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print("Row 7, Column 25")

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

clear_row#
clear_row 、コントローラー画面上のテキスト行をクリアします。
Usage:
controller.screen.clear_row(row, color)
パラメータ |
説明 |
|---|---|
|
オプション。クリアする行を指定します。デフォルトは現在のカーソル行です。 |
|
Optional. The color to apply to the cleared row. If a color is not specified, the
|
# Clear only the second row of text
controller.screen.print("This text stays")
controller.screen.next_row()
controller.screen.print("This text disappears")
wait(3, SECONDS)
controller.screen.clear_row(2)
# Turn the 5th row green.
controller.screen.clear_row(5, GREEN)
get_row#
get_row は、テキストが印刷される現在の行を整数として返します。
Usage:
controller.screen.get_row()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Display the cursor's current row.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print(controller.screen.get_row())

get_column#
get_column は、テキストが印刷される現在の列を整数として返します。
Usage:
controller.screen.get_column()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Display the cursor's current column.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print(controller.screen.get_column())

XYプリント#
print_at#
print_at は、現在の font と origin を使用して、コントローラ画面上の特定の (x, y) ピクセル位置にテキスト、数値、または変数値を印刷します x はテキストの開始位置を左端からどれだけ離すかを設定し、 y は文字の下端の位置を設定します。このメソッドは現在のカーソル位置を無視します。
Usage:
controller.screen.print_at(text, x, y)
パラメータ |
説明 |
|---|---|
|
画面に表示するテキスト、数値、または変数値。 |
|
テキストの水平位置を、0~640ピクセルの整数で指定します。0は左端、640は右端です。 |
|
テキストの垂直位置を、0~480ピクセルの整数で指定します。0が上端、480が下端です。 |
# Display a message in the middle of the screen.
controller.screen.print_at("Hello, drone!", x=320, y=240)

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

変異誘発者#
clear_screen#
clear_screen は、コントローラ画面上のすべての描画、テキスト、および画像を消去します。
Usage:
controller.screen.clear_screen(row, col, color)
パラメータ |
説明 |
|---|---|
|
オプション。画面をクリアした後にカーソルを移動する行。デフォルトは1です。 |
|
オプション。画面をクリアした後にカーソルを移動する列。デフォルトは1です。 |
|
Optional. Sets the screen color. If
|
# Draw a circle, and clear it after 2 seconds.
controller.screen.draw_circle(x=320, y=240, radius=80)
wait(2, SECONDS)
controller.screen.clear_screen()
# Print two messages in the same spot
controller.screen.print("Hello!")
wait(3,SECONDS)
controller.screen.clear_screen(row=1, col=1)
controller.screen.print("Goodbye!")
# Set the background color of the screen to red.
controller.screen.clear_screen(color=RED)
wait_for_render#
wait_for_render は、画面描画を後からレンダリングする動作に切り替えます。このメソッドが実行されると、次の wait_for_render メソッドが実行されるまで、後続の画面コマンドはコントローラ画面に表示されません。
注: テキスト、図形、または画像のグループを描画する前にこれを使用し、その後、完全な更新を一度にレンダリングするために再度使用してください。
Usage:
controller.screen.wait_for_render()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Display text and images when button 7 is pressed.
controller.screen.wait_for_render()
controller.screen.print("Screen rendered!")
controller.screen.draw_circle(x=320, y=240, radius=80)
while not controller.button7.pressing():
wait(5, MSEC)
controller.screen.wait_for_render()

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

set_pen_width#
set_pen_width は、描画される線と図形の輪郭の太さを設定します。
Usage:
controller.screen.set_pen_width(width)
パラメータ |
説明 |
|---|---|
|
ペンの幅をピクセル単位の整数で指定します。 |
# Draw a rectangle with a pen width of 10.
controller.screen.set_pen_width(10)
controller.screen.draw_rectangle(x=200, y=200, width=200, height=80)

set_pen_color#
set_pen_color は、テキスト、ピクセル、線、および図形の輪郭の色を設定します。
Usage:
controller.screen.set_pen_color(color)
パラメータ |
説明 |
|---|---|
|
Optional. Sets the pen and font color. Options include:
|
# Draw a rectangle with an orange outline.
controller.screen.set_pen_color(ORANGE)
controller.screen.draw_rectangle(x=200, y=150, width=240, height=150)
controller.screen.set_pen_color(WHITE)
controller.screen.print_at("VEXcode AIR", x=250, y=220)

set_text_fill_color#
set_text_fill_color は、印刷されるテキストの背景の塗りつぶし色を設定します。デフォルトのテキストの塗りつぶし色は透明です。
Usage:
controller.screen.set_text_fill_color(color)
パラメータ |
説明 |
|---|---|
|
Optional. Sets the text fill color. Options include:
|
# Display two colors behind text
controller.screen.set_text_fill_color(RED)
controller.screen.print("Red")
controller.screen.next_row()
controller.screen.set_text_fill_color(BLUE)
controller.screen.print("Blue")

set_fill_color#
set_fill_color は、図形を描画する際に使用される塗りつぶしの色を設定します。デフォルトの塗りつぶしの色は黒です。
Usage:
controller.screen.set_fill_color(color)
パラメータ |
説明 |
|---|---|
|
Optional. Sets the fill color. Options include:
|
# Draw an orange-filled rectangle with text on top
controller.screen.set_fill_color(ORANGE)
controller.screen.draw_rectangle(x=200, y=150, width=250, height=150)
controller.screen.print_at("VEXcode AIR", x=250, y=220)

描く#
draw_pixel#
draw_pixel 、現在の ペンカラー を使用して、選択された x 座標と y 座標に 1 つのピクセルを描画します。
Usage:
controller.screen.draw_pixel(x, y)
パラメータ |
説明 |
|---|---|
|
ピクセルが描画されるx座標。0から640までの整数で指定します。 |
|
ピクセルが描画されるy座標。0から480までの整数で指定します。 |
# Draw five pixels in a diagonal.
controller.screen.draw_pixel(x=360, y=200)
controller.screen.draw_pixel(x=340, y=220)
controller.screen.draw_pixel(x=320, y=240)
controller.screen.draw_pixel(x=300, y=260)
controller.screen.draw_pixel(x=280, y=280)
![]()
draw_line#
draw_line は、現在の ペン幅 と ペン色 を使用して、最初の画面座標 (x1, y1) から 2 番目の画面座標 (x2, y2) 線を描画します。
x座標とy座標は、set_originを使用して別の原点が設定されていない限り、デフォルトの原点(0, 0)を使用します。
Usage:
controller.screen.draw_line(x1, y1, x2, y2)
パラメータ |
説明 |
|---|---|
|
直線の開始位置を示すx座標。0から640までの整数で指定します。 |
|
直線の開始y座標。0から480までの整数で指定します。 |
|
直線の終点のx座標。0から640までの整数で指定します。 |
|
直線の終点のy座標。0から480までの整数で指定します。 |
# Make an X across the screen.
controller.screen.draw_line(x1=0, y1=0, x2=640, y2=480)
controller.screen.set_pen_color(CYAN)
controller.screen.draw_line(x1=0, y1=480, x2=640, y2=0)

draw_rectangle#
draw_rectangle は、オプションの color パラメータが使用されない限り、現在の ペン幅、ペン色、および 塗りつぶし色 を使用して長方形を描画します。
x座標とy座標は、set_originを使用して別の原点が設定されていない限り、デフォルトの原点(0, 0)を使用します。
Usage:
controller.screen.draw_rectangle(x, y, width, height, color)
パラメータ |
説明 |
|---|---|
|
長方形の左上隅のx座標。0から640までの整数で表されます。 |
|
長方形の左上隅のy座標。0から480までの整数で表されます。 |
|
長方形の幅。0から640までの整数で指定します。 |
|
長方形の高さ。0から480までの整数で指定します。 |
|
Optional. Sets the fill color of the rectangle. Options include:
|
# Draw two rectangles on the screen.
controller.screen.draw_rectangle(x=0, y=0, width=620, height=460)
controller.screen.draw_rectangle(x=200, y=180, width=200, height=100, color=GREEN)

draw_circle#
draw_circle は、オプションの color パラメータが使用されない限り、現在の ペン幅、ペン色、および 塗りつぶし色 を使用して円を描画します。
x座標とy座標は、set_originを使用して別の原点が設定されていない限り、デフォルトの原点(0, 0)を使用します。
Usage:
controller.screen.draw_circle(x, y, radius, color)
パラメータ |
説明 |
|---|---|
|
円の中心のx座標。0から640までの整数で表されます。 |
|
円の中心のy座標。0から480までの整数で表されます。 |
|
円の半径。0~480ピクセルの整数で指定します。 |
|
Optional. Sets the fill color of the circle. Options include:
|
# Draw one green circle on the screen.
controller.screen.set_fill_color(GREEN)
controller.screen.draw_circle(x=320, y=240, radius=200, color=GREEN)

show_file#
show_file は、カスタムアップロードされた画像をコントローラー画面上の x および y 位置に描画します。オプションで拡大縮小、回転、およびアルファ透明度を設定できます。
Usage:
controller.screen.show_file(file, x, y, scale_width, scale_height, rotation, use_alpha)
パラメータ |
説明 |
|---|---|
|
ユーザーがアップロードした画像を使用します。コントロールパネルで画像名を編集すると、オプションも変更されます。 |
|
画像の水平方向のオフセット値をピクセル単位の整数で指定します。正の値は右方向への移動、負の値は左方向への移動を示します。 |
|
画像の垂直方向のオフセット値。ピクセル単位の整数で指定します。正の値は下方向へ、負の値は上方向へ移動させます。 |
|
オプション。拡大縮小後の画像の幅をピクセル単位の整数で指定します。 |
|
オプション。拡大縮小後の画像の高さをピクセル単位の整数で指定します。 |
|
オプション。画像を回転させる角度(度数)。0~359の整数で指定します。 |
|
オプション。画像のアルファチャンネルを透明度に使用するかどうか。オプションは次のとおりです |
# Display uploaded Image 1 in the top left corner.
controller.screen.show_file(IMAGE1, x=0, y=0)
# Display uploaded Image 1 scaled to the full screen.
controller.screen.show_file(IMAGE1, x=65, y=0, scale_width=640, scale_height=480)
# Display uploaded Image 1 with rotation of 180 degrees.
controller.screen.show_file(IMAGE1, x=-65, y=0, rotation=180)
# Upload an image with a transparent background.
# Display uploaded Image 1 with alpha channel enabled.
controller.screen.show_file(IMAGE1, x=0, y=0, use_alpha=True)
触る#
pressing#
pressing 返され、ロボットの画面が現在押されているかどうかを示すブール値が返されます。
True– 画面が押されています。False– 画面が押されていません。
Usage:
controller.screen.pressing()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Play a sound when the screen is pressed.
while True:
if controller.screen.pressing():
controller.sound.play_note("C5", 500)
wait(5, MSEC)
# Display different messages after the screen is pressed
while not controller.screen.pressing():
wait(5, MSEC)
controller.screen.print("First message!")
controller.screen.next_row()
# Lift finger to press the screen again
while controller.screen.pressing():
wait(5, MSEC)
while not controller.screen.pressing():
wait(5, MSEC)
controller.screen.print("Second message!")
controller.screen.next_row()
x_position#
x_position は、画面が最後に押された位置のピクセル単位の x 座標を、0 (左) から 640 (右) までの整数として返します。

Usage:
controller.screen.x_position()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Play a high or low note based on where screen is pressed.
while True:
if controller.screen.pressing():
if controller.screen.x_position() > 320:
controller.sound.play_note("C6", 500)
else:
controller.sound.play_note("C4", 500)
wait(5, MSEC)
y_position#
y_position は、画面が最後に押された位置の y 座標をピクセル単位で、0 (上) から 480 (下) までの整数として返します。

Usage:
controller.screen.y_position()
# Play a high or low note based on where screen is pressed.
while True:
if controller.screen.pressing():
if controller.screen.y_position() > 240:
controller.sound.play_note("C6", 500)
else:
controller.sound.play_note("C4", 500)
wait(5, MSEC)
コールバック#
pressed#
pressed 押され、コントローラー画面が押されたときに呼び出される関数が登録されます。
Usage:
controller.screen.pressed(callback, arg)
パラメータ |
説明 |
|---|---|
|
コントローラー画面が押されたときに実行されるように事前に定義された 関数。 |
|
Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information. |
# Play a sound when the screen is pressed.
def play_sound():
controller.sound.play_note("C5", 500)
controller.screen.pressed(play_sound)
released#
released コントローラ画面が解放されたときに呼び出される関数を登録します。
Usage:
controller.screen.released(callback, arg)
パラメータ |
説明 |
|---|---|
|
コントローラー画面が解放されたときに実行されるように事前に定義された 関数。 |
|
Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information. |
# Play a sound when the screen is pressed.
def play_sound():
controller.sound.play_note("C5", 500)
controller.screen.released(play_sound)













