Board index FlightGear Development Canvas

Problems with svg and setScale

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Problems with svg and setScale

Postby www2 » Tue Aug 23, 2016 10:35 pm

Hi i have problems with setScale on a svg object.
Image
What you see on the image is that setScale([1,1]) is correct where setScale([1,0.5]) and setScale([1,2]) get also a Translation on the same axes.
My expectation is that the setScale scales from the center not this behaver.
Any one know what i do wrong or is a bug in the code for setScale?
www2
 
Posts: 261
Joined: Thu Apr 16, 2009 1:58 pm

Re: Problems with svg and setScale

Postby Thorsten » Wed Aug 24, 2016 4:49 am

It depends where your coordinate zero is - setScale multiplies all coordinates with a given value, and that in general implies a translation which is only absent if whatever point you want to hold fixed happens to be at the coordinate origin.

P.S.: You really ought to re-think your color scheme...
Thorsten
 
Posts: 11327
Joined: Mon Nov 02, 2009 8:33 am

Re: Problems with svg and setScale

Postby www2 » Wed Aug 24, 2016 7:48 am

Thx Thorsten
That is my expectation.
It looks like simgear/flightgear ignore the object center point instate use 0,0 as the center point.
For the color scheme i say three words: pre alpha code. ;)
www2
 
Posts: 261
Joined: Thu Apr 16, 2009 1:58 pm

Re: Problems with svg and setScale

Postby Thorsten » Wed Aug 24, 2016 10:01 am

If you sit down for a second and think it through, canvas can't know what you mean by center point.

For instance, I usually want to position arrows and pointer triangles by their tip, but a Shuttle symbol by its center of gravity and a predictor circle by its geometrical center. Unless of course I have a predictor triangle, that I want to position by geometrical center point....

So it's up to you to tell canvas what the reference point for a symbol ought to be, it can't know what the symbol means.
Thorsten
 
Posts: 11327
Joined: Mon Nov 02, 2009 8:33 am

Re: Problems with svg and setScale

Postby www2 » Wed Aug 24, 2016 10:19 am

I mean the geometrical center point of the object.
e.g.: For a object of x = 3 and y = 2 the center point is x = 1.5 and y = 1. plus the offset of the position on the canvas.
in state of the 0,0 in canvas space.
Note: the image that i post is a nested canvas.
the 0.0 that i speak is about the Altimeter and Vertical speed indicator than the main canvas window (the green background).
www2
 
Posts: 261
Joined: Thu Apr 16, 2009 1:58 pm

Re: Problems with svg and setScale

Postby Thorsten » Wed Aug 24, 2016 10:42 am

I mean the geometrical center point of the object.


Say you have an irregularly shaped object like an airplane symbol - how do you define it? Or even for a triangle - where is the center point?
Thorsten
 
Posts: 11327
Joined: Mon Nov 02, 2009 8:33 am

Re: Problems with svg and setScale

Postby www2 » Wed Aug 24, 2016 10:46 am

the object is a rectangle and the center point is the default that was create by inkscape.
www2
 
Posts: 261
Joined: Thu Apr 16, 2009 1:58 pm

Re: Problems with svg and setScale

Postby Johan G » Sun Dec 04, 2016 9:49 am

If I understand Thorsten correctly you would have to move your symbols path so that the path's center point snaps to and coincides with the origo of the coordinate system in Inkscape.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5546
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest