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: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

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

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

Post by teriibi » Sat Feb 24, 2018 4:43 pm

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: 1925
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 » Sat Feb 24, 2018 5:29 pm

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: 2603
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

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

Post by richmond62 » Sat Feb 24, 2018 5:48 pm

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 897 times
skew.png
skew.png (6.12 KiB) Viewed 897 times

bogs
Posts: 1925
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 » Sat Feb 24, 2018 6:02 pm

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 26 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: 2603
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

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

Post by richmond62 » Sat Feb 24, 2018 6:18 pm

By "skew" I mean what in GIMP is called "shear".

bogs
Posts: 1925
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 » Sat Feb 24, 2018 9:33 pm

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: 1695
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

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

Post by [-hh] » Sun Feb 25, 2018 10:08 am

@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
Location: Bolivia

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

Post by teriibi » Thu Mar 01, 2018 6:41 pm

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: 1925
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 » Thu Mar 01, 2018 9:04 pm

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
Location: Bolivia

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

Post by teriibi » Fri Mar 02, 2018 12:28 am

BTW thanks for the Stack !
..thats exactly the type of rotation I was looking for!! :wink:

bogs
Posts: 1925
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 » Fri Mar 02, 2018 4:19 am

Your very welcome :)
Image

Post Reply

Return to “Rich Media”