[Library] Quick Gradient Library
Posted: Thu Sep 25, 2014 5:25 am
So, I've always wanted to make some gradients, but LÖVE doesn't support it. So I made a quick library to make various different types of gradients in any shape you want (circle, rectangle, polygon, even lines!).
Update: Now this works for Löve 0.10.1, and I've updated the code so that having the gradient images is optional, not mandatory. If the gradients folder is not available, the program will now generate the images for you!
Just call require "gradient" and you're done!
How to use it:
If you have any feedback, error or feedback, please let me know.
Oh, here's an example (use the keys "WASD" to move the square, "TAB" to switch between gradients and "QE" to rotate it):
Aaaannd... A screenshot:
(I'm open to any tips on how to improve this)
Update: Now this works for Löve 0.10.1, and I've updated the code so that having the gradient images is optional, not mandatory. If the gradients folder is not available, the program will now generate the images for you!
Just call require "gradient" and you're done!
How to use it:
Code: Select all
love.gradient.draw(function, mode, centerX, centerY, width, height, color1, color2[, angle, scaleX, scaleY])
Function: A drawing function (like with love stencils).
Mode: A gradient mode (linear, radial, angle, rhombus or square).
Center X: The X center of your shape.
Center Y: The Y center of your shape.
Width: The width of your shape (regardless of rotation).
Height: The height of your shape (regardless of rotation).
Color 1: The back color of your gradient.
Color 2: The front color of your gradient.
Angle: The rotation of your gradient image (default: 0).
Scale X: The scale factor for your gradient's width (default: 1, flip horizontally: -1).
Scale Y: The scale factor for your gradient's height (default: 1, flip vertically: -1).
Oh, here's an example (use the keys "WASD" to move the square, "TAB" to switch between gradients and "QE" to rotate it):
Aaaannd... A screenshot:
(I'm open to any tips on how to improve this)