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.
Saving painted image as matrix
-
Hi everyone,
I want to make a little program which allows the user to paint in an area on the screen. After hitting a button I want to translate this image into a binary matrix with 1 for each white and 0 for each black pixel. I'm new to iOS programming and am not sure how to go about it.
Right now I'm drawing in a scene with nodes like this:marker = ui.Path().oval(0, 0, 4, 4) marker.fill() marker.close() self.pending_mark_a = ShapeNode(marker, position = self.a, color = "#000000", size = (self.dotSize,self.dotSize)) self.pending_mark_a.z_position = 1 self.add_child(self.pending_mark_a)
Can anyone help?
Cheers
-
@HT, not 100% clear what you are after. A black-and-white Paint app or something more specialized?
In any case, have you noticed the Sketch.py included in the Examples, under User Interface? By default you draw with black on white, and there’s a Save Image option, so sounds like it could be a good reference.
-
Thanks, that is perfect! For some reason I didn't have this example.
Could you explain how I could add this sketchpad to a view that's only the bottom half of the screen?
I would like to display another image in the top half and have the bottom half be paintable. -
You can use designer. See
https://gist.github.com/8f81907e4844d579ef8eda2ed5d65d5e -
That looks perfect. Thanks a lot!