Previous topicNext topic

Scale a rectangle in only one direction

Questions, comments, feedback, etc.
Post Reply
pazeller
Posts: 4
Joined: Wed Nov 16, 2016 4:39 pm

Scale a rectangle in only one direction

Post by pazeller »

Hi!

I am a noobie and I would like to know how I can create a rectangle which scales vertically (Y) but only in one direction. This works, but my rectangle is scaling in both directions (up and down). I would like to achieve the scaling only towards the up direction. Is this possible? how?
Any clue is welcome :)

Vincent
Magic
Site Admin
Posts: 3680
Joined: Wed Apr 09, 2014 9:28 pm

Re: Scale a rectangle in only one direction

Post by Magic »

Yup, it's fairly simple actually. You just have to translate by the same amount you're scaling. Like this:
ScaleAndTranslate.png
ScaleAndTranslate.png (21.61 KiB) Viewed 9587 times
pazeller
Posts: 4
Joined: Wed Nov 16, 2016 4:39 pm

Re: Scale a rectangle in only one direction

Post by pazeller »

Ok. Thats what I was thinking about...

From my small experiment, the rectangle is moving a bit (probably because there are small delays)... is there a better solution to avoid this?

Thank you!

Vincent
Magic
Site Admin
Posts: 3680
Joined: Wed Apr 09, 2014 9:28 pm

Re: Scale a rectangle in only one direction

Post by Magic »

Well, there are many different ways you could do it. You could draw a black rectangle on the bottom half of the image, or you could use the Mask module to mask the bottom half, etc.

Also, in Magic 2.0 there will be a new feature which eliminates the small delays you noticed :).
artnik
Posts: 276
Joined: Tue Jan 05, 2016 5:33 pm

Re: Scale a rectangle in only one direction

Post by artnik »

From experience, the easiest way to achieve this consistently is to translate the rectangle by half its size, such that the edge of it is effectively resting on it's origin point. I.e.translate it first to place an edge in the middle of the screen.

The order of operations is: 1. Translate. 2. Scale based on input. 3. Do other scaling and translating as needed.

Cheers!
Magic
Site Admin
Posts: 3680
Joined: Wed Apr 09, 2014 9:28 pm

Re: Scale a rectangle in only one direction

Post by Magic »

Ah yes, that's probably the best :). Sometimes I forget the obvious things. What would I do without you guys :). I must be getting old.
artnik
Posts: 276
Joined: Tue Jan 05, 2016 5:33 pm

Re: Scale a rectangle in only one direction

Post by artnik »

We're all getting old Eric! ☺
pazeller
Posts: 4
Joined: Wed Nov 16, 2016 4:39 pm

Re: Scale a rectangle in only one direction

Post by pazeller »

Thanks all for the help ;-)
Post Reply