Skip to content

Instantly share code, notes, and snippets.

@RandyGaul
RandyGaul / edge_interesections.cpp
Last active November 15, 2022 15:18
Calculate edge-edge intersections of convex polygons via Sutherland-Hodgman in 2D
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
#include <vector>
// -------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <assert.h>
struct item_t
{
int key;
int val;
};
int get_byte(int val, int byte_index)
@RandyGaul
RandyGaul / tiles_to_frames.lua
Created January 13, 2021 22:43
Aseprite Script for converting a square grid of tiles into individual Aseprite frames
-- Splits a sprite upon a grid into individual frames.
-- This file should go into your Aseprite scripts folder.
-- Aseprite -> File -> Scripts -> Open Scripts Folder
local dialog = Dialog("Split Tiles to Layers")
dialog:label{ id="help", label="", text="Set the width and height to split tiles by:" }
dialog:number{ id="tile_w", label="Tile Width:", text="8", focus=true }
dialog:number{ id="tile_h", label="Tile Height:", text="8" }
dialog:button{ id="ok", text="&OK", focus=true }
dialog:button{ text="&Cancel" }
@RandyGaul
RandyGaul / embed.c
Last active September 26, 2022 22:09
Embeds a file as a byte array in C
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc < 3) {
printf("Usage: embed <filename> <symbol>\n"); return -1;
}
const char* path = argv[1];