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
| /** | |
| * 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); |
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 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 |
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
| /** | |
| * 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) { |
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
| /** | |
| * 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} |
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
| /* | |
| 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; |
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
| /** | |
| * 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 { |
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; | |
| } |
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
| /** | |
| * 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
| /** | |
| * 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} | |
| */ |
OlderNewer