# Efficient image rotation via sheers (maybe)

**URL:** <https://forum.makecode.com/t/efficient-image-rotation-via-sheers-maybe/17568>\
**Category:** Arcade\
**Tags:** graphics-and-math\
**Created:** [January 24, 2023, 12:36am UTC](https://forum.makecode.com/t/efficient-image-rotation-via-sheers-maybe/17568 "2023-01-24T00:36:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [January 24, 2023, 12:36am UTC](https://forum.makecode.com/t/efficient-image-rotation-via-sheers-maybe/17568/1 "2023-01-24T00:36:32Z")

</div>

I don’t know what the current state of image rotation in Arcade is but I remember back in the day the option I was using was a pretty inefficient power-of-2 scale then sample technique and the best way to get this to go fast was to pre-generate a flip book w/ ~16 angles or so, but this used quite a bit of memory and it was annoying to set up.

Anyway I just learned about a way to efficiently rotate sprites that just uses three sheers operations and has some nice properties (no pixel duplication or loss) and might be efficient enough to be done in real time on low end hw since it used to be common practice on pre-gpu hardware:

> **[Rotation with three shears](https://cohost.org/tomforsyth/post/891823-rotation-with-three)**
>
> There's a graphics trick that used to be widely known that has now probably almost vanished from the graphics consciousness - you can do rotations by applying three shears in a row. This should surprise you! It surprised me. And it re-surprises me...

[https://www.ocf.berkeley.edu/~fricke/projects/israel/paeth/rotation\_by\_shearing.html](https://www.ocf.berkeley.edu/~fricke/projects/israel/paeth/rotation_by_shearing.html)

Since there’s no data loss and the operation is reversible, it might even make sense to do in-place update of the image data to save on memory.

Hopefully this is a useful data point for the next extension writer that wants to revisit rotation (if it isn’t solved already) 🙂

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 24, 2023, 12:38am UTC](https://forum.makecode.com/t/efficient-image-rotation-via-sheers-maybe/17568/2 "2023-01-24T00:38:43Z")

</div>

This is super cool!

@eanders @jwunderl

---

<div class="post-metadata">

**Author:** ![isoffline](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/isoffline/32/8791_2.png) [@isoffline](https://forum.makecode.com/u/isoffline)\
**Post date:** [January 24, 2023, 10:17pm UTC](https://forum.makecode.com/t/efficient-image-rotation-via-sheers-maybe/17568/3 "2023-01-24T22:17:28Z")

</div>

YES THIS IS WHAT IVE BEEN ASKING!! yey

---

<div class="post-metadata">

**Author:** ![I\_cant\_code](https://avatars.discourse-cdn.com/v4/letter/i/a9adbd/32.png) [@I\_cant\_code](https://forum.makecode.com/u/I_cant_code)\
**Post date:** [February 15, 2023, 4:37pm UTC](https://forum.makecode.com/t/efficient-image-rotation-via-sheers-maybe/17568/4 "2023-02-15T16:37:42Z")

</div>

Can we please have built in sprite and image rotation?
