Mirroring a Sprite

Previous topic - Next topic

Albert

Hi!
I have a number of sprites, loaded by LOADANIM
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

try scale = -1 in Rotozoomanim.
No, Flips upside down. It's not possible. Try creating the image again with tiles flipped.

Albert

Bad news.
Ok. meanwhile i created the mirrored tiles.

MEGAMANFAN

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

#4
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=0
LOADSPRITE "image.png",ID
SpriteMirrorH(ID,x,y)



Code (Mirror Horizontal:) Select

FUNCTION SpriteMirrorH: num, x, y
LOCAL sW,sH,color=RGB(255,255,255)
GETSPRITESIZE num, sW,sH
STARTPOLY num , FALSE
POLYVECTOR x,y,sW,0, color
POLYVECTOR x,y+sH,sW,sH, color
POLYVECTOR x+sW,y+sH,0,sH, color
POLYVECTOR x+sW,y,0,0, color
ENDPOLY
ENDFUNCTION



Code (Mirror Vertical:) Select

FUNCTION SpriteMirrorV: num, x, y
LOCAL sW,sH,color=RGB(255,255,255)
GETSPRITESIZE num, sW,sH
STARTPOLY num , FALSE
POLYVECTOR x,y,0,sH, color
POLYVECTOR x,y+sH,0,0, color
POLYVECTOR x+sW,y+sH,sW,0, color
POLYVECTOR x+sW,y,sW,sH, color
ENDPOLY
ENDFUNCTION



Code (Mirror Vertical AND Horizontal:) Select

FUNCTION SpriteMirrorVH: num, x, y
LOCAL sW,sH,color=RGB(255,255,255)
GETSPRITESIZE num, sW,sH
STARTPOLY num , FALSE
POLYVECTOR x,y,sW,sH, color
POLYVECTOR x,y+sH,sW,0, color
POLYVECTOR x+sW,y+sH,0,0, color
POLYVECTOR x+sW,y,0,sH, color
ENDPOLY
ENDFUNCTION

Bing ChatGpt is pretty smart :O

Albert

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

rotozoomanim with negative scaling?

Albert

#7
:) 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)  :whistle:

EDIT:
Stretchanim with negative value seems to work.
Code (glbasic) Select

DRAWANIM Bitmap%, anim%, x%, y% //draws normal anim frame
STRETCHANIM Bitmap%, anim%, x%+width%, y%, -width%, height% //draws mirrored anim frame

I love my Brick

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

Nice!
I'm using StretchSprite and StretchAnim

I love my Brick

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

Sounds good & am looking forward to seeing it  =D.

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  :D

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

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

Quote from: fuzzy70 on 2012-Apr-13
Sounds good & am looking forward to seeing it  =D.

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  :D

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. :good:
I like things and do stuff.

I love my Brick

Quote from: erico 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.