Skip to content

Instantly share code, notes, and snippets.

View attic-stuff's full-sized avatar
🎃
not eating canned air

attic-stuff attic-stuff

🎃
not eating canned air
View GitHub Profile
@attic-stuff
attic-stuff / poissondisc.gml
Last active April 12, 2025 21:06
generate an array of points using a blue noise distribution.
/**
* generates an array of blue noise points using poisson discs
* @param {real} width the width of the region of points
* @param {real} height the height of the region of points
* @param {real} radius the poisson disc radius, or space between each point
* @param {real} rejections the number of attempts made to generate a point before moving on
*/
function bluenoise(width, height, radius = 4, rejections = 30) constructor {
static sample = function(x, y) constructor {
@attic-stuff
attic-stuff / pp_outline.glsl
Last active April 1, 2025 02:19
post processing outline shader
/*
a simple outline shader that applies the outline to faces _and_ corners. this is a pp shader so
put everything u want outlined on a surface then apply the shader to the drawn surface
*/
//* vertex shader *//
attribute vec3 in_Position;
attribute vec2 in_TextureCoord;
@attic-stuff
attic-stuff / remap.gml
Last active June 23, 2025 01:46
remap a value from between two points to between two other points
/**
* remaps a value between 2 points to be a value between 2 other points.
* for example if you have a number between 0 and 10 and you want to remap it to be between 69 and 420
* you would do remap(number, 0, 10, 69, 420).
* @param {real} value the value to remap
* @param {real} old_min the lowest value in the starting range
* @param {real} old_max the highest value in the starting range
* @param {real} new_min the lowest value of the new range
* @param {real} new_max the highest value of the new range
* @returns {real}
@attic-stuff
attic-stuff / draw_a_big_arrow.gml
Last active May 15, 2023 14:40
draw a bigger arrow
/**
* draws an arrow with a variable width stem and pointy bobby bo diddly thingy
* @param {real} x1 x where the line for the arrow begins
* @param {real} y1 y where the line for the arrow begins
* @param {real} x2 x where the tip of the arrow ends
* @param {real} y2 y where the tip of the arrow ends
* @param {real} [size] the size of the thing; line is this width and triangle sides are size * 2.5
* @param {Constant.Color} [color] the color of the whole thing
*/
function draw_a_big_arrow(x1, y1, x2, y2, size = 1, color = c_white) {
@attic-stuff
attic-stuff / room_to_gui.gml
Last active May 15, 2023 14:40
convert room coordinates to gui coordinates
/**
* converts a room position to a gui position
* @param {real} x the x coordinate to convert to gui
* @param {real} [view] the view number. defaults to 0
*/
function room_x_to_gui(x, view = 0) {
return (x - camera_get_view_x(view_camera[view])) * (display_get_gui_width() / camera_get_view_width(view_camera[view]));
}
/**
* converts a room position to a gui position
@attic-stuff
attic-stuff / lerp_angle.gml
Last active May 15, 2023 14:41
linearly interpolate between two angles, taking the shortest distance.
/**
* interpolate between angles
* @param {real} a start
* @param {real} b end
* @param {real} i increment
* @returns {real}
*/
function lerp_angle(a, b, i) {
var n = a + angle_difference(b, a);
return lerp(a, n, i);