Hey everyone,
I have a ui.path in a shapeNode, which is growing somehow every second. Unfortunately, the path is jumping from state to state. I know why it is jumping and I also know for what this behavior is good for, but I‘d like to fix the path in center where it is meant to be. I guess playing around with the anchor_point would fix the problem only in some cases. Of course I could calculate around with the nodes bbox and the path bounds, but I cannot imagine that there is no better solution. I also thought about defining the size of path with a rect() before generating the actual path, but the resulting rectangle would be visible, of course. I hope you know what I’m talking about. Following a snippet which hopefully describes better what my long questions is about.
from scene import *
from time import time
class MyScene (Scene):
def setup(self):
self.points = (Point(-100, -100),Point(100, -100),Point(100, 100),Point(-200, 100))
self.startTime = time()
self.prev_dt = -1
ground = Node(parent=self)
ground.position = (self.size.w/2, self.size.h/2)
self.node = ShapeNode(ui.Path.oval(0,0,10,10), fill_color='clear', stroke_color='red')
self.node2 = ShapeNode(ui.Path.oval(0,0,20,20), fill_color='clear', stroke_color='yellow')
ground.add_child(self.node)
ground.add_child(self.node2)
def update(self):
dt = int((time()-self.startTime)%4)
if dt != self.prev_dt:
self.prev_dt = dt
path = ui.Path.oval(0,0,10,10)
path.move_to(self.points[0].x, self.points[0].y)
path.line_to(self.points[1].x, self.points[1].y)
for i in range(dt): path.line_to(self.points[(i+2)%4].x,self.points[(i+2)%4].y)
self.node.path = path
if __name__ == '__main__':
run(MyScene(), show_fps=False)
Thx alot forfor every hint :)
rownn