Skip to content

Instantly share code, notes, and snippets.

View KrabCode's full-sized avatar

Jakub Rak KrabCode

  • Prague, Czech Republic
  • 20:59 (UTC +02:00)
View GitHub Profile
uniform sampler2D texture;
uniform vec2 resolution;
uniform float time;
#define pi acos(-1.)
// beautiful sdf visualisation from here: https://www.shadertoy.com/view/XsyGRW
vec3 draw_line(float d, float thickness) {
const float aa = 3.0;
return vec3(smoothstep(0.0, aa / resolution.y, max(0.0, abs(d) - thickness)));
float imageScale = 2;
private float time;
private int catCount = 3;
private ArrayList<Cat> cats = new ArrayList<Cat>();
private Cat held = null;
private PImage sticksIdle, sticksHeld, catHeld;
private PImage[] catDown, catRight, catUp;
int sticksFadeoutDelay = 60;
int sticksFadeoutDuration = 60;
float imageScale = 1;
private float time;
private int catCount = 12;
private ArrayList<Cat> cats = new ArrayList<Cat>();
private Cat held = null;
private PImage sticksIdle, sticksHeld, catHeld;
private PImage[] catDown, catRight, catUp;
int sticksFadeoutDelay = 60;
int sticksFadeoutDuration = 60;
int sticksLastReleasedFrame = - sticksFadeoutDuration*3;
int glyphRowsAndColumns = 19;
int resultGlyphSize = 10;
int glyphSize;
ArrayList<Glyph> glyphs = new ArrayList<Glyph>();
PImage sourceImage;
PGraphics pg;
boolean displayResult = true;
void setup() {
size(800, 800, P2D);
@KrabCode
KrabCode / Fireball.txt
Created June 6, 2020 18:13
put this in /data/gui/Fireball.txt in my Sketches project
STATE_BEGIN
UNDO
GROUP§Fireball§true
Fireball§record frames§0.0§100.0
Fireball§fade to black§1.3770002§25.5
Fireball§blur§1.1499996§10.0
Fireball§translate§100.0§0.0§0.0§0.0
Fireball§rotate§3.1415927§0.0§1.7592926§0.0
Fireball§axis§0.10000001§0.0§0.0§0.026970005
Fireball§speed§0.38999966§10.0
@KrabCode
KrabCode / GeneralRamp.pde
Created May 26, 2020 15:30
Adjustable color gradient with manual interpolation without using Processing's triangle strips.
void setup() {
size(800, 800, P2D);
}
void draw() {
float[] positions = new float[]{0, 0.25, 0.5, 0.55, 1};
int[] colors = new int[]{
color(0),
color(4, 38, 102),
color(255, 255, 255),
@KrabCode
KrabCode / Ramp.pde
Created May 26, 2020 15:15
Color gradient function with adjustable colors and color position.
void setup() {
size(800,800, P2D);
}
void draw() {
float[] positions = new float[]{0, 0.25, 0.5, 0.55, 1};
int[] colors = new int[]{
color(0),
color(4,38,102),
color(255,255,255),
PShape createSphere(float r, int detail) {
PShape res = createShape();
float deg5 = TWO_PI / 5f;
float deg6 = acos((1f + sqrt(5f)) / (5f + sqrt(5f)));
PVector top = new PVector(0, r, 0);
PVector[] sides = new PVector[5];
for (int i = 0; i < 5; i++) {
sides[i] = new PVector(
r * sin(deg6) * cos(deg5 * i),
r * cos(deg6),
void setup() {
size(800, 800, P2D);
background(0);
}
void draw() {
group("global"); //collapsible groups
background(picker("background", 0).clr()); // instead of the whole clr() you can query hue, sat, br and alpha separately in the 0-1 range
PVector translate = sliderXY("translate");
translate(translate.x, translate.y);
@KrabCode
KrabCode / ShaderTest.pde
Last active March 29, 2020 14:47
Reload your shaders on the fly with Processing using this code
void setup() {
size(600, 600, P2D);
}
void draw() {
float t = radians(frameCount);
String testShader = "frag.glsl";
uniform(testShader).set("time", t);
hotFilter(testShader);
}