Kikito suggested it could be done in Lua, if I understood him correctly. I'm guessing you'd have to track the previous pixel, and on color change you would use an intermediate alpha with the previous color? That would lead to serious blurring though...TechnoCat wrote:You can't have soft edges with no alpha channel.tentus wrote:@kikito/Technocat: Bad aliasing drives me nuts. How would you do it in code, so I can see how the results turn out? Also, PNG-8 has some well-known gamma problems (http://hsivonen.iki.fi/png-gamma/). This might not be true within Love, but I still shy away from the format.
But an easy way to turn green into transparent would be to use http://love2d.org/wiki/ImageData:mapPixelCode: Select all
function pixelFunction(x, y, r, g, b, a) if r==0 and g==255 and b==0 then a = 0 return r, g, b, a end ImageData:mapPixel( pixelFunction )
4KB Explosions Contest
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: 4KB Explosions Contest
Kurosuke needs beta testers
Re: 4KB Explosions Contest
The other one being?tentus wrote:Would you mind compressing the other one, for comparison's sake?
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: 4KB Explosions Contest
Another thing you can try is to make the image at half size, and then have LOVE scale it to 2x with linear filtering. Eh? Maybe have LOVE do the aliasing?tentus wrote:Kikito suggested it could be done in Lua, if I understood him correctly. I'm guessing you'd have to track the previous pixel, and on color change you would use an intermediate alpha with the previous color? That would lead to serious blurring though...
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: 4KB Explosions Contest
The designer in me unconditionally rejects this solution, which I feel kinda bad about. Sorry, but I couldn't live with that solution, it goes against every fiber of my body.TechnoCat wrote: Another thing you can try is to make the image at half size, and then have LOVE scale it to 2x with linear filtering. Eh? Maybe have LOVE do the aliasing?
The first image I posted, http://love2d.org/forums/download/file.php?id=2240. It uses alpha rather than the g channel.thelinx wrote: The other one being?
Kurosuke needs beta testers
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: 4KB Explosions Contest
The only thing I can think about is storing a very basic image (maybe with an even smaller pallete, 8 colors or so) and then adding some blur. For example, the box blur. I don't know the details of imagedata, but in pseudocode it's like this:
EDIT:
Code: Select all
function blur(sourceImage)
imageData = <create a new imagedata with the same with and height as sourceImage>
for each pixel(x,y) in sourceImage
-- "adjacent" can be 4 pixels, or 8 pixels, if you include the diagonal ones. In corners and borders, they're less pixels.
<obtain the r,g,b,a values of the pixels adjacent to (x,y) in sourceImage>
imageData[x][y] = <the average rgba values of the adjacent pixels in sourceImage>
end
return imagedata
end
The blur I'm proposing is 3-pixels wide, and we're talking about a smoke sprite that will be moving, changing in size, and fading. But if that's a problem the loop above can be changed so blurring only applies if at least one of the pixels has an alpha. This will blur the image borders, but leave the internal parts intact.tentus wrote:That would lead to serious blurring though...
Last edited by kikito on Tue Jan 11, 2011 6:38 pm, edited 1 time in total.
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: 4KB Explosions Contest
I don't know anything about this, but wouldn't it be possible to use the g-channel completely for alpha? As in:
Probably not, eh?
EDIT: 2525! OK, I'll stop now. No I won't.
Code: Select all
function pixelFunction(x, y, r, g, b, a)
return r, 0, b, g -- no green?
end
ImageData:mapPixel( pixelFunction )
EDIT: 2525! OK, I'll stop now. No I won't.
Last edited by Robin on Tue Jan 11, 2011 6:45 pm, edited 1 time in total.
Help us help you: attach a .love.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: 4KB Explosions Contest
Close, but it would probably need to be:Robin wrote:I don't know anything about this, but wouldn't it be possible to use the g-channel completely for alpha? As in:
Probably not, eh?Code: Select all
function pixelFunction(x, y, r, g, b, a) return r, 0, b, g -- no green? end ImageData:mapPixel( pixelFunction )
Code: Select all
function pixelFunction(x, y, r, g, b, a)
return r, r, b, g --double r or b to make it grey
end
ImageData:mapPixel( pixelFunction )
*Ring ring ring* Hey, it's me gif!
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: 4KB Explosions Contest
PNG orTechnoCat wrote:*Ring ring ring* Hey, it's me gif!
Help us help you: attach a .love.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: 4KB Explosions Contest
Wouldn't you also need to invert the g value, since 255 alpha is opaque?TechnoCat wrote:Close, but it would probably need to be:Robin wrote:I don't know anything about this, but wouldn't it be possible to use the g-channel completely for alpha? As in:
Probably not, eh?Code: Select all
function pixelFunction(x, y, r, g, b, a) return r, 0, b, g -- no green? end ImageData:mapPixel( pixelFunction )
You could probably write the image out to take 4 bits per pixel in a binary file, 2 for greyscale, 2 for alpha. That could make a really small file.Code: Select all
function pixelFunction(x, y, r, g, b, a) return r, r, b, g --double r or b to make it grey end ImageData:mapPixel( pixelFunction )
*Ring ring ring* Hey, it's me gif!
Code: Select all
function pixelFunction(x, y, r, g, b, a)
return r, r, b, (255 - g) --double r or b to make it grey
end
ImageData:mapPixel( pixelFunction )
Kurosuke needs beta testers
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: 4KB Explosions Contest
Yeah, you would have to figure something out to do it. It might not look correct in an image viewer, but look correct after you parse it depending on what you do.tentus wrote:Wouldn't you also need to invert the g value, since 255 alpha is opaque?
Also, I'm consistently surprised at how often I use GIF at work, it's a great image format.Code: Select all
function pixelFunction(x, y, r, g, b, a) return r, r, b, (255 - g) --double r or b to make it grey end ImageData:mapPixel( pixelFunction )
I like how we're putting all hands on deck to undermine the avoidance of sprites.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests