Skip to content

Instantly share code, notes, and snippets.

@GoToLoop
GoToLoop / PVector.js
Last active February 13, 2023 05:21
PVector Class Refactoring for PJS
//module.exports = function(options, undef) {
"use strict";
const TAU = 2 * Math.PI,
lerp = (start, stop, amt = 0) => +start + amt*(stop - start),
sq = n => n*n,
pjsCheck = obj => obj != null && 'noLoop' in obj,
argsErr = (mtd, len, min) => {
throw `Too few args passed to ${mtd}() [${len} < ${min}].`;
};
@GoToLoop
GoToLoop / NoRepeatIdInput.pde
Last active August 6, 2021 20:25
JavasScript's alert(), confirm(), prompt(), isNaN(), isFinite() and some few others as a Java class!
/**
* No Repeat ID Input (v2.1.1)
* by GoToLoop (2015/Sep/15)
*
* Forum.Processing.org/two/discussion/12532/
* windowjs-cross-mode-alert-confirm-prompt-other-js-api-for-java#Item_2
*
* Forum.Processing.org/two/discussion/869/check-array-contents-with-arraylist
*
* Studio.ProcessingTogether.com/sp/pad/export/ro.9$Bjf6i21oXBw
/**
* Keyboard Input Library
* Andrew Errity v0.2 (2015-Oct-01)
* GoToLoop v1.0.4 (2015-Oct-22)
*
* https://Forum.Processing.org/two/discussion/13175/
* do-whille-is-not-working-how-it-suppose-to#Item_12
*
* https://GitHub.com/aerrity/Inputs/blob/master/src/Inputs.java
* https://Gist.GitHub.com/GoToLoop/bba0c288aaeeb5ef9bb1
@GoToLoop
GoToLoop / resizeNN.js
Last active June 6, 2023 18:11 — forked from gncgnc/resizeNN.js
Extends p5.Image to handle nearest neighbor resizing for scaling images w/o blurring.
/**
* Resize the image to a new width and height using nearest neighbor algorithm.
* To make the image scale proportionally,
* use 0 as the value for the wide or high parameters.
* For instance, to make the width of an image 150 pixels,
* and change the height using the same proportion, use resize(150, 0).
* Otherwise same usage as the regular resize().
*
* Note: Disproportionate resizing squashes "pixels" from squares to rectangles.
* This works about 10 times slower than the regular resize.
@GoToLoop
GoToLoop / CircleMutualAttraction.pyde
Last active March 30, 2018 04:05 — forked from Speykious/CircleMutualAttraction
This is an example for the library Fisica for Processing in Python.
"""
CircleMutualAttraction (v2.3.8)
by Speykious (2017-Jun-27)
mod GoToLoop (2017-Jun-29)
https://Forum.Processing.org/two/discussion/23226/
new-python-example-for-the-fisica-library#Item_2
https://Gist.GitHub.com/GoToLoop/1861619991354ed7d063026658270689
"""
@GoToLoop
GoToLoop / Countdown.java
Last active April 13, 2018 13:43
Countdown Class (Java)
/**
* Countdown Class (v1.2.5)
* GoToLoop (2017/Aug/26)
*
* https://Forum.Processing.org/two/discussion/27733/
* countdown-class-library-for-java-js-python
*
* https://Forum.Processing.org/two/discussion/23846/
* time-delay-in-python-mode#Item_11
*
@GoToLoop
GoToLoop / CountdownClass.pyde
Last active April 13, 2018 15:14
Countdown Class (Python)
"""
Countdown Class (v1.2.5)
GoToLoop (2017/Aug/28)
Forum.Processing.org/two/discussion/27733/
countdown-class-library-for-java-js-python#Item_2
Forum.Processing.org/two/discussion/23846/
time-delay-in-python-mode#Item_14
@GoToLoop
GoToLoop / CountdownClass2.pyde
Last active April 13, 2018 15:13
Countdown Class II (Python)
"""
Countdown Class II (v1.2.5)
GoToLoop (2017/Aug/30)
Forum.Processing.org/two/discussion/27733/
countdown-class-library-for-java-js-python#Item_3
Forum.Processing.org/two/discussion/23846/
time-delay-in-python-mode#Item_17
@GoToLoop
GoToLoop / adjustFrame.js
Last active November 15, 2022 02:27
Expands Current iFrame Element to Fit Body's Size
'use strict';
function adjustFrameSize() {
if (frameElement) {
frameElement.height = frameElement.frameBorder = 0;
frameElement.height = getDocHeight() + 'px';
frameElement.width = getDocWidth() + 'px';
}
}
@GoToLoop
GoToLoop / CanvasResizeWatcher.java
Last active March 26, 2019 17:57
Canvas Resize Watcher
/**
* 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;