It would seem that trying to embed structs and scalars for graphical elements in GOP subpatches is glitching out something nasty. Draw commands work well until the GOP property is turned on, and then the canvas size gets huge and scrolling gets lost on something like an infinite scrollbar treadmill. Ive been super eager to start designing UI elements with scalars,, but the inability to nest structs and scalars in GOP subpatches is posing some real limitations/frustrations... is anyone else experiencing this? Am I doing something wrong, or is this a bug?
Drawing scalars freaks out when GOP is turned on
GOP is a really complicated interface-- iemguis display at normal size while garrays and scalars appear translated and scaled according to the margins and x/y ranges you specify.
This would make sense if the GOP rectangle actually worked as a clipping rectangle. Then you could do things like designing a scalar widget "sprite sheet" and just change the margins and x/y range to display different areas of the subcanvas. But GOP windows don't clip, so you can't easily do that.
Also, when you have the subcanvas window open the scalars and garrays on it are scaled according to the dimensions of the window, which you'd have to scale manually using the "x/y per pixel" settings to get it to look "normal."
hmm... interesting. So you are saying that if I adjust the xy range in the graph properties of the gop subpatch, then I can finagle it until it looks normal? Right now, the range is just the default... -1, 1 i believe. How would I calculate the right numbers to set if I had a gop patch that was sized on parrent at - oh say... 200x100px?
@th8a set the range to 200 and 100.
you can try 400 and 200 to see the scalars shrink to a quarter.
also you can explicitly set the x and y values of the data structure to position the scalars inside the subpatch.
as @jancsika said, if you have scalars outside the range of the subpatch they will still be rendered, not clipped, thus showing through.
if you provide a patch, it is easier to make things clear.
@ingox Ahhh I see. Yes, it's working now. I guess you really do just tweak it til it looks right. Thats super cool now that I can finally rely less on pixel based graphics. I am still a little unclear on how the scaling works... why with any other object does leaving the gop range setting alone look just as expected, while struct based graphics scale on a totally different system? I guess the more I use it and get to know it, the understanding will follow... now that I got past this little obstacle, i have questions! Like are there any future plans for gradient fills in draw? can you import svg graphics from other programs? (i think I saw something like that in the help patches...) I dig the direction that this is going. In no time at all, purr-data can rival MAX for rich GUIs, only with better performance and more customizable! Very good work, fellahs.
@th8a The range settings are especially for rendering data structures, that's why they can be ignored for other stuff.
They work exactly like the range settings for graphical arrays, that is because garrays are actually based on data structures.
It is actually pretty straightforward. If you have a gop window with 100px width:
- With x range 0 to 100, a scalar placed at 50 will be displayed in the middle
- With x range 0 to 1, a scalar placed at 0.5 will be displayed in the middle
- With x range -10 to 10, a scalar placed at 0 will be displayed in the middle and a scalar placed at -10 will be displayed at the left corner
(The actual position also depends on the drawing instructions).
With x/y ranges both 0 to 1, a 1x1 pixel polygon will be stretched to the gop window regardless of gop size.
goootttcha. Thanks for the run down. It was a bit confusing and counterintuitive at first, but now that I understand that, it's working out. Thanks for the help!
i believe gradient fills are not possible.
Not possible as in not possible right now, or not possible as in not possible forever?
Like are there any future plans for gradient fills in draw?
It's not possible in Pd because the GUI toolkit it uses-- tk-- doesn't have gradient fills.
It's possible to have gradient fills in Purr Data but I don't have any interface for creating or referencing them atm.
Yea, I know tk is a tad dated for eye candy like that, i was specifically asking about purr data. That's good to know it can be done at some point anyway! So I have hit another little roadblock in my patching adventures here... I am wondering if there is a way to make multiple instances of a gop subpatch in which the structs within those patches function independently of one another. I tried naming structs with $0 prefixes as you would in other parts of pd, but it would not create the scalar when $0 was in the name. As it stands, I made a sweet flashy bng button that lights up all nice and is scalable on it's parent, and every instance I load up will light up every time one is clicked. Does $0 naming not work in structs? is there some other way to accomplish this?
ooh, just had the idea to dynamically create a struct by sending a message to pd with a loadbang... that way the object loads with the instance number instead of the '$0' as a literal... could that work well? is there a better/easier way?
[struct $0-mystruct float x] works `````
That's really strange. I tried something similar and i couldn't get it to create the object. Just gave me a red box and a message in the console, 'could not create object.'
for using [append], I am afraid I dont quite follow how you mean. could you give me an example of how to set something like that up?
i am pretty new to this aspect of pd. I have some understanding as to what structs and pointers are, but i guess i'm still grasping how that all plays out in msp. Pointers have always glitched my brain a little bit to begin with... lol
I am managing to get all the scaling and stuff working well, though I must say, it gets a bit confusing the way the scalar will look huge inside the patch once GOP is set on, but close the sub patch and it's sized normal on it's parent. Is that functionality intentional or is it some reaction to the oldschool tk/tcl making sense of the updated gui? On one hand, It's hard to tell if I am witnessing glitces in the way some things are reacting, or, . on the other if I just dont yet know wth i'm doing in svg land. If they are glitches, I'd have to study a bit more before I can give any useful reports on it... Just finding control of certain things a bit disorienting.
Thanks for the help/response/info. Im still truckin along over here
@th8a You can look at this thread to find some examples: https://forum.pdpatchrepo.info/topic/10858/data-structures-append-and-get-what-am-i-getting-wrong/7
Without your patch it is quite difficult to tell what is going wrong.
About the scaling: After creating the subpatch you usually don't need to open it ever again, so i would say you just don't have to worry about anything if it looks like you want it to on the parent...
that seems like sound advice. Here is where the patch is currently at. I want it to simply be a nicer looking bng button which is scalable and reusable as an abstraction. for now it's just an exercise to learn this aspect of purr-data. Eventually, I have a bunch of UI object abstractions I plan to give to the community once they are awesome. feel free to look around on it. If you do, let me know if your seeing the thing where the scalar is huge inside the subpatch window but normal on the parent. j-svbng-blu.pd
Well, I tried my idea of dynamically making structs per instance by setting a loadbang to send the canvas a message to create a struct and scalar with the $0 number of that instance prepended. It works, but not without causing a full on crash.... back to the drawing board I suppose...
UPDATE: ok, I had to set a delay between the message which creates the struct object and the message that creates the scalar. Looks like my old nemesis, the bug that attempts to update elements before they are created is once again the culprit. With a little delay time it is stable and each abstraction functions independently. I can copy and paste multiple instances, but if I call the object from a text box, it will still crash. go figure... my best guess is something to do with pointers getting mixed up j-svbng-blu.pd
SyntaxError: missing ) after argument list at perfect_parser (/home/th8a/apps/purr-data/lib/pd-l2ork/bin/pdgui.js:1662:48) at Socket.<anonymous> (/home/th8a/apps/purr-data/lib/pd-l2ork/bin/pdgui.js:1680:9) at emitOne (events.js:96:13) at Socket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:178:18) at Socket.Readable.push (_stream_readable.js:136:10) at TCP.onread (net.js:560:20) Segmentation fault (core dumped) [5872:5872:0908/181830.239431:ERROR:extension_function_dispatcher.cc(601)] Permission denied for nw.App.quit
@th8a Very interesting. i opened your patch with Pd-L2ork and first thing i must say the graphics look very beautiful in Purr Data!
i still don't understand how you got the scalars into the patch without any [append] object?
Is it not possible to use [draw] onto a subpatch? It would solve the graphics all over the place issue to just put the scalars into a subpatch with gop on.
i put some comments to my button example from above that hopefully give a somewhat comprehensive overview of the basic concepts of data structures in pd and how to use [append] to add scalars:
i also added an example on how you can safely use dynamic patching with data structures without any crashes and without any delays.