# Latest Thunkable for Android releases (Pinch to scale on Canvas)

**URL:** <https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636>\
**Category:** Announcements\
**Tags:** canvas, gesture\
**Created:** [August 18, 2017, 9:04pm UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636 "2017-08-18T21:04:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![albert](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/albert/32/4077_2.png) [@albert](https://community.thunkable.com/u/albert)\
**Post date:** [August 18, 2017, 9:04pm UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/1 "2017-08-18T21:04:30Z")

</div>

Hey Thunkers,

Hope you are having a happy Friday. To get you started for the weekend, we have added the ability to [scale up or down objects on a Canvas by pinching](https://docs.thunkable.com/android/components/gaming/canvas.html#pinch-scale), one of the most intuitive gestures on a smartphone. We think this should enable even more interesting and powerful gaming and drawing apps.

[https://docs.thunkable.com/assets/pinch-to-scale-fig-1.png](https://docs.thunkable.com/assets/pinch-to-scale-fig-1.png)

Release notes are below and make sure to download the latest [Thunkable companion app](https://play.google.com/store/apps/details?id=com.thunkable.appinventor.aicompanion3&hl=en)  
[Thunkable Release Notes](https://docs.google.com/document/d/1ieT5-fX_FUngqWdhA2WisfUhqJ5PhSdt69uyc7BKd68/edit)

Next up for us on Android are Push Notifications and a native Floating Action Button -

Happy Thunking!  
Albert on behalf of the team

---

<div class="post-metadata">

**Author:** ![Carlos\_Pedroza](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/carlos_pedroza/32/7421_2.png) [@Carlos\_Pedroza](https://community.thunkable.com/u/Carlos_Pedroza)\
**Post date:** [August 19, 2017, 12:35am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/2 "2017-08-19T00:35:47Z")

</div>

Great work! Thank you very much!

---

<div class="post-metadata">

**Author:** ![Lml\_DLGdo](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/lml_dlgdo/32/6470_2.png) [@Lml\_DLGdo](https://community.thunkable.com/u/Lml_DLGdo)\
**Post date:** [August 19, 2017, 3:49am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/3 "2017-08-19T03:49:45Z")

</div>

> [@albert](#):
>
> Next up for us on Android are Push Notifications

👍

---

<div class="post-metadata">

**Author:** ![Abdul\_Maajith](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/abdul_maajith/32/3455_2.png) [@Abdul\_Maajith](https://community.thunkable.com/u/Abdul_Maajith)\
**Post date:** [August 19, 2017, 6:42am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/4 "2017-08-19T06:42:23Z")

</div>

great work @albert

---

<div class="post-metadata">

**Author:** ![ILoveThunkable](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ilovethunkable/32/3134_2.png) [@ILoveThunkable](https://community.thunkable.com/u/ILoveThunkable)\
**Post date:** [August 19, 2017, 6:47am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/5 "2017-08-19T06:47:48Z")

</div>

I am sure, this is added by @tingccc

---

<div class="post-metadata">

**Author:** ![Italo](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@Italo](https://community.thunkable.com/u/Italo)\
**Post date:** [August 19, 2017, 6:52pm UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/6 "2017-08-19T18:52:16Z")

</div>

Is this based on Hal Abelson’s ScaleDetector extension?

---

<div class="post-metadata">

**Author:** ![ILoveThunkable](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ilovethunkable/32/3134_2.png) [@ILoveThunkable](https://community.thunkable.com/u/ILoveThunkable)\
**Post date:** [August 20, 2017, 8:05am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/7 "2017-08-20T08:05:14Z")

</div>

I think so.

---

<div class="post-metadata">

**Author:** ![mannankhanabdul](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mannankhanabdul/32/532_2.png) [@mannankhanabdul](https://community.thunkable.com/u/mannankhanabdul)\
**Post date:** [August 20, 2017, 10:10am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/8 "2017-08-20T10:10:14Z")

</div>

Yes correct.

---

<div class="post-metadata">

**Author:** ![notkristina](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/notkristina/32/7918_2.png) [@notkristina](https://community.thunkable.com/u/notkristina)\
**Post date:** [September 18, 2017, 4:49pm UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/9 "2017-09-18T16:49:01Z")

</div>

When using scale\_factor to adjust the width and height of a non-square sprite, I’m finding that the sprite’s aspect ratio is getting slightly distorted each time it’s scaled down smaller than a certain size, until the smaller dimension approaches zero and the sprite disappears. I’m assuming this is a quirk of the whole-number nature of both pixel dimensions, meaning that when each dimension is multiplied by the five-decimal-place scale factor and then rounded to a whole pixel, the two dimensions gradually become out of sync with one another.

It might be helpful if we could set a locked aspect ratio for a sprite. But in the meantime, I have found that I can more or less work around this by allowing a sprite to scale down _only if_ both dimensions are greater than a minimum pixel count (and again, I haven’t worked out the ideal minimum, but 100+ seems to be working for me right now).

Posting here because I would’ve been happy to find this info an hour ago. 🤣 Please advise if this is not an appropriate use of this forum topic—I’m new to Thunkable.

---

<div class="post-metadata">

**Author:** ![Italo](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@Italo](https://community.thunkable.com/u/Italo)\
**Post date:** [September 18, 2017, 5:53pm UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/10 "2017-09-18T17:53:58Z")

</div>

When resizing proportionally, you can use this formula:

Only use the pinch to resize the width and calculate the height like this

sprite.height = ( original height / original width ) x new width

---

<div class="post-metadata">

**Author:** ![notkristina](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/notkristina/32/7918_2.png) [@notkristina](https://community.thunkable.com/u/notkristina)\
**Post date:** [September 22, 2017, 2:19am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/11 "2017-09-22T02:19:59Z")

</div>

Indeed I did, but the issue persists.

ETA: I’m finding that even when I do set a bottom limit for the dimensions, the sprite will still distort if I pinch it big-medium-big-medium, so this is not at all a foolproof workaround. It does seem to slow the distortion process down a bit, though.

---

<div class="post-metadata">

**Author:** ![Italo](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@Italo](https://community.thunkable.com/u/Italo)\
**Post date:** [September 22, 2017, 3:43am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/12 "2017-09-22T03:43:02Z")

</div>

You are doing something wrong, because using that formula I have perfect proportional resizing. Can you post the blocks where you resize your sprite?

---

<div class="post-metadata">

**Author:** ![notkristina](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/notkristina/32/7918_2.png) [@notkristina](https://community.thunkable.com/u/notkristina)\
**Post date:** [September 22, 2017, 4:00am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/13 "2017-09-22T04:00:28Z")

</div>

![](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/2X/d/d004c9adc8481c2c0ff486f584180f2d107330dc.png)

This is the separate app where I have been searching for a workaround (so as to rule out any other part of my app interfering). It only does this, and over the course of many resizings, the image gradually and consistently distorts. The nearer it is to square, the more times it takes.

---

<div class="post-metadata">

**Author:** ![Italo](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@Italo](https://community.thunkable.com/u/Italo)\
**Post date:** [September 22, 2017, 7:29am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/14 "2017-09-22T07:29:02Z")

</div>

@notkristina: You need to calculate the aspect ratio for the sprite in the beginning of your app, to make sure that value is not changed later in the app, like you are doing inside your Canvas.Scaled event.  
Did you notice the red circle with a cross in your global oldWidth definition? That’s an error. It means you can’t assign that value in a definition. So that variable is empty at start.  
Also I added the blocks you need to keep the sprite between 100 and 300 pixels wide, you change it to whatever you need there.

 ![](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/2X/4/49d255e760b6587eda658fa8f3fe6e49e5561988.PNG)

---

<div class="post-metadata">

**Author:** ![notkristina](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/notkristina/32/7918_2.png) [@notkristina](https://community.thunkable.com/u/notkristina)\
**Post date:** [September 22, 2017, 11:23am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/15 "2017-09-22T11:23:28Z")

</div>

I am such a fool. I misread your equation the first time and went on thinking I knew what I was doing. Of course this will work. Thank you so much for your time and patience. Your solution will help lots of people, but first, me! 😆

I did not notice that red X, thank you for bringing it up. It didn’t especially matter what that variable was initialized to in this instance, but I wonder why that’s not an acceptable value.

---

<div class="post-metadata">

**Author:** ![Puneet\_Thakur](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@Puneet\_Thakur](https://community.thunkable.com/u/Puneet_Thakur)\
**Post date:** [January 22, 2018, 6:08am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/17 "2018-01-22T06:08:39Z")

</div>

@Italo  
i used these blocks but whenever i pinch to zoom the sprite becomes invisible

---

<div class="post-metadata">

**Author:** ![Italo](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@Italo](https://community.thunkable.com/u/Italo)\
**Post date:** [January 22, 2018, 12:50pm UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/18 "2018-01-22T12:50:54Z")

</div>

Show your blocks.

---

<div class="post-metadata">

**Author:** ![Chris](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/chris/32/78883_2.png) [@Chris](https://community.thunkable.com/u/Chris)\
**Post date:** [January 23, 2018, 5:29am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/19 "2018-01-23T05:29:02Z")

</div>

This is NOT a support or discussion topic… Please create a new topic in the right category(e.g. Android Discussions) if you have problems 😉

---

<div class="post-metadata">

**Author:** ![Puneet\_Thakur](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@Puneet\_Thakur](https://community.thunkable.com/u/Puneet_Thakur)\
**Post date:** [January 23, 2018, 8:41am UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/20 "2018-01-23T08:41:59Z")

</div>

@Italo

 ![IMG_20180123_140413](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/2X/3/3ea6403e59b6f4fd85804433d6c6a337f613cabf.JPG)

---

<div class="post-metadata">

**Author:** ![Italo](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@Italo](https://community.thunkable.com/u/Italo)\
**Post date:** [January 23, 2018, 6:51pm UTC](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636/21 "2018-01-23T18:51:06Z")

</div>

It looks like it should work. How big the image assigned to your sprite is?

[Next page](https://community.thunkable.com/t/latest-thunkable-for-android-releases-pinch-to-scale-on-canvas/6636.md?page=2)
