ui.Path.append_path(other_path) , diff line_width values ?
@omz, I guess I can only direct this question to you.
But if I make a ui.Path and then set the paths.line_width to say 2, then I create another path and set its path.line_width to .5 then....append the 2nd path the the first, I am only getting the line_width of the first object being applied to the appended object. Maybe I am doing something wrong. I am hoping that's not the way it should be.
Phuket2 last edited by Phuket2
As @ccc would say.... Show an example 🎉
def make_shape(self): with ui.GState(): r = ui.Rect(*self.bounds).inset(ln_width / 2, ln_width /2) s = ui.Path.oval(*r) s.line_width = 20 with ui.GState(): s2 = ui.Path.rect(*s.bounds) s2.line_width = .5 s.append_path(s2) s.close() s.stroke()
The example is a little screwed up, was trying something. But it's the right idea
a ui.Path can only have one line width! Append only appends the shapes. append lets you have cutouts, depending on the evenoddrule.
for a lower level thing, you might want to look at CGLayer.
That lets you combine a whole set if sequential operations into something you can save, and draw into another drawing context.
@JonB , thanks. I sort of feared that would be the answer. I don't want to go more low level. I struggle at this level. I think in your other post was the same thing that comes to my mind if I really need it. I could have a list of shapes which are just drawn in a loop on top of each other. But just more slow downs and complexity
What, exactly, ate you trying to achieve? Just display a fixed size shape? or have it resizable? What is wrong wi a ui.Image that is rendered once, and stored? should the shapes be editable in some way?
@JonB , trying to create a wrapper class. I know the one off is easy. The example I gave was representative of a problem I had with my wrapper/API. Was trying to draw a simple clock. A thick circle and 2 clock hands. But the point is I wanted to return a ui.path. But ok, I can't with the line_widths intact. But still it's a big limitation when you are making composite images on the fly. I really don't want it rasterised. I just want it as a geometrical shape with its line_widths preserved.
This is why I get frustrated. It really isn't easy to do this nicely.
I will just keep trying.
Why not use a sceneview?
Or, a list of Paths, with corresponding fill_color and line_colors.
Alternatively, you could use a CGLayer which does what you want, i think, just in objc.
@JonB , I know I am frustrating at times 😱😬 believe me, I frustrate myself more....
I really try not touch objc unless I copy some simple code for brightness etc... Seems pointless to me, if I struggle with Python, I can just imagine the mess I would get myself in with objc. It also suits me as its a hobby. I would have a completely different view if I was still working.
Anyway, I think I will look at a list of shapes for the moment. I might be fine. I think I will have to rethink my approach though. It's getting to big, I think. It's becoming the anti helper.
As I say, it's ok. I will just keep plodding away. I am sure one day, it all will become clearer than mud 😬🎉
My approach maybe is stupid. I was just building it up to try to see where the challenges where going to lay as I tried to do more complex things.
If you are interested at all, here is my gist