GUI Commands¶
GUI commands allow using self('command content') within the construct() method to open interactive feature panels in the GUI.
More importantly, after submission, the panel’s interaction results can be applied to the source code.
The basic usage of GUI commands is:
self('command_name: command_parameters')
Important
Commands must use complete string literals. Variables or expressions cannot be used to pass command names and parameters.
It is precisely because of this restriction that JAnim can correctly modify the source code based on GUI operations.
Note
Documentation is incomplete. The content here is currently quite brief
select Command¶
Select subitems of the specified item
Try:
typ = TypstText('#lorem(4)', scale=3).show()
self('select: typ').set(color=RED)
self('select: typ').set(color=GREEN)
self('select: typ').set(color=BLUE)
txt = Text('This is the first line.\nThis is the second line.').show()
self('select: txt[0]').set(color=RED)
self('select: txt[1]').set(color=GREEN)
camera Command¶
Freely rotate/move/zoom the camera view
Try:
ThreeDAxes(
axis_config={
'include_tip': True
}
).show()
circle = Circle().show()
circle.points.rotate(40 * DEGREES, axis=UP)
self('camera')
NumberPlane(faded_line_ratio=1).show()
square1 = Square(color=RED, fill_alpha=1)
square2 = Square(color=GREEN, fill_alpha=1)
square3 = Square(color=BLUE, fill_alpha=1)
square2.points.rotate(PI / 2, axis=UP)
square3.points.rotate(PI / 2, axis=RIGHT)
squares = Group(square1, square2, square3)
squares.show().apply_depth_test()
self('camera')
move Command¶
Move items, supports auto-snapping
Try:
circle = Circle().show()
square = Square().show()
rect = Rect(6, 0.5).show()
self('move: circle, square, rect')