how does anim8 reads an image?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
lex
Prole
Posts: 23
Joined: Fri Nov 28, 2014 4:58 am

how does anim8 reads an image?

Post by lex »

I saw a tutorial don't remember where? anyways...

this I kind of get it.
all I do its count the x 32 and the y 32 ! ( 32x32 rectangle)
--no clue whats an offset? or border--

Code: Select all

                  -- frame, image,                         offsets, border
	   g32 = anim8.newGrid(32,32, 1024,768,   3,3,     1)

          spinning = {
             anim8.newAnimation(g32('1-8',1),              0.8),
             anim8.newAnimation(g32(18,'8-11', 18,'10-7'), 0.8),
}
BUT? this I dont get it? I count from side to side even as 32x32 and still???
didnt come close to the image area.. they are not 32x32 but 64x64 ?
Worst I see more images with different sizes how does anim8 read them???

Code: Select all

                          -- frame, image,    offsets, border
		g64 = anim8.newGrid(64,64, 1024,768,  299,101,   2)
	        plane    = anim8.newAnimation(g64(1,'1-3'), 0.1)
	        seaplane = anim8.newAnimation(g64('2-4',3), 0.1)

is this picture made of 32x32 rectangle from left to right and top to bottom???
or HOW does it works?
Attachments
1945.png
1945.png (61.47 KiB) Viewed 4797 times
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: how does anim8 reads an image?

Post by kikito »

Hi there,

First of all, there is documentation about what each parameter does in anim8's github page:

https://github.com/kikito/anim8

Maybe I should explain them in more detail. I will do so here. anim8.newGrid has the following parameters:

Code: Select all

anim8.newGrid(frameWidth, frameHeight, imageWidth, imageHeight, left, top, border)
frameWidth and frameHeight are the dimensions of each animation frame (if your character is 32x32, then they are 32).

imageWidth and imageHeight are the dimensions of the image containing all the frames - usually you get them by doing image:getWidth() and image:getHeight().

Now, the next two are problematic: left and top. Their use case is this: Sometimes, the first top-left corner of the grid that you want to capture does not start in 0,0. For example, the submarine is a 32x98 animation, but it is in x=366 and y=98 on the image. You can't "make that grid start at 0,0" because 366 is not a multiple of 32. Instead, you set the "origin" to x=366 and y=98, so the "first frame" (the frame with numbers 1,1 on the grid) is the first frame of the submarine.

Finally, border is quite simple. Notice that all the planes in the image have a "gray border" around them. If I just make the frames go "one after the other", then that border will appear. I have to "skip" it. That's what "border" does. It says that there is a border of 1 pixel between each frame in the image, and that the calculations must take that into account to "skip".

I have made this image for the submarine grid, I hope you find it useful:
anim8-explanation.png
anim8-explanation.png (183.28 KiB) Viewed 4754 times
When I write def I mean function.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: how does anim8 reads an image?

Post by kikito »

Hi again,

I have added this explanation and some other details to the anim8 readme. I hope you get a better idea of what each parameter does now:

https://github.com/kikito/anim8
When I write def I mean function.
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: how does anim8 reads an image?

Post by pielago »

Ohh I have use only AnAL
but by far this its better kikito Nice work!
question can I be able to use this as tiles as well????
I want to place animation ,different size houses,nature as tiles for map
trying to use less possibles images as possible and place em in maybe 3 big images ..
lex
Prole
Posts: 23
Joined: Fri Nov 28, 2014 4:58 am

Re: how does anim8 reads an image?

Post by lex »

thank you I am about to read it and work on it
the only part that i am not sure how to get its the offset how do you get it and
not sure what are tiles I got to search in to it as well XD
sorry pretty new at this also is there place online where i can gather with ppl that use love2D to chat and learn from them
I see love2D its not easy as how the front-page describe it XD
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: how does anim8 reads an image?

Post by kikito »

pielago wrote:question can I be able to use this as tiles as well????
Yes, you can use if for tiles as well.
pielago wrote:trying to use less possibles images as possible and place em in maybe 3 big images ..
Don't make the images too big - some graphics cards still have difficulties with images bigger than 1024x1024
lex wrote:the only part that i am not sure how to get its the offset how do you get it
You open the image with a drawing program (the gimp, photoshop, etc), put the cursor on the top-left pixel where you want the grid to start, and then note those coordinates. That's the offset.
lex wrote:not sure what are tiles
In addition to animating enemies or the player, you can also animate parts of the scenario (for example water). The square pieces that form a level are called tiles. With anim8 you can animate characters or tiles (they work the same, animation-wise)
When I write def I mean function.
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: how does anim8 reads an image?

Post by pielago »

Thank you so much for the info
No bigger than 1024x1024
Omg now I get why I had problems with my Images they were to big ..
so the standard size of a picture what wold it be ? so any graphics cards can work even old ones?
from your experience? kikito can you tell me? so I can note it..
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: how does anim8 reads an image?

Post by kikito »

so the standard size of a picture what wold it be ? so any graphics cards can work even old ones?
The max I would use is 1024x1024. You can also use smaller.
When I write def I mean function.
lex
Prole
Posts: 23
Joined: Fri Nov 28, 2014 4:58 am

Re: how does anim8 reads an image?

Post by lex »

Yes ..thank you kikito finally I am able to animate the rest of the images..
last question almost all of them are animations BUT what if I want to just display one image (not animation) from the big image?

Code: Select all

g = anim8.newGrid(64,65, 1024,768,   167,498,   1)
land = anim8.newAnimation( g (1,1), 0.1)
do I still use the 0.1?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: how does anim8 reads an image?

Post by Positive07 »

lex wrote:Yes ..thank you kikito finally I am able to animate the rest of the images..
last question almost all of them are animations BUT what if I want to just display one image (not animation) from the big image?

Code: Select all

g = anim8.newGrid(64,65, 1024,768,   167,498,   1)
land = anim8.newAnimation( g (1,1), 0.1)
do I still use the 0.1?
That may be wasting too much (I mean, anim8 creates data needed to animate like all the assets in the grid in a table, and position, width... etc etc, you just need the image section), use a [wiki]Quad[/wiki] instead, you can create one with [wiki]love.graphics.newQuad[/wiki]

The arguments are pretty similar, x, y, w, h, realw and realh (realw and realh are the real width and height of the image

Then you can draw it with [wiki]love.graphics.draw[/wiki](yourQuad, yourImage, posx, posy, rotation, scalex, scaley)

I think this is simpler :awesome: . Also it is, in most cases the basic of the standard map approach. I think Quads are what anim8 uses inside of it, of course anim8 has a nice API for animations on top of that
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], rabbitboots, Semrush [Bot] and 3 guests