@cvp - that’s a tremendous help, many thanks.
For anyone who might want help with ui and scene path drawing when searching in the future, here’s the complete working code (when using the ‘new’ render loop not the classic render loop):
import ui
from scene import *
class MyScene (Scene):
def setup(self):
self.background_color = '#00006b'
self.centre = Point(self.size.w/2, self.size.h/2)
def update(self):
pass
def touch_began(self, touch):
# Calculate vector between centre point and touched point
dx = touch.location.x - self.centre.x
dy = touch.location.y - self.centre.y
# Draw path from centre point to touched point
path = ui.Path()
path.line_width = 4.0
path.move_to(-dx,dy)
path.line_to(-dx,dy)
path.move_to(0,0)
path.line_to(dx,-dy)
# Create line node from path
line = ShapeNode()
line.path = path
line.position = (self.centre.x, self.centre.y)
line.stroke_color = 'white'
self.add_child(line)
# Place dots at centre and touch points
dotA = Dot(location = self.centre)
self.add_child(dotA)
dotB = Dot(location = touch.location)
self.add_child(dotB)
class Dot(ShapeNode):
def __init__(self, *, location, **kwargs):
circle = ui.Path.oval(0,0,20,20)
super().__init__(circle, fill_color='white', **kwargs)
self.position = (location.x, location.y)
run(MyScene())