parseimg - parses images

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

parseimg - parses images

Post by alloyed »

parseimg is a small utility library for turning raster ImageData into higher-level shapes, which can be useful for visually defining game data without having to hardcode and tweak numbers inside a text editor, or having to write your own game editor. The algorithms here have been sitting in different forms for a while in my misc utilities bucket, where I've used them for:
* simple tilemaps
* object placement in non-tiled maps
* hitboxes for character sprites
* spatial positioning for UI/HUD elements
and probably more. to see exactly how parseimg does this, check out the code and included comments:

https://gist.github.com/Alloyed/d66abd4 ... 2e201a4c0b

A simple example+screenshot is attached. It doesn't show how you'd actually use these algorithms in a game but hopefully it gives you a sense of how they behave so you can imagine your own examples:
2017-04-11-015829_800x600_scrot.png
2017-04-11-015829_800x600_scrot.png (16.52 KiB) Viewed 3523 times
Attachments
parseimg-v0.1.love
(8.82 KiB) Downloaded 118 times
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: parseimg - parses images

Post by s-ol »

This is pretty neat! What are the rectangles inside the circles representing? Sometimes they are centered but sometimes they are not.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
alloyed
Citizen
Posts: 80
Joined: Thu May 28, 2015 8:45 pm
Contact:

Re: parseimg - parses images

Post by alloyed »

It's basically the center of the circle, rounded to the closest pixel. The cases where they aren't centered is because the center is actually in between two pixels, and the algorithm will actually give you the fractional position if you want it, for example {x = 2.5, y = 2.5, r = 3.5}, but usually I just round it off in practice
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: parseimg - parses images

Post by yetneverdone »

Cool!
Please correct me if im wrong, is one of its possible uses is to render a "part" of a large image? Im guessing based on the screenshot.
Post Reply

Who is online

Users browsing this forum: No registered users and 69 guests