Shear a sprite according to a specific angle ?

Just starting out? Need help? Post your questions and find answers here.
Joubarbe
Enthusiast
Enthusiast
Posts: 713
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Shear a sprite according to a specific angle ?

Post by Joubarbe »

Hi,

I'd like to know if it's possible to "shear" a sprite without losing too much quality, according to a given angle. In fact, I'd like to do the same thing I do in Photoshop : skew the image at a vertical angle of 3°, from this image :

Image

to this one :

Image

Or is it better to load my already sheared image into PB ?
True29
User
User
Posts: 64
Joined: Sun Feb 03, 2013 1:50 am

Re: Shear a sprite according to a specific angle ?

Post by True29 »

i think photoshop do a little bit antialiasing.
Joubarbe
Enthusiast
Enthusiast
Posts: 713
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: Shear a sprite according to a specific angle ?

Post by Joubarbe »

Yep, that's why a simple TransformSprite() won't give a good result.
User avatar
STARGÅTE
Addict
Addict
Posts: 2235
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Shear a sprite according to a specific angle ?

Post by STARGÅTE »

You can set SpriteQuality(#PB_Sprite_BilinearFiltering) and use TransformSprite() with self calculated corners (instead of RotateSprite). And try to move the sprite some sub-pixel like +0.5 for x and y
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Joubarbe
Enthusiast
Enthusiast
Posts: 713
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: Shear a sprite according to a specific angle ?

Post by Joubarbe »

Currently I was using (always with PB_Sprite_BilinearFiltering) :

Code: Select all

dbg = SpriteWidth(spr)
dbg2 = SpriteHeight(spr)
TransformSprite(spr, 0, 0, #PB_Default, dbg, 5, #PB_Default, dbg, dbg2 + 5, #PB_Default, 0, dbg2, #PB_Default)
But as you probably guess, that gives aliasing. The only solution I see is to load my sprites as images and use the gDrawing library to draw them into a sprite with the gShear function. That's not ideal, because I need to have the same image twice...
Post Reply