Jump to content
  • entries
    3
  • comments
    29
  • views
    8,387

LED - LE pure 2d drawing library


Lunarovich

4,204 views

 Share

Let's admit it, LE context drawing functions are essentially OK, but are very basic and very low-level. I wish something like LED library API would make a part of the official LE API one day.

 

Until then, here is LED: a lightweight (~350 lines of code) LUA 2d drawing library draft. It gives you out of the box entities - Text, Panel, Image and Animation - enriched with useful functions like SetPosition, SetScale, SetColor, Release and similar.

 

In order to use it grab Main.lua (for the example) and LED/LED.lua (for the lib itself) files from my github.

 

P.S. Library is in its early state of development, so bugs are possible (even trivial ones unsure.png). In the future, I'll add the documentation (for now, use the Main.lua example and read the code - it's not complicated) and more functionality. Do not hesitate to participate in the development if you like the project.

 

EDIT 04.06.15

Added SetPivot() via shaders.

 

EDIT 05.06.15

Added Intersection(). Now you can test for basic rectangle based overlapping.

 

pcezWy1.png

  • Upvote 6
 Share

10 Comments


Recommended Comments

You're welcome :) Please do signal any bugs or inconsistencies. I feel that it's essential that we have something like this in LE.

Link to comment

That's amusing, I've been working on something just like this myself! XD

I think we all have at some point made a gfx library for Leadwerks.

Link to comment

I think we all have at some point made a gfx library for Leadwerks.

 

Cool :) If anyone has something that is less basic and more consistent than this, it would be great to see it. A community project with contributors and maintainers would be even greater :)

Link to comment

Einlander: I was planning to release it once it was remotely ready though smile.png

 

Lunarovich: Mine is fairly basic to be honest, I was aiming to allow theme files (a master lua table with settings) to configure the gui's looks(size of borders, colors, etc). Currently it has a button and a some-what messed up label( forgot to update some older code with newer algorithms) I would have no issue uploading the code somewhere later on if you like, though please bear in mind that I'm still somewhat new to leadwerks and definitely GUI coding smile.png

Link to comment

Einlander: I was planning to release it once it was remotely ready though smile.png

 

Lunarovich: Mine is fairly basic to be honest, I was aiming to allow theme files (a master lua table with settings) to configure the gui's looks(size of borders, colors, etc). Currently it has a button and a some-what messed up label( forgot to update some older code with newer algorithms) I would have no issue uploading the code somewhere later on if you like, though please bear in mind that I'm still somewhat new to leadwerks and definitely GUI coding smile.png

 

Mine was a complete window manager and all its objects. I put it on hold after the setscale command didn't work correctly

Link to comment

Mine was a complete window manager and all its objects. I put it on hold after the setscale command didn't work correctly

 

On the other hand, I don't have an ambition to make a window manager. I just want to implement a barebones solid library that gives us graphical entities, properties and methods out of the box. At this point, I don't even want to implement such things as buttons, menus and similar. For example, I want to have a sprite with a method SetPivot. A nice addition would be to have a nesting hierarchy of entities, so that transformations of a parent sprite get automatically applied to children sprites.

 

Btw, @Einlander, do you plan to release your library? Another question: do you know how one goes to implement pivot?

Link to comment

I've just impelemnted SetPivot via shaders. It was not possible to do it via SetTranslation, since it translates canvas, so to say, and not an entity.

 

Anyway, you can now have entities rotating about an arbitrary pivot. See Main.lua for examples.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...