g2
g2 copied to clipboard
'scl' property of 'img' disappeared
mec.shape.img is handing over a scl property to g2.img command. Examples using this worked some months ago.
This is needed to perform a homogenious scaling. Using b and h properties for scaling does not work, as the real dimensions of the image are not known to the user.
I don't know how they could have worked, since image never had a scl property, if i am not mistaken.
In the old g2 there is no scl for image and at the moment i can't find any functionality which would indicate that behavior exists.
We could put a scl in img which would be multiplied with b and h, but maybe wrapping an image with beg and end is more consistent.
I could implement a scaling property into the inversion for cartesian mode though, which should fit in quite nice.
It might be, that I implemented a sclproperty experimentally, which I forgot to push.
But homogenious scaling is a must have in my opinion. If we use beg .. end for this as a workaround we should consequently also remove the positioning properties, which would makes no sense (performance), as in canvas, svg, etc. images can be directly positioned, rotated and scaled.
Scaling works now ... but the image location seems to be scaled also ...
Changed implementation method.
Width and height of image is now just multiplied with scl property.
Should behave as expected now.
Hmm ... scaling is gone again. Unfortunately running out of time. Please try for yourself. That Mechanism ...
{
"id":"4bar",
"nodes": [
{ "id":"A0","x":100,"y":100, "base":true },
{ "id":"A","x":100,"y":150 },
{ "id":"B","x":350,"y":220 },
{ "id":"B0","x":300,"y":100, "base":true }
],
"constraints": [
{ "id":"a","p1":"A0","p2":"A","len":{ "type":"const" } },
{ "id":"b","p1":"A","p2":"B","len":{ "type":"const" } },
{ "id":"c","p1":"B0","p2":"B","len":{ "type":"const" } }
],
"shapes": [
{ "type":"img","uri":"../img/hand.png","p":"A0","wref":"a","w0":-1.5708,"xoff":140,"yoff":80,"scl":0.1 },
{ "type":"fix","p":"A0" },
{ "type":"img","uri":"../img/hand.png","p":"A","wref":"b","w0":-1.5708,"xoff":140,"yoff":80,"scl":0.1 },
{ "type":"img","uri":"../img/hand.png","p":"B0","wref":"c","w0":-1.5708,"xoff":140,"yoff":80,"scl":0.1 }
]
}
with that image

I see. I should review the scaling again. But frankly i would not use scl here.
{ "type":"img","uri":"./hand.png","p":"A0","wref":"a","w0":-1.5708,"xoff":100,"b":25,"h":50 },
Seems to be good enough, but the corner of the image is hard coded to the point. Maybe we should review that behavior in mec.shape
I think i have identified the problem and scaling should work as intended now. Am a bit hesitant to close the issue till further testing though.