This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * rounds a value to its nearest power of two neighbor | |
| * @param {real} n the value to round | |
| * @return {real} | |
| */ | |
| function round_pot(n) { | |
| return power(2, ceil(log2(n))); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function array_shuffle_hella(array) { | |
| var l = array_length(array); | |
| array_shuffle_ext(array); | |
| for (var i = 0; i < l; i++) { | |
| if (is_array(array[i]) == true) { | |
| array_shuffle_hella(array[i]); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function string_pewpewBOOMahhhhh(thing) { | |
| var count = string_length(thing); | |
| var bucket = array_create(count, ""); | |
| for (var i = 1; i <= count; i++){ | |
| bucket[i - 1] = string_char_at(thing, i); | |
| } | |
| return bucket; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * finds the point at which 2 line segments intersect using paul bourke's method | |
| * @param {real} x1 point 1 x | |
| * @param {real} y1 point 1 y | |
| * @param {real} x2 point 2 x | |
| * @param {real} y2 point 2 y | |
| * @param {real} x3 point 3 x | |
| * @param {real} y3 point 3 y | |
| * @param {real} x4 point 4 x | |
| * @param {real} y4 point 4 y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * test whether or not a channel exists within an animation curve | |
| * @param {asset.GMAnimCurve} curve the animation curve to check | |
| * @param {any} channel the channel index or name to evaluate | |
| * @return {bool} | |
| */ | |
| function animcurve_channel_exists(curve, channel) { | |
| var data = animcurve_get(curve); | |
| if (is_real(channel) == true) { | |
| return channel < array_length(data.channels); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function perlin(x, y, z) { | |
| static permutations = [ | |
| 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, | |
| 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, | |
| 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, | |
| 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, | |
| 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, | |
| 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, | |
| 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, | |
| 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * calculates the closest point on a line to a point not on that line and returns the distance between them | |
| * @param {real} px the point x | |
| * @param {real} py the point y | |
| * @param {real} x1 segment point 1 x | |
| * @param {real} y1 segment point 1 y | |
| * @param {real} x2 segment point 2 x | |
| * @param {real} y2 segment point 2 y | |
| * @returns {real} | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * converts a string hex color code into a usable decimal color number (#ffffff becomes c_white, etc). | |
| * if there is a chance this will receive an invalid string, uncomment the validation | |
| * @param {String} hexcode the hex color to convert in #nnnnnn form | |
| * @returns {Real} | |
| */ | |
| function hexcolor_convert(hexcode) { | |
| static hexadecimal_letter = { | |
| a: 10, b: 11, c: 12, d: 13, e: 14, f: 15, | |
| A: 10, B: 11, C: 12, D: 13, E: 14, F: 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * packs four color values, r g b and a, into a single unsigned 32 bit value | |
| * @param {real} r red value, 0 to 255 | |
| * @param {real} g green value, 0 to 255 | |
| * @param {real} b blue value, 0 to 255 | |
| * @param {real} a alpha value, 0 to 255 | |
| * @returns {real} | |
| */ | |
| function pack_colors(r, g, b, a) { | |
| return r + (g << 8) + (b << 16) + (a << 24); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * step function, returns 1 if value is higher than threshold, returns 0 otherwise | |
| * @param {real} t the threshold to compare our value to | |
| * @param {real} v the value being compared to threshold | |
| * @returns {real} 1 or 0 | |
| */ | |
| function step(t, v) { | |
| if (v > t) { | |
| return 1; | |
| } |