Page 1 of 1

Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Sat Feb 24, 2018 4:43 pm
by teriibi
Said it all in the Title ! :P

1)
How does one Tilt at a 90deg angle an SVG widget through a script...
In order to display it on a stack from an horizontal position to a vertical position ?
...or there is no way in LC to do that with this widget in particular ? :shock:

2)
Can one resize down or up... by a few pixels or by a % an SVG Widget so that at the end it does display bigger/smaller on the Card ? :roll:
Thanks for any info...

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Sat Feb 24, 2018 5:29 pm
by bogs
You can set any property an object has to anything you want to that is a known quantity.

So, angle that you asked about, possibly the easiest of all -

Code: Select all

on mouseUp
   set the angle of widget "Icon" to the angle of widget "Icon" +90
   // rotates clock wise, use -90 to rotate counter clock wise
end mouseUp
Sizing up (the graphic is merely there to set a boundary), percentages would be done by multiplication, pixels would be by whatever integer you use for the number of pixels using addition -

Code: Select all

on mouseUp
   if the width of widget "Icon" >= the width of graphic "Rectangle" then exit to top
   set the height of widget "Icon" to the height of widget "Icon" *1.5
   set the width of of widget "Icon" to the width of of widget "Icon" *1.5
end mouseUp
Sizing down, percentages would be done by division, pixels would be by whatever integer you use for the number of pixels using subtraction -

Code: Select all

on mouseUp
   set the height of widget "Icon" to the height of widget "Icon" /1.5
   set the width of of widget "Icon" to the width of of widget "Icon" /1.5
end mouseUp

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Sat Feb 24, 2018 5:48 pm
by richmond62
I'm not sure what you mean by "Tilt".

Rotation and altering either vertical or horizontal height is relatively easy.

I would like to know if there is a way to Skew an SVG (or any other image, for that matter) within LiveCode:
LiveCode.png
LiveCode.png (4.8 KiB) Viewed 8368 times
skew.png
skew.png (6.12 KiB) Viewed 8368 times

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Sat Feb 24, 2018 6:02 pm
by bogs
LOL, thank you for posting Richmond, it showed me I had forgotten to attach the stupid demo stack ha ha ha.
rotateAndResize.zip
(1.16 KiB) Downloaded 297 times
I agree, all those things (rotation, height/width) are easy to do. When you say 'skew', are we talking about just changing its proportions? Or do you mean 'skew' in the more literal sense, where the proportions change *and* the bottom is not in alignment with the top?

The first is easy as well, the second might require a bit more thought (but I am pretty sure it could be done).

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Sat Feb 24, 2018 6:18 pm
by richmond62
By "skew" I mean what in GIMP is called "shear".

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Sat Feb 24, 2018 9:33 pm
by bogs
Yah, that is the second one. I haven't looked into it, but as I say I am sure it could be done.

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Sun Feb 25, 2018 10:08 am
by [-hh]
@Richmond

For skewing a widget path you can use my SVG_Text widget (LC 8 only) installable via "[hh]-widgets-un-installer" from "Sample stacks". Now

[tab 2 of the property inspector]
set the svgTextPath to <iconPath>
set the inputPathInstructions to true
[tab 1 of the property inspector]
set the resizeProportional to true
set the pathAngleX to <angle> (= skewX)
set the pathAngleY to <angle> (= skewY)

You can copy and paste the <iconPath> from an svg icon-widget and use the property inspector for the above. Just a few clicks and moving sliders.

For skewing any image you can use my stack "Perspective Image Distortion" from "Sample stacks".
Start with an (imported) image. Then simply skew the control polygon for that, use the RelativePoints there. For example
SkewX (horizontal coords of the edges change equally, vertical coords remain constant)
add 100 to item 1 of line 1 and add 100 to item 1 of line 2, hit enter
SkewY (vertical coords of the edges change equally, horizontal coords remain constant)
add 100 to item 2 of line 2 and add 100 to item 2 of line 3, hit enter

I'll publish soon the demo stack I used for my LCGlobal talk in Nov 2017 about perspective and affine transforms of images and graphics. It can do much more.

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Thu Mar 01, 2018 6:41 pm
by teriibi
Thanks guys - I think thats all I needed is the angle +90 ..way to do it.
Its just a visual animation on screen, not a file modification process I needed.

I really start to like LC very much for the simplicity of its language !
so many stuffs can be done in such an easy way :P

Tks 8)

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Thu Mar 01, 2018 9:04 pm
by bogs
teriibi wrote:
Thu Mar 01, 2018 6:41 pm
so many stuffs can be done in such an easy way :P
That is certainly very true, a great many things that would be much harder in another language are very easy to do in this one. The outside the box stuff is a little more interesting to get done though.

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Fri Mar 02, 2018 12:28 am
by teriibi
BTW thanks for the Stack !
..thats exactly the type of rotation I was looking for!! :wink:

Re: Is there a way to Tilt and resize an SVG Widget by script V / H ?

Posted: Fri Mar 02, 2018 4:19 am
by bogs
Your very welcome :)