99 lines
No EOL
1.9 KiB
Lua
99 lines
No EOL
1.9 KiB
Lua
local default_G = {}
|
|
for k, v in pairs(_G) do
|
|
table.insert(default_G, k)
|
|
end
|
|
|
|
love.graphics.setDefaultFilter('nearest', 'nearest')
|
|
interfaceFont = love.graphics.newFont('Inter-Regular.otf', 20)
|
|
|
|
ease = require 'ease'
|
|
|
|
slider = require 'slider'
|
|
dropdown = require 'dropdown'
|
|
graph = require 'graph'
|
|
|
|
modes = {
|
|
preview = 1,
|
|
mix = 2,
|
|
multiply = 3,
|
|
create = 4
|
|
}
|
|
|
|
function createUI()
|
|
dropdown.createDropdowns()
|
|
slider.createSliders()
|
|
end
|
|
|
|
require 'util' -- exports into global table
|
|
|
|
-- rendering constants
|
|
|
|
padding = 16
|
|
outerpadding = 22
|
|
margin = 6
|
|
dropdownWidth = 186
|
|
lineWidth = 2
|
|
fontHeight = love.graphics.getFont():getHeight()
|
|
|
|
-- global for convinience's sake
|
|
|
|
mode = nil
|
|
|
|
function love.load()
|
|
love.graphics.setFont(interfaceFont)
|
|
fontHeight = love.graphics.getFont():getHeight()
|
|
createUI()
|
|
end
|
|
|
|
function love.update(dt)
|
|
graph.update(dt)
|
|
slider.update(dt)
|
|
dropdown.update(dt)
|
|
end
|
|
|
|
function love.draw()
|
|
local sw, sh = love.graphics.getDimensions()
|
|
local mx, my = love.mouse.getPosition()
|
|
|
|
love.graphics.setLineWidth(2)
|
|
|
|
love.graphics.setColor(0.09, 0.09, 0.12, 1)
|
|
love.graphics.rectangle('fill', 0, 0, sw, sh)
|
|
love.graphics.setColor(0.08, 0.08, 0.1, 1)
|
|
love.graphics.rectangle('line', 0, 0, sw, sh)
|
|
|
|
love.graphics.setColor(0.2, 0.2, 0.3, 1)
|
|
love.graphics.print('Box of Eases by oatmealine', outerpadding, sh - fontHeight - outerpadding)
|
|
|
|
slider.render()
|
|
|
|
dropdown.render()
|
|
|
|
graph.render()
|
|
end
|
|
|
|
function love.mousepressed(x, y, m)
|
|
if dropdown.mousepressed(x, y, m) then return end
|
|
end
|
|
|
|
function love.mousereleased(x, y, m)
|
|
if dropdown.mousereleased(x, y, m) then return end
|
|
end
|
|
|
|
function love.wheelmoved(x, y)
|
|
if y == 0 then return end
|
|
|
|
if dropdown.wheelmoved(x, y) then return end
|
|
end
|
|
|
|
function love.keypressed(key)
|
|
if key == 'f6' then -- print all globals
|
|
for k, v in pairs(_G) do
|
|
for _, g in ipairs(default_G) do
|
|
if g == k then goto continue end
|
|
end
|
|
print(k, v)
|
|
::continue::
|
|
end
|
|
end
|
|
end |