Skip to content

Drawicons

Pablo Mayobre edited this page Mar 25, 2015 · 3 revisions

Drawicons

The Drawicons library takes the overhead of drawing icons.

To draw icons you would need to load the font and then correctly position the characters in the spot you want, drawicons.lua does all this for you plus it makes rotation really simple.

Require Drawicons

When you require drawicons in your project, it gives you a function you need to call with three arguments:

  • path: The path to the asset folder (Where the icon.ttf font can be found)
  • icons: This is the table returned when you require the Icons library
  • color: This is the table returned when you require the Colors library

This function returns the drawicons module

icons = require "material-love.libs.icons"
color = require "material-love.libs.color"
drawicons = require "material-love.libs.drawicons" ("material-love/assets", icons, color)

Using Drawicons

To use it you can simply call it inside love.draw with like this:

drawicons (icon, x,y, rotation, color, active, invert)
  • icon: The name of the icon you want to draw as found on the icons table.
  • x,y: The x and y position where the icon will be drawn (this will be the center point for the icon)
  • rotation: Rotation angle (in radians)
  • color: The color of the icon (can be "black" or "white")
  • active: Boolean value of the state (true for active, false for inactive)
  • invert: An InvertMode ("vertical", "horizontal", "vertical-horizontal", "none"). Will invert the icon in the specified axis.

Files

To use this library you need the following files:

  • libs/drawicons.lua
  • libs/icons.lua
  • libs/colors.lua
  • assets/icons.ttf
Clone this wiki locally