Skip to content

Instantly share code, notes, and snippets.

View KrabCode's full-sized avatar

Jakub Rak KrabCode

  • Prague, Czech Republic
  • 22:14 (UTC +01:00)
View GitHub Profile
int sketchWidth = 600;
int sketchHeight = 600;
int rulerWidth = 400;
int rulerHeight = 375;
float waveHeight = 200;
float waveHeightHalf = waveHeight / 2;
int xLeft = sketchWidth / 2 - rulerWidth / 2;
int xRight = sketchWidth / 2 + rulerWidth / 2;
import java.util.Date;
int sketchWidth = 600;
int sketchHeight = 600;
int rulerWidth = 400;
int rulerHeightOuter = 130;
float rulerHeightInner = 130;
float waveHeight = 200;
float waveHeightHalf = waveHeight / 2;
// see https://www.redblobgames.com/grids/hexagons/
float size = 1000/24;
float w = size*2;
float h = sqrt(3)*size;
float xStep = w*(3/4f);
float yStep = h;
int xCount;
int yCount;
@KrabCode
KrabCode / PowderToy.pde
Created September 13, 2021 15:48
Working powder toy with a simple material picker for APDE.
// Should work on APDE
// Based on a GDC talk called "Exploring the Tech and Design of Noita"
// https://www.youtube.com/watch?v=prXuyMCgbTc
private PGraphics pg;
float scale = 0.075f;
float prevScale = scale;
float rectWidth, rectHeight;
@KrabCode
KrabCode / NoitaPhysics.pde
Created September 11, 2021 18:24
sorry for misleading naming in "water", it behaves like sand instead
float[][] grid;
float[][] temp;
float scale = 0.12;
int w, h;
boolean add = false;
float touchSize = 10;
void setup() {
fullScreen();
colorMode(HSB,1,1,1,1);
@KrabCode
KrabCode / blur.glsl
Created September 24, 2020 18:26
adjustable blur shader
// From the PostFX library for Processing, put this file into the data folder in the sketch folder
// Adapted from:
// <a href="http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html" target="_blank" rel="nofollow">http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html</a>
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
void setup() {
size(800, 800, P2D);
}
void draw() {
float t = radians(frameCount);
int detail = 50;
float whiteRadius = 150+150*sin(t);
float redRadius = 350;
background(0);
@KrabCode
KrabCode / LiveShader.pde
Created August 11, 2020 19:25
Reload shaders at runtime
import static java.lang.System.currentTimeMillis;
void setup() {
size(600, 600, P2D);
}
void draw() {
float t = radians(frameCount);
String testShader = "frag.glsl";
uniform(testShader).set("time", t);
STATE_BEGIN
UNDO
GROUP§ChaosField_2§true
GROUP§global§true
global§noise speed§0.7265625§10.0
global§background§vertical§rgb lerp§0.0§true§0.8394117§1.0§0.596875§1.0§1.0§true§0.8394117§1.0§0.596875§1.0§
global§stroke§0.0§0.0§0.0§1.0§1.0
global§weight (< 2)§2.9039063§10.0
global§grid count§10.000319§100.0
global§color speed§1.0000012§100.0
private float imageScale = 2;
private final int maxCatCount = 12;
private final int maxChunkCount = 1000;
private float time;
private final ArrayList<Cat> cats = new ArrayList<Cat>();
private final ArrayList<Cat> catsToRemove = new ArrayList<Cat>();
private final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
private final ArrayList<Chunk> chunksToRemove = new ArrayList<Chunk>();
private Cat held = null;