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

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
teriibi
Posts: 254
Joined: Mon Nov 13, 2017 3:49 pm

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

Post 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...
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post 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
Image
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

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

Post 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 14015 times
skew.png
skew.png (6.12 KiB) Viewed 14015 times
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post 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 685 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).
Image
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 »

By "skew" I mean what in GIMP is called "shear".
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post 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.
Image
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

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

Post 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.
shiftLock happens
teriibi
Posts: 254
Joined: Mon Nov 13, 2017 3:49 pm

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

Post 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)
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post 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.
Image
teriibi
Posts: 254
Joined: Mon Nov 13, 2017 3:49 pm

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

Post by teriibi »

BTW thanks for the Stack !
..thats exactly the type of rotation I was looking for!! :wink:
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs »

Your very welcome :)
Image
Post Reply