Skip to content

Instantly share code, notes, and snippets.

View edap's full-sized avatar

Davide Prati edap

View GitHub Profile
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active May 3, 2024 08:26
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@gre
gre / easing.js
Last active April 30, 2024 04:58
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
# sleepy flower girl
(◡ ‿ ◡ ✿)
# y u no
ლ(ಠ益ಠლ)
# smiling breasts
(^人^)
# flipping tables
@jasonrudolph
jasonrudolph / about.md
Last active January 6, 2024 07:40
Programming Achievements: How to Level Up as a Developer

procedural mesh generation

Generates an algorithmic 3D OBJ file with ThreeJS and Node.js.

# print to stdout
node generate-mesh.js > test.obj

# write to file
node generate-mesh.js test.obj
@4poc
4poc / gist:c279d24157af06d12cbe
Last active June 23, 2022 09:53
GOZORK Text Adventure Game
/**
* GOZORK Text Adventure Game
* by apoc <http://apoc.cc>
*
* Inspired by the infamous beginning of Zork I.
* Reading the source will obviously spoil the game.
* The goal is to somehow kill the troll.
* Oh yeah and: This is my first GO program! Which would be
* my perfect excuse for the bad code quality1!
* Here is a solution/transcript:
@vanderlin
vanderlin / ofApp.cpp
Created August 5, 2019 18:19
Color Palette from image (OpenCV KMeans)
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
video.setDeviceID(0);
video.setup(320, 240);
}
//--------------------------------------------------------------
@datchley
datchley / es6-eventemitter.js
Last active June 7, 2021 03:40
A straight forward EventEmitter implemented in Javascript using ES6
let isFunction = function(obj) {
return typeof obj == 'function' || false;
};
class EventEmitter {
constructor() {
this.listeners = new Map();
}
addListener(label, callback) {
this.listeners.has(label) || this.listeners.set(label, []);
@Flexi23
Flexi23 / gist:1713774
Created January 31, 2012 23:27
GLSL 2D vector buffer in a texture with a custom floating point precision
/*
These are the helper functions to store and to restore a 2D vector with a custom 16 floating point precision in a texture.
The 16 bit are used as follows: 1 bit is for the sign, 4 bits are used for the exponent, the remaining 11 bit are for the mantissa.
The exponent bias is asymmetric so that the maximum representable number is 2047 (and bigger numbers will be cut)
the accuracy from 1024 - 2047 is one integer
512-1023 it's 1/2 int
256-511 it's 1/4 int and so forth...
between 0 and 1/16 the accuracy is the highest with 1/2048 (which makes 1/32768 the minimum representable number)
int seed = int(random(999999));
void setup() {
size(960, 960, P2D);
smooth(8);
pixelDensity(2);
rectMode(CENTER);
generate();