Skip to content

Instantly share code, notes, and snippets.

@TannerRogalsky
TannerRogalsky / main.lua
Created January 23, 2017 13:55
Fast vertex setting in Love using ImageData and the FFI
local num_verts = 100000
local vertices = {}
for i=1,num_verts do
vertices[i] = {0, 0, 0, 0, 255, 255, 255, 255}
end
local ffi = require('ffi')
ffi.cdef[[
typedef struct {
float x, y;
@Eiyeron
Eiyeron / reflect.glsl
Created October 1, 2017 14:20
Love2D shader for realtime palette swap + EB-like sine-based distorsions
#define PALETTE_SIZE 4
uniform float time = 0;
// Good old wave effect
uniform vec2 amplitude = vec2(0 / 128., 8/128.);
uniform vec2 speed = vec2(1., 2.);
uniform vec2 frequency = vec2(1, 3);
uniform float sampling_factor = 0.5;
uniform vec3 palette[PALETTE_SIZE+1];
uniform bool inverse = false;
@mnemnion
mnemnion / sparse.lua
Last active February 17, 2021 17:55
Sparse multidimensional tables in Lua
local Sparse = {}
local function new(dimension)
local sparse = {}
sparse._dimension = dimension
return setmetatable(sparse, Sparse)
end
function Sparse.__index(sparse, key)
if sparse._dimension == 1 then
@mnemnion
mnemnion / curry.lua
Created November 7, 2020 05:16
Simple currying in Lua, partial application
-- Simple currying module
--
-- With a bit of extra complexity, so that
-- currying several times gives only one
-- level of function indirection for up to
-- five parameters.
-- weak table to store a reference to the curried
-- function, with the parameters and original function
local _curried = setmetatable({}, { __mode = 'k' })
@1bardesign
1bardesign / conf.lua
Last active February 23, 2021 14:08
A little self-contained pomodoro timer for love2d
function love.conf(t)
t.window.width, t.window.height = 200, 60
t.window.x, t.window.y = 10, 10
t.window.borderless = true
t.window.title = "Pomodoro!"
end