-
Notifications
You must be signed in to change notification settings - Fork 3
Using all the libraries
#Using the whole set of Libraries
If after reading through all the features this library provides you have come here then that is Awesome!
Using this library as a set instead of as separated libraries is way easier. You just need to require material-love
inside love.load
(it needs access to the LÖVE modules)
local m
love.load = function ()
m = require "material-love"
end
Now you have access to all the modules inside material-love
To use shadows you can just call m.shadow
in your love.draw
function:
love.draw = function ()
m.shadow.draw(x,y,w,h,center,pad,depth)
end
The PatchObject is stored in m.shadow.patch
for you to access it methods and properties.
For more info on the parameters of the shadows check the Shadows page
The FAB draw function is mapped to the m.fab
function so it is pretty simple to use it too
love.draw = function ()
love.graphics.setColor(color)
m.fab(x,y,r,depth)
end
For more info on the parameters and why you should set the color to your desired color first, check the FAB page
The color module is available through the m.color
space, and all the functions are also exposed
m.color ("red","A200")
m.color.main ("cyan")
m.color.mono ("white","divider")
m.color.variations ("brown")
m.color.background ("dark")
m.color.list ()
For more info on each of this functions check the Colors page
You can create Ripple objects through the m.ripple
table with the appropriate functions
m.ripple.box(x,y,w,h,r,g,b,a,tim)
m.ripple.circle(x,y,ra,r,g,b,a,tim)
m.ripple.custom(f,fr,r,g,b,a,tim)
m.ripple.stencil(x,y,w,h,tim)
Also if for some reason you dont want to use the objects methods you can:
- Update them through the
m.ripple.update
function - Draw them through the
m.ripple.draw
function - Start a ripple on them through the
m.ripple.start
function - Fade the active ripple on them through the
m.ripple.fade
function
For info on each of this functions check the Ripples page
Accessing the roundrect
function is simple, it is in the m.roundrect
variable, the arguments are the same and the return value too.
Use it as you would do with roundrect
love.load = function ()
m = require "material-love"
p = m.roundrect(x,y,w,h,xr,yr,precission,{true,true,true,true})
end
love.draw = function ()
love.graphics.polygon("fill",unpack(p))
love.graphics.polygon("line",unpack(p))
end
For more info check the Rounded Rectangle page.
The Roboto fonts are accessible through the m.roboto
table, though you can also use it as a function as with the normal roboto
table
love.graphics.setFont(m.roboto "body2")
love.graphics.setFont(m.roboto.title)
For more info check the Roboto page
Icons and DrawIcons are merged into a single table, called m.icons
with this four functions:
-
m.icons.get
which acts asicons.get
-
m.icons.list
which acts asicons.list
-
m.icons.names
which acts asicons.names
-
m.icons.draw
which acts asdrawicon
Plus you can access the icon font through m.icons.font
Check the pages for DrawIcons and Icons for more info on these functions.
The Nine Patch library can be found on the m.nine
table. Using it is the same as using the nine.lua
file
local PatchImage = love.graphics.newImage("material-love/images/ninepatch.png")
m.nine.convert(PatchImage,"ninepatch",true)
local PatchTable = love.filesystem.load("ninepatch.lua")()()
PatchObject = m.nine.process(PatchTable)
m.nine.draw(PatchObject,x,y,w,h,pad,image)
For more info on these functions check the Nine Patch page which explains them in detail
The smooth image transition that can be found on the image
library can be found through m.image
with both the new
and draw
functions.
-
m.image.new
Creates a new object, with the image object which providesdraw
andupdate
methods so it is easier to use it. -
m.image.draw
Handles just thedraw
part, so you have to provide the elapsed time.
For more info on these functions and the methods of the image object check the Image Transition page.
Loading spinners which can normally be found on the spinner
library are inside m.spinner
local spin = m.spinner.new(radius,width,speed)
local ospin = m.spinner.new(oradius,owidth,ospeed)
love.update = function (dt)
spin:update(dt)
m.spinner.update(ospin,dt)
end
love.draw = function ()
spin:draw(x,y)
m.spinner.draw(ospin,ox,oy)
end
For more info on spinners and their method go to the Loading Spinners page
I hope this can be useful to you, if you have doubts dont doubt to ask me, you can use the Issue Tracker (check the Guidelines), the LÖVE forums (which I check periodically) and you can send me a mail (you can find my e-mail here)