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
/** | |
* Recursive shadowcasting algorithm. | |
* This algorithm creates a field of view centered around (x, y). | |
* Opaque tiles are treated as if they have beveled edges. | |
* Transparent tiles are visible only if their center is visible, so the | |
* algorithm is symmetric. | |
* @param cx - x coordinate of center | |
* @param cy - y coordinate of center | |
* @param transparent - function that takes (x, y) as arguments and returns the transparency of that tile | |
* @param reveal - callback function that reveals the tile at (x, 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
/* | |
* Your program must print string with the number of years and months and the total number of days between the dates. | |
* Dates are provided in dd.mm.yyyy format. | |
* You are not allowed to plug in JS libraries such as moment.js or date-fns directly into the code. All code need to be written in this file. | |
* | |
* Result must be shown as a string in years, months and total days. If years or months are 0, then it should not be displayed in the output. | |
* | |
* Example: | |
* Input: ['01.01.2000', '01.01.2016'] | |
* Output: |
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 newLineGradient (info = {}) { | |
const blur = info.blur | |
const size = info.size - 1 | |
const minCoordBlur = blur | |
const maxCoordBlur = size - blur | |
return function getValue (coord = Infinity) { | |
if (coord <= minCoordBlur) return 0 | |
if (coord >= maxCoordBlur) 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
function newFractalNoise (info) { | |
const { | |
noise, | |
octaves = 1, | |
amplitude = 1.0, | |
frequency = 1.0, | |
persistence = .5 | |
} = info | |
return function getFractalNoise (x, 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
var TWO_PI = 2 * Math.PI; | |
function processOptions(options) { | |
return { | |
amplitude: typeof options.amplitude === "number" ? options.amplitude : 1.0, | |
frequency: typeof options.frequency === "number" ? options.frequency : 1.0, | |
octaves: typeof options.octaves === "number" ? Math.floor(options.octaves) : 1, | |
persistence: typeof options.persistence === "number" ? options.persistence : 0.5 | |
}; | |
} | |
function makeCuboid(width, height, depth, noise3, options) { |
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
var NORM_2D = 1.0 / 47.0; | |
var NORM_3D = 1.0 / 103.0; | |
var NORM_4D = 1.0 / 30.0; | |
var SQUISH_2D = (Math.sqrt(2 + 1) - 1) / 2; | |
var SQUISH_3D = (Math.sqrt(3 + 1) - 1) / 3; | |
var SQUISH_4D = (Math.sqrt(4 + 1) - 1) / 4; | |
var STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1) / 2; | |
var STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1) / 3; | |
var STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) / 4; | |
var base2D = [ |
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 newGradient (info = {}) { | |
const blur = info.blur | |
const size = info.size - 1 | |
const minCoordBlur = blur | |
const maxCoordBlur = size - blur | |
return function getValue (x = Infinity, y = Infinity) { | |
const { coord } = [{ | |
coord: x, |
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
{ | |
"name": "oauth", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node index.js" | |
}, | |
"keywords": [], | |
"author": "Luca Tabone <taboneluca3@gmail.com>", |
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
{ | |
"files.eol": "\n", | |
"editor.tabSize": 2, | |
"window.zoomLevel": 1, | |
"git.autofetch": true, | |
"editor.rulers": [ 80 ], | |
"editor.cursorStyle": "block", | |
"window.commandCenter": false, | |
"editor.minimap.enabled": false, | |
"files.trimFinalNewlines": true, |
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
"*": | |
core: | |
telemetryConsent: "no" | |
editor: | |
fontSize: 17 | |
invisibles: {} | |
scrollPastEnd: true | |
showInvisibles: true | |
softWrap: true | |
tabType: "soft" |
NewerOlder