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.
[share] Circle view/mask view (food for thought)
Phuket2 last edited by Phuket2
In a previous post I asked for help to get a circlular view working. @omz answered it for me. But look I am not a graphics guy, well I am not a really anything guy 😱
But with the simple solution he provided, I can see how it could be extended to do some very nice things. I was thinking of trying to do more with this. But I thought I really should leave it to the experts. I know others here can do a lot better job than me.
My idea is, any number of these mask views could be written using the techniques that @omz shows. Put into custom view classes that have a standard interface , then they could be used like plugins. If the containing class is defined very well, maybe with ABC's then as people write new ones using the base case they could for example be added to a list of view masks in Pythonista Tools.
Just my 2 cents worth. But personally, I think this is how we can leverage people's hard work here.
Ok, the sample code I have listed wants to access your photos. Thought it would give a better example being able to choose your own pics
import ui import photos class ImageMaskCircle(ui.View): def layout(self): self.frame = self.superview.bounds def draw(self): # https://forum.omz-software.com/topic/2902/circle-view-for-ui # @omz solution oval = ui.Path.oval(*self.bounds) rect = ui.Path.rect(*self.bounds) oval.append_path(rect) oval.eo_fill_rule = True oval.add_clip() ui.set_color('white') rect.fill() class TestClass(ui.View): def __init__(self, image_mask = None, *args, **kwargs): ui.View.__init__(self, *args, **kwargs) self.iv = ui.ImageView() self.iv.image = ui.Image.from_data(photos.pick_image(raw_data=True)) self.add_subview(self.iv) self.add_subview(image_mask) def layout(self): self.iv.frame = self.bounds if __name__ == '__main__': f = (0,0, 80, 80) im = ImageMaskCircle() tc = TestClass(im, frame = f) tc.present('sheet')