Spielerando

Rotate Pixel Art: Three Ways and What Each Costs

There is no perfect way to turn pixel art by a slanted angle, because the turned pixels do not land on the grid. There are three good ways, and each pays a different price: one keeps every pixel and roughens the edge, one gives the cleanest outline and loses small details, and one is what your engine does when you just turn the sprite. You can measure the price on your own sprite before you choose.

A pixel art bee seen from above, turned by 0, 15, 30, 45, 60 and 75 degrees, in three rows. In the top row the stripes get ragged near 45 degrees, in the middle row the outline stays clean, in the bottom row the shape sits in between.
Our bee, 16 by 16 pixels, turned by 0, 15, 30, 45, 60 and 75 degrees. Top row: every pixel kept. Middle row: smooth. Bottom row: the usual way.

Why does a turned sprite look broken?

A quarter turn is exact: every pixel moves to a new square of the grid and nothing changes. At 30 degrees the squares of the turned sprite lie across the grid, and something has to decide which grid square gets which colour.

The usual way asks, for each square of the new picture, which old pixel is nearest. Some old pixels are then taken twice and some never. On a big, soft picture nobody notices. On a sprite of 16 by 16, a pixel that is never taken can be an eye.

What does each way cost?

We turned the bee through a full circle in steps of one degree, 360 pictures for each way, and counted. The bee has 96 pixels. Two of them are its eyes, white and one pixel each.

Way Angles at which a colour gained or lost pixels Angles at which an eye was lost Length of the outline, on average
Every pixel kept 0 0 72.1
Smooth 348 296 61.6
The usual way 268 32 68.2

The outline is counted in pixel sides that touch nothing, so a rougher edge is a longer one. The bee as drawn has 68.

Read across, the table says what the picture shows. Keeping every pixel never loses anything, and its edge is the roughest of the three. The smooth way has the shortest, cleanest outline, and it lost an eye of the bee at 296 of the 360 angles. The usual way sits between them on both counts.

At 30 degrees, this is what each way did to the bee's colours. A minus is pixels lost, a plus is pixels gained:

keep     {}
smooth   {"#1f2142":-3,"#9db8ff":-1,"#f2c14e":1,"#ffffff":-2}
nearest  {"#1f2142":-3}

#ffffff is the eyes: the smooth way lost both. #1f2142 is the dark ink of the stripes and the antennae: the usual way lost three pixels of it, and so did the smooth way.

Three pixel art bees side by side, each turning in steps of 15 degrees: every pixel kept on the left, smooth in the middle, the usual way on the right.
The same three ways through a full turn, in steps of 15 degrees. From left to right: every pixel kept, smooth, the usual way. Watch the eyes.

How do the three ways work?

Every pixel kept. The turn is done as three slides: every row slides sideways by a whole number of pixels, then every column slides up or down, then every row slides again. A slide by whole pixels cannot lose a pixel or double one, so three slides cannot either. Turning a picture with three such slides goes back to Alan W. Paeth, 1986. The price is position: in our tests each pixel lands less than 1.2 pixels from the perfect place, and that is what roughens the edge, most of all near 45 degrees.

Smooth. The sprite is first drawn nine times as big with its stairs smoothed, by a rule called Scale3x applied twice, and the turned picture is read from the big one. The Scale2x project, which Scale3x belongs to, names Andrea Mazzoleni as the author and 2001 as the year. A close relative is RotSprite, which Aseprite offers next to its fast rotation: it scales to eight times the size, turns and shrinks back.

The usual way. Each new pixel takes the nearest old one. It is what an engine does when you turn a sprite whose filter is set to nearest, the common setting for pixel art. Godot's manual describes that filter in one line: "The texture filter reads from the nearest pixel only."

Quarter turns and mirroring are exact in all three, and the recipe does them first. So only the last 45 degrees or less are ever slanted.

Which one should you use?

  • Details of one pixel, such as eyes, a glint or a thin antenna: keep every pixel. It is the only way that cannot lose them.
  • Solid shapes without such details, such as a rock, a wheel or a shield: try smooth first. Its outline is the cleanest.
  • Only four directions: you need no slanted turn at all. Quarter turns and mirroring are exact.
  • A sprite that turns freely while the game runs: the engine will use the usual way on every frame. If that flickers, make 16 or 24 frames ahead of time and show the nearest one.

Whatever you pick, always turn the original sprite. A sprite that was turned before carries its damage into the next turn.

And then look. The numbers tell you what was lost, not what looks right. The frames can be written back as text with the recipe Pixel art from text, so your AI can repair the two or three pixels that bother you in one frame without touching the rest.

Paste this to your AI

My sprite [file or text] has to turn in my game. Help me choose how.

1. First tell me in words what in this sprite is one pixel thin or one
   pixel small: eyes, glints, lines. Those are what a turn can destroy.
2. Take the code "Pixel rotation" from
   https://spielerando.com/en/recipes/pixel-rotation. Run its tests first
   and show me that they pass.
3. Turn the original sprite into [8] frames in each of the three ways:
   keep, smooth and nearest. Show me the three rows side by side, scaled
   up 8 times.
4. Under each frame, show me what lostPixels says about it, as printed.
   Do not tell me which row is best. I choose.
5. Write the row I choose as a sprite sheet. If I name pixels to repair,
   change only those and show me the frame again.

How to check it worked

  • Find the smallest detail in every frame. If your sprite has eyes, count them in each one.
  • Compare the first frame with the original. It is not turned, so it must be the same picture.
  • Check the quarter frames. With 8 frames, the third, fifth and seventh are quarter turns and must be exact copies, turned.
  • Play the turn slowly. A frame that looks fine alone can still jump against its neighbours.
  • Check the size. Every frame must have the same width and height, or the sprite will hop while it turns.

Was this page helpful?

One click, no account. It shows us which pages help.

Next step

Cookbook

A Character Facing 8 Directions from One Set of Drawings

A bee seen from above can simply be turned, but a figure seen at a slant shows a different side from each direction, and this page builds all of them from one set of layers.

Sources

Last updated: 2026-11-26