### Author Topic: Mirroring a Sprite  (Read 9132 times)

#### Albert

• Dr. Type
• Posts: 257
##### Mirroring a Sprite
« on: 2008-Mar-22 »
Hi!
how can I draw a mirrored sprite?
I tried STRETCHANIM with -1, 1 but it seems that stretch values less than 0 -> no sprite visible

Please, I need very fast ansver! Or I have to draw all the mirrored sprites

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10726
• here on my island the sea says 'hello'
##### Mirroring a Sprite
« Reply #1 on: 2008-Mar-22 »
try scale = -1 in Rotozoomanim.
No, Flips upside down. It's not possible. Try creating the image again with tiles flipped.

#### Albert

• Dr. Type
• Posts: 257
##### Mirroring a Sprite
« Reply #2 on: 2008-Mar-23 »
Ok. meanwhile i created the mirrored tiles.

#### MEGAMANFAN

• Mc. Print
• Posts: 14
• cik
##### Re: Mirroring a Sprite
« Reply #3 on: 2009-Oct-03 »
try tomirrorimage it on paint or gimp or photoshop,etc.etc.etc!
think of a number x 2+22 divide 2-1st number = my grade in math!!!

(11)

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1635
• Particle Hawk
##### Re: Mirroring a Sprite
« Reply #4 on: 2009-Oct-03 »
Polyvectors are great for manipulating texture coordinates.

To understand these functions, just use them exactly as if they were "DRAWSPRITE" commands.
These 3 function will mirror, vertical, horizontal, and both.

Code: (How to use Mirror functions) [Select]
`ID=0LOADSPRITE "image.png",IDSpriteMirrorH(ID,x,y)`

Code: (Mirror Horizontal:) [Select]
`FUNCTION SpriteMirrorH: num, x, yLOCAL sW,sH,color=RGB(255,255,255)GETSPRITESIZE num, sW,sHSTARTPOLY num , FALSEPOLYVECTOR x,y,sW,0, colorPOLYVECTOR x,y+sH,sW,sH, colorPOLYVECTOR x+sW,y+sH,0,sH, colorPOLYVECTOR x+sW,y,0,0, colorENDPOLYENDFUNCTION`

Code: (Mirror Vertical:) [Select]
`FUNCTION SpriteMirrorV: num, x, yLOCAL sW,sH,color=RGB(255,255,255)GETSPRITESIZE num, sW,sHSTARTPOLY num , FALSEPOLYVECTOR x,y,0,sH, colorPOLYVECTOR x,y+sH,0,0, colorPOLYVECTOR x+sW,y+sH,sW,0, colorPOLYVECTOR x+sW,y,sW,sH, colorENDPOLYENDFUNCTION`

Code: (Mirror Vertical AND Horizontal:) [Select]
`FUNCTION SpriteMirrorVH: num, x, yLOCAL sW,sH,color=RGB(255,255,255)GETSPRITESIZE num, sW,sHSTARTPOLY num , FALSEPOLYVECTOR x,y,sW,sH, colorPOLYVECTOR x,y+sH,sW,0, colorPOLYVECTOR x+sW,y+sH,0,0, colorPOLYVECTOR x+sW,y,0,sH, colorENDPOLYENDFUNCTION`
« Last Edit: 2009-Oct-04 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

#### Albert

• Dr. Type
• Posts: 257
##### Re: Mirroring a Sprite
« Reply #5 on: 2010-Dec-20 »
Hi again!

The question is similar: There is any built-in function to draw an anim mirrored (2 years passed, maybe a new function arised )? Or Hemlos's code is the preferred one?

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10726
• here on my island the sea says 'hello'
##### Re: Mirroring a Sprite
« Reply #6 on: 2010-Dec-20 »
rotozoomanim with negative scaling?

#### Albert

• Dr. Type
• Posts: 257
##### Re: Mirroring a Sprite
« Reply #7 on: 2010-Dec-20 »
Same what you suggested two years ago. Ok trying now...
Nope. It's only a 180 degree rotation (because this mirrors not about a vertical line but the centerpoint of the image)

EDIT:
Stretchanim with negative value seems to work.
Code: (glbasic) [Select]
`DRAWANIM Bitmap%, anim%, x%, y% //draws normal anim frameSTRETCHANIM Bitmap%, anim%, x%+width%, y%, -width%, height% //draws mirrored anim frame`
« Last Edit: 2010-Dec-20 by Albert »

#### I love my Brick

• Mr. Drawsprite
• Posts: 61
##### Re: Mirroring a Sprite
« Reply #8 on: 2012-Apr-12 »
Im currently coding a sprite designer for GLBasic with all the trimmings and found a solution to the above question.

Zoomsprite num,x,y,-1,1 // will flip the sprite horizontally.
I like things and do stuff.

