Skip to content

Instantly share code, notes, and snippets.

/**
* 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 / PVector.js
Last active June 3, 2023 14:26
q5.Vector
"use strict";
for (const p of Object.getOwnPropertyNames(Math)) Q5[p] = Math[p];
function Q5(scope, parent) {
const
$ = this, M = Math,
{ _isObj, _isFun, _isNum, _isP5, _val, _argsErr } = Q5;
var
@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}].`;
};
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 / 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 / HackedMovie.java
Last active October 21, 2022 11:49
Hacked Movie EoS Event
/**
* Hacked Movie EoS Event (v2.1.0)
* by GoToLoop (2022-Oct-20)
*
* Gist.GitHub.com/GoToLoop/67023ba3e9ba1d0301c40f7c030d176a
*
* Discourse.Processing.org/t/hacked-movie-eos-event-library/39375
* Forum.Processing.org/two/discussion/14990/movie-begin-and-end-events#Item_1
*/
@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
@GoToLoop
GoToLoop / .block
Last active January 29, 2021 09:10
Get p5js Version
height: 200
scrolling: no
border: no
license: cc-by-4.0
@GoToLoop
GoToLoop / ArrayList_Shims.js
Last active November 6, 2020 03:49
ArrayList Polyfill Shims for JS Arrays
// 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