Animated Vector Graphics Scene Graph

Share your advanced PureBasic knowledge/code with the community.
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Animated Vector Graphics Scene Graph

Post by idle »

AvgSceneGraph

Create Animated Vector graphic Scenes
It's not tied to any gadget so it can be technically used for any vector surface

you can have multiple scenes on a surface, like tab pages or views
zoom and pan a scene (right click move mouse and wheel)
pick and move objects (left down move mouse)
pick and scale object (not shown)
set objects visible / not visible (not shown)

Modify, Add or remove elements from objects dynamically at runtime via callbacks
objects are a runtime display lists of drawing instructions so all the parameters are modifiable at runtime

Assign animations on events (not shown)

You will be able to use it to design elements of a UI and edit it live

Things to come
parametric primitives so they can be shape morphed like circle to star, circle to heart

Save and restore to json and export the code and maybe if I get tricky export as binary to a data section and execute it from memory.

I'm still working out the structure and event propagation which isn't sorted yet so this is very much a WIP

https://atomicwebserver.com/AVGSceneGraph.pbi


Image

https://atomicwebserver.com/avgscenegraph.mp4
User avatar
minimy
Enthusiast
Enthusiast
Posts: 665
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Animated Vector Graphics Scene Graph

Post by minimy »

Hey idle, you have good coffe too! :lol:
As allways an amazing code.
Tested in PB6.3b3 and work perfect.
Thank you very much idle for share this great addition.
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Animated Vector Graphics Scene Graph

Post by idle »

minimy wrote: Thu Oct 16, 2025 12:17 pm Hey idle, you have good coffe too! :lol:
As allways an amazing code.
Tested in PB6.3b3 and work perfect.
Thank you very much idle for share this great addition.
Thanks but there are still bugs the outline square with red circle doesn't move together properly. I think I know how to fix it.

Edit:Edit Almost Fixed :evil:
User avatar
mk-soft
Always Here
Always Here
Posts: 6292
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Animated Vector Graphics Scene Graph

Post by mk-soft »

Not run :(
---------------------------
PureBasic
---------------------------
Line 862: Structure not found: Displaylist.
---------------------------
OK
---------------------------
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 6292
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Animated Vector Graphics Scene Graph

Post by mk-soft »

Ok,

need PB v6.30

or change line 862 to run on v6.21

Code: Select all

;Prototype pDiplayListgCB(*avg.Displaylist,mousex.d,mousey.d) 
Prototype pDiplayListgCB(*avg,mousex.d,mousey.d) 
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Animated Vector Graphics Scene Graph

Post by idle »

mk-soft wrote: Thu Oct 16, 2025 9:16 pm Ok,

need PB v6.30
Thanks for info fixed Prototype pDiplayListgCB(*avg,mousex.d,mousey.d)
and it will work with 6.03+
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Animated Vector Graphics Scene Graph

Post by idle »

idle wrote: Thu Oct 16, 2025 9:22 pm
mk-soft wrote: Thu Oct 16, 2025 9:16 pm Ok,

need PB v6.30
Thanks for info fixed Prototype pDiplayListgCB(*avg,mousex.d,mousey.d)
and it will work with 6.03+
I still got to fix the move position for moving child objects.
Edit: Think its done now!

another bug is that it draws an object at the wrong position on reverse animation. you can see it flash for one frame.
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Animated Vector Graphics Scene Graph

Post by idle »

Fixed the flash on reverse animation.

Added button using paths, linear gradients, border, with swap gradient color and border color on hover and scales on click

*note the animation updates are still being worked on but this gives you an idea of where it's going.
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Animated Vector Graphics Scene Graph

Post by idle »

added a switch button
still need to work on the child offsets it makes it a bit tricky to position with -offsets.
Mesa
Enthusiast
Enthusiast
Posts: 444
Joined: Fri Feb 24, 2012 10:19 am

Re: Animated Vector Graphics Scene Graph

Post by Mesa »

For information, i tested it on pb6.03 x86 and everything works except, it crashes when the mouse cursor hover the orange box with this message error: line 2464: array index out of limit.

Code: Select all

If *scene\mouseButton  And *obj\params[index]\isHovered 
M.
Mesa
Enthusiast
Enthusiast
Posts: 444
Joined: Fri Feb 24, 2012 10:19 am

Re: Animated Vector Graphics Scene Graph

Post by Mesa »

If i replace line 994: 'params.AVGObjectParams[10] ;temporary fix' by 'params.AVGObjectParams[100] ;temporary fix'
The error is replaced by an ima line 2459 'If (*obj\events\onMouseMove And isSelected = *obj\id)'
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Animated Vector Graphics Scene Graph

Post by idle »

Thanks I will look at in morning, its probably not unsurprising that it crashed, I'm only testing it with 6.30 and x64. The parameters index is currently static 10 items per object. When you add a path to an object it increments the index so if that exceeds 10 it will crash. Im also short cutting the dereference which might be a problem 6.03 x86v. It will be changed to a dynamic array and structure will be adapted to a union to reduce size and rhen you will also have a set of scene parameters, object param to override and item param to override so it behaves like CSS.
acreis
Enthusiast
Enthusiast
Posts: 225
Joined: Fri Jun 01, 2012 12:20 am

Re: Animated Vector Graphics Scene Graph

Post by acreis »

Beautifulllll
User avatar
mk-soft
Always Here
Always Here
Posts: 6292
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Animated Vector Graphics Scene Graph

Post by mk-soft »

macOS:

No circles are displayed in macOS !?
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
idle
Always Here
Always Here
Posts: 5998
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Animated Vector Graphics Scene Graph

Post by idle »

Mesa wrote: Fri Oct 17, 2025 11:18 am If i replace line 994: 'params.AVGObjectParams[10] ;temporary fix' by 'params.AVGObjectParams[100] ;temporary fix'
The error is replaced by an ima line 2459 'If (*obj\events\onMouseMove And isSelected = *obj\id)'
fixed: was the function definition missing the button parameter from the prototype
Post Reply