#### Albert

• Dr. Type
• Posts: 257
##### Re: Mirroring a Sprite
« Reply #9 on: 2012-Apr-12 »
Nice!
I'm using StretchSprite and StretchAnim

#### I love my Brick

• Mr. Drawsprite
• Posts: 61
##### Re: Mirroring a Sprite
« Reply #10 on: 2012-Apr-13 »
Ive started a routine to help (with anims) within the sprite designer.  Save options: save single, save anim, save reverse anim. I`m also implementing a start and finish marker so you can fine tune a anim list and also animate it.

If anyone has any ideas of what they need when designing sprites let me know. But only if Albert is fine with me asking this here.

For now I have coded the following: plot, line, circle/eiipse, box, fill, stencil (various wacky vector shapes that can be shrunk/enlarged upon the grid) flip, rotate, cut n paste, undo, clear, wrap scroll, copy/paste sprite, modify colours, animate(in progress), test screen(paste sprites on screen to see how they look - also in progress), 32x32,64x64 & 128x128 size options

It looks like DPaint in appearence and all drawing options are zoomed to fill the grid.  Draw a line and you see an enlarged pixel line move around the grid etc.
I like things and do stuff.

#### fuzzy70

• Community Developer
• Prof. Inline
• Posts: 828
• Look left, Look right, LOOK OUT!!
##### Re: Mirroring a Sprite
« Reply #11 on: 2012-Apr-13 »
Sounds good & am looking forward to seeing it  .

By "modify colours" to you mean a palette type system or basic image processing features like brighten/darken, invert, outline etc. If it is not the latter then that would be a nice feature & save at trip to GIMP/Photoshop for little tweaks. Also the ability to use a sprite as a brush or fill pattern would be great but am getting carried away now

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

#### erico

• Community Developer
• Prof. Inline
• Posts: 4270
##### Re: Mirroring a Sprite
« Reply #12 on: 2012-Apr-13 »
Light table to hand draw animation and possibly some sort of stencil to make it easier to colorize them.
It does look like a great Idea you should open a thread about it.

About stretchanim and zoomsprite to achieve flipped sprites:
I understand drawsprite is quite fast and that zoomsprite and rotosprite maybe a little slower on systems like caanoo.
I wonder if using stretch or zoom to a perfect negative number would yield same speed as drawsprite.

I might be able to check this on caanoo. I don´t think there would be a problem on higher systems though.

#### I love my Brick

• Mr. Drawsprite
• Posts: 61
##### Re: Mirroring a Sprite
« Reply #13 on: 2012-Apr-13 »
Sounds good & am looking forward to seeing it  .

By "modify colours" to you mean a palette type system or basic image processing features like brighten/darken, invert, outline etc. If it is not the latter then that would be a nice feature & save at trip to GIMP/Photoshop for little tweaks. Also the ability to use a sprite as a brush or fill pattern would be great but am getting carried away now

Lee
[/quote

The palette is currently 48 colours strong in 3 strips ( I dont agree with having 100s of colours on screen. A fixed number allows you plan the palette - just like in the old days ) that have a r,g,b ref next to them.  The ref marker is surrounded by < & > buttons to reduce, increase the colours values.

The cut/paste option uses a sprite and allows it to become the brush. In this mode such options as flip, rotate, scroll etc now effect the brush and not the grid.

Your ideas to improve the fill command have been noted perhaps in a future version. A patterned fill could be made by using data and array commands with preset designs(a method I used early on to generate a stipple fill). A brush fill is a simple case of storing it as an data statement. I will be tinkering with this

I think for now a bitmap save displaying all sprites is the cheapest option with regards to GIMP etc.

Thanks for the ideas.
I like things and do stuff.

#### I love my Brick

• Mr. Drawsprite
• Posts: 61
##### Re: Mirroring a Sprite
« Reply #14 on: 2012-Apr-13 »
Light table to hand draw animation and possibly some sort of stencil to make it easier to colorize them.
It does look like a great Idea you should open a thread about it.

About stretchanim and zoomsprite to achieve flipped sprites:
I understand drawsprite is quite fast and that zoomsprite and rotosprite maybe a little slower on systems like caanoo.
I wonder if using stretch or zoom to a perfect negative number would yield same speed as drawsprite.

I might be able to check this on caanoo. I don´t think there would be a problem on higher systems though.
The animation code currently displays each frame at natural size and large grid size. So you can click through them step by step if needed and make the odd change to the sprite.

I wont hog this thread anymore (sorry) and will soon start my own. I`ll attach a demo of the code when I reach 90% complete - currently 70%.  When I started this project, I made a pen and paper list of things to do. When I tick one off I keep returning to that portion of code with new ideas.  Ive now decided to abort such habits, get through the list and complete the project.

See you all soon
I like things and do stuff.