Skip to content

Instantly share code, notes, and snippets.

@KrabCode
Created November 14, 2023 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrabCode/63ba399ad2501ab708652b456ba82025 to your computer and use it in GitHub Desktop.
Save KrabCode/63ba399ad2501ab708652b456ba82025 to your computer and use it in GitHub Desktop.
import com.krab.lazy.*;
LazyGui gui;
PFont font;
int fontSize = -1;
void setup() {
fullScreen(P2D, 0);
gui = new LazyGui(this, new LazyGuiSettings()
.setLoadLatestSaveOnStartup(true)
);
lazySetFont(20);
}
void lazySetFont(int size) {
if (fontSize != size) {
font = createFont("JetBrainsMono-Regular.ttf", size);
fontSize = size;
}
}
void draw() {
gui.pushFolder("grid");
background(gui.colorPicker("background", color(36)).hex);
stroke(gui.colorPicker("foreground", color(100)).hex);
strokeWeight(gui.slider("weight", 3));
float step = gui.slider("step", 50);
PVector size = gui.plotXY("size", width*1.2, height*1.2);
PVector offset = gui.plotXY("offset");
for (float x = -size.x + offset.x; x < size.x; x+= step) {
for (float y = -size.y + offset.y; y < size.y; y+= step) {
point(x, y);
}
}
gui.popFolder();
gui.pushFolder("text");
PVector rectPos = gui.plotXY("rect pos", 250);
PVector rectSize = gui.plotXY("rect size", 150);
fill(gui.colorPicker("rect fill", 0).hex);
stroke(gui.colorPicker("rect stroke", 100).hex);
strokeWeight(gui.slider("rect weight", 3));
float cornerRadius = gui.slider("corner radius");
rect(rectPos.x, rectPos.y, rectSize.x, rectSize.y, cornerRadius);
String textDefault = "Among those who devote themselves to the transmutation of metals,"+
"\nhowever, there can be no such thing as mediocrity of attainment."+
"\nA person who studies this Art, must have either everything or nothing."+
"\nAn Alchemist who knows only half their craft, reaps nothing but disappointment"+
"\nand waste of time and money; moreover, they lay themselves open to the mockery"+
"\nof those who despise our Art. Those, indeed, who succeed in reaching the goal"+
"\nof the Magistery, have not only infinite riches, but the means of continued"+
"\nlife and health. Hence it is the most popular of all pursuits.";
fill(gui.colorPicker("text color", color(160)).hex);
PVector pos = gui.plotXY("text pos");
translate(pos.x, pos.y);
textAlign(LEFT, TOP);
lazySetFont(gui.sliderInt("text size", fontSize));
textFont(font);
text(textDefault, 0, 0);
gui.popFolder();
}
@KrabCode
Copy link
Author

image

@KrabCode
Copy link
Author

5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment