Skip to content

Instantly share code, notes, and snippets.

View flamendless's full-sized avatar
🎯
Implementing backend tech the optimized and efficiently.

flamendless flamendless

🎯
Implementing backend tech the optimized and efficiently.
View GitHub Profile
@flamendless
flamendless / mana.lua
Created March 2, 2018 08:15
Progress Bar
local classic = require("modules.classic.classic")
local guiMana = classic:extend()
function guiMana:new()
self.max = 100
self.current = 100
self.percent = 1
self.x = game.gWidth/2 + 8
self.y = game.gHeight - 3
@flamendless
flamendless / Love2D-wiki-trimmer.lua
Created March 10, 2018 14:19
Love2D api/wiki trimmer (removes non-english .html files). Also useful for other batch deletion using lua and lfs.
--LOVE2D api/wiki trimmer
--Also useful for other batch deletion using lua and lfs
--Created by Brandon Blanker Lim-it @flamendless
local lfs = require("lfs")
local toRemove = {
"_deutsch",
"_portugu",
"_fran",
local Pswap = {}
local orig_pal
local new_pal
local image
local image2
local lookup = {}
function Pswap:load()
local orig_pal_data = love.image.newImageData("orig.png")
-- Create 256 shuffled numbers
local perm = {}
for i = 1, 256 do
table.insert(perm, math.random(#perm + 1), i)
end
-- Repeat the list
for i = 1, 256 do
perm[i+256] = perm[i]
end
@flamendless
flamendless / noise-to-image.lua
Created July 10, 2018 04:27
Save a noise to a texture! thanks Positive07
local data = love.image.newImageData(w, h)
data:mapPixel(function(x,y,r,g,b,a)
local a = love.math.noise(x, y)
return a, a, a, 1
end)
if isSaveIt then
data:encode("png", filename or "noise.png")
local image = love.graphics.newImage(data)
return image
else
@flamendless
flamendless / CircleTransformation.lua
Last active September 28, 2018 04:39
Interpolate a circle to another circle (number of points/2)
local processPoints = function(shape1, shape2)
local d = #shape1/#shape2 * 2
local all = {}
for i = 1, #shape1, 2 do
all[i] = false
if i % d == 1 then
all[i] = true
end
end
return all
@flamendless
flamendless / convert-to-grayscale.lua
Created October 16, 2018 13:01
Convert a palette .png (num of colours x 1 pixel) to appropriate grayscaled palette (for colour swap shader)
function love.load()
for k, file in pairs(love.filesystem.getDirectoryItems("source")) do
convert(file)
end
end
function convert(file)
local data = love.image.newImageData("source/" .. file)
local width = data:getWidth()
local div = 255/width
@flamendless
flamendless / main.lua
Created November 13, 2018 00:32 — forked from 1bardesign/main.lua
recolour.lua
--[[
example use
]]
local recolour = require("recolour")
--we want to recolour this asset image
local to_recolour = love.image.newImageData("path/to/image.png")
--using this palette image
local palette = love.image.newImageData("path/to/palette.png")
@flamendless
flamendless / shockwave.glsl
Created March 8, 2019 14:45
from steveroll over @ discord
extern number minRadius = 0.05;
extern number maxRadius = 0.1;
extern number mul = 0.01;
extern vec2 center = vec2(0.5,0.5);
number dist(vec2 a, vec2 b){
return sqrt(pow(b.x-a.x,2)+pow(b.y-a.y,2));
}
package midisequenceextractor;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiChannel;