Skip to content

Instantly share code, notes, and snippets.

View WilliamLivingood's full-sized avatar

WilliamLivingood

View GitHub Profile
@WilliamLivingood
WilliamLivingood / gist:f0702472e0b0747350ec1c3e6b806d15
Created September 24, 2025 05:51
Processing Code to Draw a Snowflake
import processing.svg.*;
// paramater
final int canvas_size = 1000;
final String out_file = "snowflake.svg";
final int num_sides = 10;
final float outer_radius = 350;
final float hub_radius = 40;
@WilliamLivingood
WilliamLivingood / gist:2048c9aff397fe047af4cb999dbb889b
Created September 24, 2025 05:58
Code for Computer Generation of a Galaxy
import Turtle.*;
Turtle turtle;
void setup() {
size(900, 900);
noLoop();
colorMode(HSB, 360, 100, 100);
background(0);
@WilliamLivingood
WilliamLivingood / gist:2705e0f2af053ea5818ca4ca32d4e415
Created September 24, 2025 06:10
Processing Code to Generate a Flower (rose)
import Turtle.*;
import processing.svg.*;
Turtle t;
void setup() {
size(1050, 1050);
noLoop();
}
import Turtle.*;
Turtle t;
void setup() {
size(250, 600);
background(0);
stroke(255);
noLoop();
t = new Turtle(this);
@WilliamLivingood
WilliamLivingood / gist:aeed7f996bf648e5a2ecc1f69b8c5b83
Created October 6, 2025 01:27
L1Assignment w/ ToDos Adressed
// The main processing sketch for running the L1Assignment code
// Handles incrementing/decrementing the iterations using keyPress events ('m' & 'n')
// Output can be saved by pressing 's'.
// @author: @mriveralee
// Note: This sketch uses the Turtle library which can be downloaded from
// https://github.com/leahbuechley/Turtle
import processing.svg.*;
import processing.pdf.*;
import Turtle.*;
// This is an implementation of an L-System that extends the class
// "BaseLSystem", which makes it easy to make new types of LSystems (e.g., probabalistic)
// without repeating lots of code.
// It assumes all input vocabulary not given a rule are constants.
// Though you could give an explicit rule for a constant using "F" --> "F"
// It contains a StringBuffer (currentIterationBuffer) that should be used
// to handle production rules when computing the currentIteration string as part of iterate
// in order avoid wasteful creation of strings and memory problems.
// The StringBuffer is used in the iterate method of the LSystem.
// @author: @mriveralee
LSystem desy1() {
float moveDist = 36;
float rotateAngle = 50;
float scaleFactor = 1.8;
String axiom = "F";
// Create any production rules
HashMap<Character, String> rules = new HashMap<>();
rules.put('F', "F[+F]F[-F]F+F--F+F[-F]");
@WilliamLivingood
WilliamLivingood / gist:8ee0241e971bf00ab29336b38f142e7e
Created October 6, 2025 03:52
LSystem design 2 / flower thing
LSystem desy2() {
float moveDist = 44f;
float rotateAngle = 25.7f;
float scaleFactor = 2.8f;
String axiom = "X";
HashMap<Character, String> rules = new HashMap<>();
// NOTE: no spaces in the strings:
rules.put('X', "F[+X][-X]FX");
rules.put('F', "FF");
@WilliamLivingood
WilliamLivingood / gist:bffeb2e7db634ce52ad0c5f5c66aa512
Created October 6, 2025 05:31
Random Length, Angle, and Systems
LSystem desy3() {
float moveDist = random(10, 40);
float rotateAngle = random(20, 60);
float scaleFactor = 1.9f;
String axiom = "F";
// Create any production rules
HashMap<Character, String> rules = new HashMap<>();
String[] produc = new String[] { "FF-[-F+F]F+[+F-F]F", "F+F--F+F[+F-F]", "F+F--F+F[-F][+F]F" };
rules.put('F', produc[(int) random(produc.length)]);
"""
This file contains parameters, helpers, and setup to
create a basic gcode generation algorithm from line segments.
The main
Inputs:
lines: the line segments to be converted into gcode commands for extrusion
nozzle_diameter: the diameter of the 3D printer's nozzle
filament_diameter: the diameter of the 3d printing filament