[Lazarus] SVG Object

Mehmet Erol Sanliturk m.e.sanliturk at gmail.com
Tue Jan 18 00:53:31 CET 2022


On Tue, Jan 18, 2022 at 2:37 AM Steve Gatenby via lazarus <
lazarus at lists.lazarus-ide.org> wrote:

> Thanks Marc - seems I will need to stick with what I have then.
>
> Currently I am pulling all object info from the SVG into an array and
> assigning quadrant positions.
>
> Then do best guess by relative quadrant of mouse click position - works
> fine, but feels sloppy :)
>
>

If it is feasible for you , you may do the following :


In an array of a record , define approximate "bounding boxes" of your
SVG graphic ( You may generate  a "bounding box" array conforming to the
given SVG ) .

In  the "bounding box" array record , you may define a pointer showing the
SVG object .
When a mouse click is obtained , you may search  "bounding box" array and
if it is related with an element of the SVG , from it you reach to the SVG
element and
do whatever you want to do with it .


https://en.wikipedia.org/wiki/Minimum_bounding_box
Minimum bounding box

( Please see attached pages . )


This idea may be considered as an alternative view which I can not say that
it is very suitable for you . Only you may decide its usefulness .



Mehmet Erol Sanliturk






>
> On 17/1/22 8:55 pm, Marc Weustink via lazarus wrote:
> > I'm afraid there is no easy solution for that. SVGs are rendered from
> > the first element to the last, where ever element (atleast in theory)
> > can be a part of a given pixel. SVG elements do have a
> > x,y,width,height but they may also be part of one or more
> > transformations.
> > To give you an idea, the (browser)app I'm currently working on
> > displays several object, where every object has an origin(x,y) of 0,0
> > and they are finally placed by translations.
> > The easiest way (if you are in a browser context) is to add an onclick
> > handler to your elements of interest.
> >
> > Marc
> >
> >
> >
> > On 16-1-2022 23:34, Steve Gatenby via lazarus wrote:
> >> Not sure if this is the right place to ask about this one -
> >>
> >> I am using the BCSVGViewer from bgra controls - for SVG viewing
> >> obviously :)
> >>
> >> Would anybody know if there is a method to retrieve the object
> >> (within the svg) at specified x,y ?
> >>
> >> or is it possible to use embedded links within the svg ?
> >>
> >> I am looking to find which object has been clicked on within the svg
> >> to create a 'clickable' map
> >>
> >> Any suggestions on a better place to post this also appreciated
> >>
> >> Regards SteveG
> >>
> --
> _______________________________________________
> lazarus mailing list
> lazarus at lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20220118/073c0804/attachment-0001.htm>


More information about the lazarus mailing list