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
| const renderTriangles = (triangles, options) => { | |
| options = { | |
| eye: [0, 1, 1], | |
| center: [0, 0, 0], | |
| mode: 'both', | |
| orbit: true, | |
| ...options | |
| } | |
| const wireframe = ([a, b, c]) => [a, b, b, c, c, a] |
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
| <canvas id="canvas" width="500" height="500"></canvas> | |
| <script> | |
| var mouseX = 0 | |
| var mouseY = 0 | |
| canvas.onmousemove = function (e) { | |
| mouseX = e.offsetX | |
| mouseY = e.offsetY | |
| } |
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
| <canvas id="canvas" width="500" height="500" style="border: 1px solid"></canvas> | |
| <script> | |
| var panX = 0 | |
| var panY = 0 | |
| var zoom = 1 | |
| draw() |
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 textBBox (text, attributes) { | |
| var ns = 'http://www.w3.org/2000/svg' | |
| var svg = document.createElementNS(ns, 'svg') | |
| var svgText = document.createElementNS(ns, 'text') | |
| for (var name in attributes) { | |
| svgText.setAttribute(name, attributes[name]) | |
| } | |
| svgText.textContent = text | |
| svg.appendChild(svgText) | |
| svg.style.position = 'fixed' |
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
| <script src="render.js"></script> | |
| <script> | |
| var a = 0 | |
| var b = 0 | |
| var c = function () { | |
| return a + b | |
| } | |
| function render (e) { | |
| if (e.type === 'input') { |
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
| <script> | |
| // Data abstracts storage | |
| let Data = { | |
| _count: 0, | |
| get count () { | |
| return Data._count | |
| }, | |
| set count (value) { | |
| Data._count = value | |
| } |
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 parseTokens (code) { | |
| return code | |
| .split(/([()]|"(?:\\.|[^"])*"|;[^\n]*|\s+)/) | |
| .filter(token => !/^;|^\s|^$/.test(token)) | |
| } | |
| function parseArray (tokens) { | |
| const array = [] | |
| if (tokens.shift() !== '(') { | |
| throw new Error(`Expected '('`) |
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 foo = function (match, offset) { | |
| return { tag: 'foo', offset: offset } | |
| } | |
| var bar = function (match, offset) { | |
| return { tag: 'bar', offset: offset } | |
| } | |
| var baz = function (match, offset) { | |
| return { tag: 'baz', offset: offset } |
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
| let __={},curry=_=>{let r=l=>(...e)=>{let t=l.map(_=>_===__?e.length?e.shift():__:_);return t.some(_=>_===__)?r(t):_.apply(null,t)};return r(Array(_.length).fill(__))};export{__,curry} |
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
| import { Flow } from '/path/to/flow.js' | |
| let num = new Flow(1) | |
| .map(x => x + 1) | |
| .map(x => x * 2) | |
| .map(x => x / 8) | |
| console.log(num.get()) |