Skip to content

Instantly share code, notes, and snippets.

View 1bardesign's full-sized avatar

Max Cahill 1bardesign

View GitHub Profile
@1bardesign
1bardesign / license.txt
Last active June 7, 2023 23:43
prerelease basic profiler for lua, depends on batteries and uses lg as an alias for love.graphics - will be included in ferris at some point
Copyright 2023 Max Cahill
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
@1bardesign
1bardesign / export-layers.scm
Created April 30, 2023 12:20
script-fu to export all image layers from a gimp file to png
; export all (image) layers as separate pngs
; available in the layer menu
;
; Max Cahill 2023
; Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;
; recursive layer scan routine that pulls all layers out of the image into a list
; from https://gitlab.gnome.org/GNOME/gimp/-/issues/6761
@1bardesign
1bardesign / pixelart-pointers.md
Created March 23, 2022 23:53
tips and references for folks getting started with pixel art, and a little bit of philosphy too

This is a work in progress 🛠️

Pixel art

Pixel art is like art, but with pixels.

Generally the distinction is made at the point where the placement and colour relationships of individual pixels have a significant impact on the final piece, and where the artist is (or should be) concerned about optimising those relationships. This generally means both lower overall resolutions and lower colour counts, but there are many important works of pixel art that transcend those restrictions.

Pixel art and game art are often intertwined. Pixel art has long been used for game art because earlier systems had lower resolutions and lower colour counts, making a pixel art approach more important. It is important to understand, however, that the modern pixel art "movement" occurred significantly after those limited systems were mainstream, the modern understanding of pixel art has been developed in a reasonably post-hoc manner and the amount of academic interest in the movement is relatively tiny, with most of the folks

@1bardesign
1bardesign / oklab_snippet.glsl
Last active April 30, 2021 05:28
oklab to rgb and back for love2d glsl - see https://bottosson.github.io/posts/oklab/ - todo: polar coordinate mode
vec3 oklab_to_rgb(vec3 lab) {
float L = lab.x;
float a = lab.y;
float b = lab.z;
//
float l_ = L + 0.3963377774 * a + 0.2158037573 * b;
float m_ = L - 0.1055613458 * a - 0.0638541728 * b;
float s_ = L - 0.0894841775 * a - 1.2914855480 * b;
@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
@1bardesign
1bardesign / texture_utils.lua
Last active October 1, 2020 02:14
texture utilities including various downsamples, dilation, and blurring
--texture utilities
--todo: clean up and include in https://github.com/1bardesign/batteries
--[[
Copyright (c) 2020 Max Cahill
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@1bardesign
1bardesign / shader_try_send.lua
Created September 3, 2020 23:39
try to send a uniform to a shader without getting blocking errors when it's been optimised away
--[[
try to send a uniform to a shader
prints a warning once for the lifetime of the shader for missing uniforms
otherwise succeeds or fails silently
]]
do
local _warned = setmetatable({}, {__mode = "k"})
local function _warn(s, u)
local already_warned = _warned[s]
if not already_warned then
@1bardesign
1bardesign / metatable_example.lua
Created May 12, 2020 00:38
a heavily commented example of using metatables to implement class-like behaviour in lua
--define the example class table
local example_class = {}
--build the class metatable
--this is instructions to lua for what we want instances to do in certain circumstances
example_class.mt = {
--we only really care about the index metamethod
--this one says that if something is missing in the table this metatable is set on
--to go look in the example_class table
__index = example_class,
@1bardesign
1bardesign / matrix_utility.lua
Created March 30, 2020 23:01
Perspective projection and camera lookat functions for love2d
--[[
matrix utility functions for love2d
expects vec3 from https://github.com/1bardesign/batteries
]]
return {
calculate_perspective = function(screen, fov, near, far, into)
--everything we need
local aspect = screen[1] / screen[2];
@1bardesign
1bardesign / main.lua
Last active May 17, 2020 23:57
simplified hydraulic erosion on the gpu in love
--[[
"Hydrosion"
Simplified hydraulic erosion on the gpu in love
Some instabilities here and there but was a fun evening project to tackle
For Matt, hope it helps!
License: