- Создал(а) Aleksandr Savkin, редактировал(а) Vasily Selivantsev янв. 26, 2023
resources/gui_and_objects/figures.py
This module is designed to display figures on the channel.
Figures display only works for local channels - the script cannot display channels on a remote server.
In order to see the figures, it is necessary to enable "display of figures and subtitles from scripts" in the View Options. More in the Operator's manual: Camera window interface settings
For the display, use the method draw(channel_guid, *figures), where:
channel_guid (str)
: Guid of a channel.*figures
- List of figures to be displayed on the channel.
For most figures, you need to specify coordinates, which are in range [0, 100].
In this case, [0, 0] are the coordinates of the upper left corner and [100, 100] are the coordinates of the lower right corner.
To clear all figures on a channel, use the method host.figure_remove(channel_guid)
List of possible figures with examples:
line(xy_1, xy_2, color="#1FC619", width=2)
xy_1 (List[int, int])
- Coordinates of the line's beginning.xy_2 (List[int, int])
- Coordinates of the line's end.color (str, optional)
: Line color, #1FC619 by default.width (int, optional)
: Line width, 2.0 by default.
import figures channel_guid = "uR76TlcA" # Change to guid of a channel figures.draw( channel_guid, figures.line([0, 0], [100, 100], color="#FF0000", width=30), figures.line([100, 0], [0, 100], color="#FF0000", width=30), figures.line([0, 50], [100, 50], color="#00FF00"), figures.line([50, 0], [50, 100], color="#00FF00"), )
rect(xy_1, xy_2, color="#1FC619")
xy_1 (List[int, int])
- Top left corner coordinates.xy_2 (List[int, int])
- Lower right corner coordinates.color (str, optional)
- Line color, #1FC619 by default.
import figures channel_guid = "uR76TlcA" # Change to guid of your channel figures.draw( channel_guid, figures.rect([16, 16], [76, 76], color="#FFEFB0"), figures.rect([17, 17], [77, 77], color="#E3F7AB"), figures.rect([18, 18], [78, 78], color="#DB97C7"), figures.rect([19, 19], [79, 79], color="#A199D2"), figures.rect([20, 20], [80, 80], color="#FFEFB0"), figures.rect([21, 21], [81, 81], color="#E3F7AB"), figures.rect([22, 22], [82, 82], color="#DB97C7"), figures.rect([23, 23], [83, 83], color="#A199D2"), figures.rect([24, 24], [84, 84], color="#FFEFB0"), figures.rect([25, 25], [85, 85], color="#E3F7AB"), figures.rect([26, 26], [86, 86], color="#DB97C7"), figures.rect([27, 27], [87, 87], color="#A199D2"), )
fillrect(xy_1, xy_2, color="#1FC619")
xy_1 (List[int, int])
- Top left corner coordinatesxy_2 (List[int, int])
- Lower right corner coordinatescolor (str, optional)
- Line color,#1FC619 by default
import figures channel_guid = "uR76TlcA" # Change to guid of your channel figures.draw( channel_guid, figures.fillrect([00, 00], [25, 25], color="#00FF00"), figures.fillrect([50, 00], [75, 25], color="#00FF00"), figures.fillrect([25, 25], [50, 50], color="#00FF00"), figures.fillrect([75, 25], [100, 50], color="#00FF00"), figures.fillrect([0, 50], [25, 75], color="#00FF00"), figures.fillrect([50, 50], [75, 75], color="#00FF00"), figures.fillrect([25, 75], [50, 100], color="#00FF00"), figures.fillrect([75, 75], [100, 100], color="#00FF00"), )
textbox(text, align="TL", fill=True, color="#1FC619")
text (str)
: Textalign (str, optional)
: Text position, TL by defaultTL
- Top LeftTR
- Top RightBL
- Bottom LeftBR
- Bottm Right
- fill (bool, optional): Fills the background with color if True, True by default
color (str, optional)
: Text color, #1FC619 by default
import figures channel_guid = "uR76TlcA" # Change to guid of your channel figures.draw( channel_guid, figures.textbox("Top Left", align="TL", fill=False, color="#00FF00"), figures.textbox("Top Right", align="TR", fill=True, color="#FFFFFF"), figures.textbox("Bottom Left", align="BL", fill=True, color="#FFFFFF"), figures.textbox("Bottom Right", align="BR", fill=False, color="#00FF00"), )
text_ext(xy, text, bg_color="#C5CEC4", font_color="#000000", font_size_px=12)
Text resizing may not work in Trassir version 4.1.1120512 and below
xy (List[int, int])
: Coordinates of the text's beginning.text (str)
: Text.bg_color (str, optional)
: Background color.font_color (str, optional)
: Text color.font_size_px (int, optional)
: Font size.
import figures channel_guid = "uR76TlcA" # Change to guid of your channel figures.draw( channel_guid, figures.text_ext( [10, 10], "The space suit is technically ancient.", bg_color="#FFFFFF", font_color="#000000", ), figures.text_ext( [10, 20], "Planets yell on assimilation at earth!", bg_color="#FFFFFF", font_color="#000000", ), figures.text_ext( [10, 30], "Procedure, mankind, and powerdrain.", bg_color="#FFFFFF", font_color="#000000", ), figures.text_ext( [10, 40], "Rudely, indeed, alignment!", bg_color="#FFFFFF", font_color="#000000" ), figures.text_ext( [10, 50], "I destroy this flight, it's called chemical mystery.", bg_color="#FFFFFF", font_color="#000000", ), )
polyline(*points, color="#1FC619", width=2)
points (List[List[int, int]])
: List of coordinates of the polyline's points.color (str, optional)
: Color line, #1FC619 by default.width (int, optional)
: Line width, 2 by default.
import figures channel_guid = "uR76TlcA" # Change to guid of your channel snake_coordinates = [ [13, 10], [20, 10], [20, 40], [25, 40], [25, 15], [40, 15], [40, 40], [45, 40], [45, 20], [60, 20], [60, 40], [80, 40], [90, 45], [57, 45], [57, 25], [49, 25], [49, 45], [37, 45], [37, 20], [28, 20], [28, 45], [17, 45], [17, 20], [13, 15], [13, 10], ] figures.draw( channel_guid, figures.polyline( *snake_coordinates, color="#00FF00", width=10 ) )
poly(*points, color="#1FC619", width=2, fill=False)
Unlike a broken line, the first and last points of the area automatically connects to each other.
points (List[List[int, int]])
: List of coordinates of the polyline's pointscolor (str, optional)
: Color line,#1FC619 by default
width (int, optional)
: Line width,2 by default
fill (bool, optional)
: Fills inner area with transparent background
import figures channel_guid = "uR76TlcA" # Change to guid of your channel figures.draw( channel_guid, figures.poly( [10, 90], [30, 10], [50, 70], [70, 10], [90, 90], color="#FF0000", width=7, fill=False # True ) )
- Нет меток