Skip to content

Instantly share code, notes, and snippets.

@andymasteroffish
Created May 27, 2021 19:57
Show Gist options
  • Save andymasteroffish/df9c1cdd46a2c13dd1bdb39374d44415 to your computer and use it in GitHub Desktop.
Save andymasteroffish/df9c1cdd46a2c13dd1bdb39374d44415 to your computer and use it in GitHub Desktop.
Source code for a plotter drawing based on a @Hau_kun tweet
// Original tweet by @Hau_kun
// https://twitter.com/Hau_kun/status/1397547848015638532
// Made in openFrameworks
// Using ofGCode
// https://github.com/andymasteroffish/ofxGCode
void ofApp::setup(){
ofxGCode gcode;
ofBackground(5);
float noise_seed = 0;
gcode.setup();
gcode.demo_col.set(255);
for(float y=0;y<780;y+=60){
for(float x=0;x<780;x+=60){
//rectangle
vector<ofVec2f> rect;
rect.push_back(ofVec2f(x-25,y-25));
rect.push_back(ofVec2f(x+25,y-25));
rect.push_back(ofVec2f(x+25,y+25));
rect.push_back(ofVec2f(x-25,y+25));
//draw it
gcode.polygon(rect);
//make some circle lines
float noise_zoom = 0.011;
for(int i=16; i>0; i--){
float R=ofNoise(x*noise_zoom,y*noise_zoom, noise_seed)*18 + (int)(i/8) * PI;
ofVec2f center;
center.x = x+cos(R)*45;
center.y = y+sin(R)*45;
vector<ofVec2f> pnts = ofxGCode::get_circle_pnts(center,(i*9)/2, 70);
vector<GLine> lines = ofxGCode::pnts_to_lines(pnts, true);
lines = ofxGCode::trim_lines_outside(lines, rect);
gcode.add_lines(lines);
}
}
}
gcode.sort();
gcode.save("hau_kun.nc");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment