skywalk wrote: Sun Oct 19, 2025 11:31 pm
Yes!
MIT license is preferred.
I got lost in legalese with eclipse 2.
I like the fast array approach as I sometimes place 20k objects on a layer. I redraw my scenes with a hardcoded algo and it is still fast enough for user. This is not a game though. More like a custom graphical report.
As is, the pan feature is cool. Maybe the motion objects are messing with the origin?
I've fixed up the select move and clicks I can post it now but it's in-between modification and will take me a day or two to change.
The problem with an array is that you can't easily modify it at runtime. Currently the display list is a "list" of drawing commands so you are free to insert or delete elements at will by id but that means you need to foreach on the list to find the items you want to insert modify or delete and then the properties array would be a mess.
so to provide O(1) lookups, insert, delete modify it wants a map think of web browsers they use map of a map or list to access elements I can do this in one structure and still preserve the speed of a list. The cost of the O(1) look up will be 8 memory access vs the list with 1 memory access times the depth of the list to the item. So It's not expensive in the scheme of things.
Currently zorder is preserved by iterating a list of object IDs that are looked up in the map of objects. so you get an object which has a display list of drawing commands() as you add Paths it increments the array of parameters for the object so you can get back the ID of the element to access its properties. I'm changing those properties so that the item holds the properties to reduce the overhead of the properties array which is currently 432 bytes per item.
so here I added activeColor and hoverColor to the spVectorSourceColor structure and removed them from params
Code: Select all
Procedure AVGVectorSourceColor(*scene.AVGScene, objectID, color,hoverColor=0, id=0, *userdata=0)
If FindMapElement(*scene\objects(), Str(objectID))
Protected *obj.AVGObject = *scene\objects()
AddElement(*obj\avg\dl())
*obj\avg\dl()\ptVectorSourceColor = AllocateStructure(spVectorSourceColor)
*obj\avg\dl()\ptVectorSourceColor\Color = color
*obj\avg\dl()\ptVectorSourceColor\ActiveColor = color
;*obj\params[*scene\nextitem]\color = color
If hoverColor
*obj\avg\dl()\ptVectorSourceColor\hoverColor = hoverColor
;*obj\params[*scene\nextitem]\hovercolor = hoverColor
Else
*obj\avg\dl()\ptVectorSourceColor\hoverColor = Color
;*obj\params[*scene\nextitem]\hovercolor = color
EndIf
*obj\avg\dl()\func = @RtVectorSourceColor()
*obj\avg\dl()\ptVectorSourceColor\params\id = *scene\nextitem
*obj\avg\dl()\ptVectorSourceColor\params\userdata = *userdata
*obj\avg\dl()\ptVectorSourceColor\params\type = #spVectorSourceColor
*obj\ptrDisplayListItem[*scene\nextitem] = *obj\avg\dl()
EndIf
EndProcedure
so when you hover it swaps the color as it walks the display list and doesn't need to look up the properties index but I still need to look up the map of objects
when you want to change the colors outside of a callback
Code: Select all
Procedure AVGSetObjectColors(*scene.AVGScene, object.s, color.l=0,hoverColor.l=0,index=0)
If FindMapElement(*scene\objects(),Str(*scene\ObjectByName(object)))
*obj.AVGObject = *scene\objects()
If index < 20
Protected *dl.DisplaylistPtr = *obj\ptrDisplayListItem[index]
If *dl\item\type = #spVectorSourceColor
Protected *ptr.spVectorSourceColor = *dl\item
If *ptr\Color <> color
*ptr\Color = color
EndIf
If *ptr\hoverColor <> hoverColor
*ptr\hoverColor = hoverColor
EndIf
EndIf
EndIf
EndIf
EndProcedure
So it has to look up the item from the map by name to get the display list then set *dl pointer from the properties
This is a slight improvement but it still has the overhead of the array albeit reduced in size though if you wanted to remove or add elements the index is borked. so I would need a properties list or a properties map which is out of the question as the overhead of a map is 64 elements x 32 bytes 2048 bytes so that leaves a list but to cut to the chase, if I use squint, I get the benefit of a map to a map at only the cost of 8 memory access vs 1 times the depth of a list of properties. so as soon as you have more than 8 items in an object your wining and with squint there is no overhead it's just a pointer
So that's why I'm going all foo, the cost of the price of convivence to users to do what ever they want and it'll be way easier to adapt as it becomes an in memory db on pointers so I can do the lot with one structure.
The only shenanigans I need to do is set an index keys as key.s = "Circle:"+ RSet(Hex(index),4,"0")
and then the order is preserved in the trie.