Skip to content

Instantly share code, notes, and snippets.

View DoctorGester's full-sized avatar

Kirill Artemov DoctorGester

View GitHub Profile
local ffi = require "ffi"
ffi.cdef [[
typedef struct {
float x;
float y;
} vector;
]]
local storage_size = 8096
function rewrite_sprite_sheet_with_extruded_borders(file_name, sheet_columns, sheet_rows)
local source_data = love.image.newImageData("resources/" .. file_name)
local padding = vector(2, 2)
local sprite_size = vector(source_data:getWidth() / sheet_columns, source_data:getHeight() / sheet_rows)
local target_container_size = sprite_size + padding
local output = love.image.newImageData(sheet_columns * target_container_size.x, sheet_rows * target_container_size.y)
for column = 0, sheet_columns - 1 do
function frame_scrollbar(content_height)
local frame = get_current_frame()
local frame_origin = get_frame_origin()
local frame_size = get_frame_size()
local frame_height = frame_size.y
local scrollbar_height_relative = frame_height / content_height
if scrollbar_height_relative >= 1 then
return
end
bool mat4_invert(mat4& m, mat4& inv) {
double det;
inv.m11 = m.m22 * m.m33 * m.m44 -
m.m22 * m.m34 * m.m43 -
m.m32 * m.m23 * m.m44 +
m.m32 * m.m24 * m.m43 +
m.m42 * m.m23 * m.m34 -
m.m42 * m.m24 * m.m33;
#include <chrono>
const int total_objects = 10000;
int group_identifiers[] = {
123,
20,
3,
41,
5893,
#include <chrono>
struct Object {
int property_to_sort_by;
int property_to_group_by;
};
int compare_objects(const void* a, const void* b) {
Object* left = (Object*) a;
Object* right = (Object*) b;
Folder_Color* string_to_folder_color(String string) {
static Folder_Color None(0, 0xff555555, 0);
static Folder_Color Purple1(0xFFE1BEE7, 0xff8e24aa, 0xffeecbf4);
static Folder_Color Purple2(0xFFCE93D8, 0xff8e24aa, 0xffe4a8ee);
static Folder_Color Purple3(0xFFBA68C8, 0xfff3e5f5, 0xffcb75da);
static Folder_Color Purple4(0xFF8E24AA, 0xfff3e5f5, 0xffa637c5);
static Folder_Color Indigo1(0xFFD1C4E9, 0xff5e35b1, 0xffddd0f5);
static Folder_Color Indigo2(0xFFB39DDB, 0xff5e35b1, 0xffc7b0ef);
static Folder_Color Indigo3(0xFF9575CD, 0xffede7f6, 0xffa281dd);
static Folder_Color Indigo4(0xFF5E35B1, 0xffede7f6, 0xff7146ca);
static u32 color_name_to_color_argb(String &color_name) {
char c = *color_name.start;
switch (color_name.length) {
// Red
case 3: return 0xFFE91E63;
case 4: {
if (c == 'B'/*lue*/) return 0xFF2196F3; else
if (c == 'G'/*ray*/) return 0xFF9E9E9E;
const naive_search_index = [];
for (let folder of folders) {
naive_search_index.push({
name: folder.title.toLowerCase(),
id: string_id_to_number(folder.id)
});
}
variables (
Bool "Is in a race" False
Bool "Just finished racing" False
Bool "Already tried racing" False
Number "Race start time" 0
Number "Race result time" 0
)
trigger "Race start" (
description ""