Forum Archive

Can I use the line() function in a layer?

zlite

Is there any way to use the line() function in a layer? I want to be able draw lines on top of part of the screen, but not have to redraw everything underneath it. But I can't see how to constrain line() to one layer. Any suggestions?

ccc

You could use PIL to draw an image and then create a Pythonista scene.Layer which is right-sized to display that image. The layer will now know how to redraw itself without any special code in your scene.Scene.draw() method. See diagonal_line.py at https://gist.github.com/cclauss/8683457

zlite

Clever! Many thanks for the great suggestion and sample code.