Skip to content

Instantly share code, notes, and snippets.

View niklas-may's full-sized avatar

Niklas May niklas-may

View GitHub Profile
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px,
);
@niklas-may
niklas-may / demo-tween.js
Last active December 27, 2021 11:37
Tween Function in Javascript with Easings
import tween, { easeOutQuart } from 'tween.js'
tween({
from: 0,
to: 3000,
duration: 2000,
easing: easeOutQuart,
onUpdate: (value) => value, // do some magic
})
@niklas-may
niklas-may / audio-handler.js
Last active April 29, 2021 12:48
Made to handle cancelable volume fading
export class AudioHandler {
constructor(element, options) {
this.element = element
this.isFading = false
this.fadeTimer = undefined
this.set(options)
}
play() {
this.element.play()
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
export default {
// no easing, no acceleration
linear: (t) => t,
// accelerating from zero velocity
easeInQuad: (t) => t * t,
@niklas-may
niklas-may / controlled-af.js
Last active April 29, 2021 08:23
Throttle requestAnimationFrame to a fixed number of calls per seconds (aka. define frames per second)
export default class ControlledAf {
constructor(step, fps = 60, immediate = false) {
this.step = step
this.fps = fps
this.raf = undefined
this.fpsInterval = undefined
this.startTime = undefined
this.now = undefined
this.then = undefined
3:55:54 PM: Build ready to start
3:55:58 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
3:55:58 PM: build-image tag: v3.3.2
3:55:58 PM: buildbot version: 0868ae15c7c4005fe7a69a665a5062b7f6293c2f
3:55:59 PM: Fetching cached dependencies
3:55:59 PM: Starting to download cache of 255.0KB
3:55:59 PM: Finished downloading cache in 135.41203ms
3:55:59 PM: Starting to extract cache
3:55:59 PM: Failed to fetch cache, continuing with build
3:55:59 PM: Starting to prepare the repo for build
@niklas-may
niklas-may / annotate-and-slice-images-for-print.sh
Last active May 2, 2019 11:47
Annotate webpage screenshots with their filename and create slices that perfectly fit an A4 landscape paper.
numFiles=$(ls -1q * | wc -l)
index=1
for file in *; do
echo "annotating ${index} of ${numFiles}: ${file}"
((index = index + 1))
convert $file -background black -fill white label:$file +swap -gravity Center -append $file
@niklas-may
niklas-may / fontGetTessellation.cpp
Last active December 14, 2017 20:39
openFrameworks - Load Font and getTessellation
// .h
ofTrueTypeFont myType;
vector <ofMesh> text;
// .cpp setup
myType.load("FONT-NAME.ttf", 100, true, false, true);
text.clear();
vector<ofTTFCharacter> path = myType.getStringAsPoints("TEXT");
for(int i = 0; i < path.size(); i++){