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.
Scene Help
-
So, I’m trying to create a yellow circle using the scene module. Does anyone know how I would do that, then move that yellow circle very smoothly left, right, up, or down?
Ps: I don’t really care if it’s the scene module or not. As long as it works, that’s cool.
-
@Bumbo-Cactoni
ShapeNode
-
sorry for short response earlier. was bit busy lol
from scene import * import sound import random import math def Circle(pos, color, p): n = ShapeNode(parent=p) n.fill_color = 'yellow' n.stroke_color = 'black' n.line_width = 5.0 n.position = p.size/2 n.path = ui.Path.oval(0, 0, 100, 100) return n class MyScene (Scene): def setup(self): self.animated = Circle(self.size/2, 'yellow', self) self.animated.run_action( Action.repeat( Action.sequence( Action.move_by(-100, 0, 1), Action.move_by(100, 0, 1), Action.move_by(100, 0, 1), Action.move_by(-100, 0, 1), Action.move_by(0, -100, 1), Action.move_by(0, 100, 1), Action.move_by(0, 100, 1), Action.move_by(0, -100, 1)), -1))
-
@Bumbo-Cactoni, just for fun, the ui version. Although, for more complex animations, again recommend scripter.
import ui class Circle(ui.View): @property def diameter(self): return self.width @diameter.setter def diameter(self, value): self.width = self.height = value self.corner_radius = value/2 if __name__ == '__main__': v = ui.View() c = Circle( diameter=200, border_color='yellow', border_width=2, center=v.bounds.center(), flex='TLRB', ) v.add_subview(c) v.present('fullscreen') def animate(): c.center = (100,100) c.diameter = 100 ui.animate(animate, 3.0)