Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
how do I use ui.transform.rotation and anchor point on my vector shape
-
want to rotate the shape and change the anchor point.
anchor point gives me error.
transform doesn't rotate the shape.
parallelogram.anchor_point(0,0) # Rotate the parallelogram 180 degrees transform = ui.Transform.rotation(180) self.left_wall.transform = transform
I want to rotate the parallelogram 180 degrees. here's the complete code
import ui from scene import * def parallelogram(a, angle_of_a, color, x_pos, y_pos): b = a # Calculate the coordinates of points B and C angle_A_rad = math.radians(angle_of_a) bx = a by = 0 cx = bx + b * math.cos(angle_A_rad) cy = b * math.sin(angle_A_rad) # Create a path to draw the parallelogram path = ui.Path() path.move_to(bx, by) # Point B path.line_to(cx, cy) # Point C path.line_to(cx - a,cy + a) # Point D path.line_to(bx - a, by + a) # Point A path.close() # Create a shape node with the path parallelogram = ShapeNode(path=path) parallelogram.fill_color = color parallelogram.stroke_color = 'black' parallelogram.position = (x_pos, y_pos) parallelogram.anchor_point(0,0) return parallelogram class MyScene(Scene): def setup(self): self.background_color = 'white' self.left_wall = parallelogram(400, 100, 'orange', self.size.w / 2, self.size.h / 2) # Rotate the parallelogram 180 degrees transform = ui.Transform.rotation(180) self.left_wall.transform = transform self.add_child(self.left_wall) if __name__ == '__main__': run(MyScene(), show_fps=False)
-
@resserone13v2-0 error is "anchor_point is not callable..."
parallelogram.anchor_point = (0,0)
Rotation angle is in radians
transform = ui.Transform.rotation(math.pi)
ui.Transform is used with an ui.View, not a Node, use Action
#transform = ui.Transform.rotation(math.pi) #self.left_wall.transform = transform self.left_wall.run_action(Action.rotate_by(math.pi, 1, TIMING_EASE_IN_OUT))