Skip to content

Instantly share code, notes, and snippets.

@GoToLoop
GoToLoop / ArrayList_Shims.js
Last active Nov 6, 2020
ArrayList Polyfill Shims for JS Arrays
View ArrayList_Shims.js
// ArrayList Polyfill Shims for JS Arrays (v1.0.1)
// GoToLoop (2020/Nov/05)
// https://Gist.GitHub.com/GoToLoop/a74c5780667f2610097cfc007e53a559
"use strict";
// Add some useful Java list's methods to JS arrays as polyfills:
Object.defineProperties(Array.prototype, {
size: {
value() { // polyfill hack to add method size() to JS arrays
@GoToLoop
GoToLoop / MatrixFrameGL.py
Last active Aug 24, 2020
Push/Pop Limit Workaround (Python Mode)
View MatrixFrameGL.py
"""
* Push/Pop Limit Workaround (v1.0.5)
* GoToLoop (2020/Aug/22)
*
* Discourse.Processing.org/t/too-many-calls-to-pushmatrix/23411/9
* Gist.GitHub.com/GoToLoop/193d951ef13f212f09e2b2809efc4de0
"""
from processing.opengl import PGraphicsOpenGL
@GoToLoop
GoToLoop / MatrixFrameGL.java
Last active Aug 23, 2020
Push/Pop Limit Workaround (Java Mode)
View MatrixFrameGL.java
/**
* Push/Pop Limit Workaround (v1.0.1)
* GoToLoop (2020/Aug/22)
*
* Discourse.Processing.org/t/too-many-calls-to-pushmatrix/23411/8
* Gist.GitHub.com/GoToLoop/e35ac69e9bd4dbbcce557218c3b20588
*/
// Comment out the package statement below if it's inside a ".java" file:
package processing.core;
@GoToLoop
GoToLoop / .block
Last active Jan 29, 2021
Get p5js Version
View .block
height: 200
scrolling: no
border: no
license: cc-by-4.0
@GoToLoop
GoToLoop / .block
Last active Aug 10, 2020
Brownian Motion
View .block
height: 610
scrolling: no
border: no
license: cc-by-4.0
@GoToLoop
GoToLoop / .block
Last active Aug 10, 2020
Trailing Deque
View .block
height: 600
scrolling: no
border: no
license: cc-by-4.0
@GoToLoop
GoToLoop / .block
Last active Aug 28, 2019
Ramer–Douglas–Peucker Algorithm
View .block
height: 600
scrolling: no
border: yes
license: cc-by-4.0
View windowResized.global.js
function windowResized() {
const css = getComputedStyle(canvas.parentElement),
mw = float(css.marginLeft) + float(css.marginRight),
mh = float(css.marginTop) + float(css.marginBottom),
ww = float(css.width) || windowWidth,
wh = float(css.height) || windowHeight,
w = round(ww - mw), h = round(wh - mh);
resizeCanvas(w, h, true);
}
@GoToLoop
GoToLoop / CanvasResizeWatcher.java
Last active Mar 26, 2019
Canvas Resize Watcher
View CanvasResizeWatcher.java
/**
* Canvas Resize Watcher (v1.0)
* GoToLoop (2018/May/04)
* Developed on P3 (v3.3.5)
*
* https://Discourse.Processing.org/t/event-called-when-canvas-is-resized/6643/8
* https://Gist.GitHub.com/GoToLoop/1d1eb18f468a7d5758469707276b6ea1
*/
package gotoloop.listener;
@GoToLoop
GoToLoop / adjustFrame.js
Last active Sep 4, 2022
Expands Current iFrame Element to Fit Body's Size
View adjustFrame.js
'use strict';
function adjustFrameSize() {
if (frameElement) {
frameElement.height = frameElement.frameBorder = 0;
frameElement.height = getDocHeight() + 'px';
frameElement.width = getDocWidth() + 'px';
}
}