home
|
featured sketches
|
gallery
|
write a sketch
|
forum
|
Copy sketch
Printouts
//declaring varialbes needed int a = 0; void setup() { size(500,500); //background set so fills can later be matched for invisible squares background(200,200,200); } void draw() { //random colours set stroke(random(0,255),random(0,255),random(0,255)); //random length set a = random(200,375); //random lines placed line(0,0,250,a); line(500,500,a-100,225); line(0,500,a,225); line(500,0,225,a); line(0,250,200,a); line(250,0,a-50,250); line(250,500,a-50,250); line(500,250,250,a-25); //setting colours to make it invisible stroke(200,200,200); fill(200,200,200); //triangles are added to keep the lines neat, obscuring any that are out of line (pun unintended). triangle(0,0,0,250,150,225); triangle(0,500,0,250,150,325); triangle(0,0,250,0,190,152); triangle(0,500,250,500,195,358); triangle(250,500,500,500,290,357); triangle(250,0,500,0,290,150); triangle(500,0,500,250,350,205); stroke(0,0,0); //whole section commented due to being for debug //strokeWeight(2); //line(0,0,250,200); //line(0,0,250,375); //line(500,500,100,225); //line(500,500,275,225); //line(0,500,200,225); //line(0,500,375,225); //line(500,0,225,200); //line(500,0,225,375); //line(0,250,200,200); //line(0,250,200,375); //line(250,0,150,250); //line(250,0,325,250); //line(250,500,150,250); //line(250,500,325,250); //line(500,250,250,175); //line(500,250,250,350); //this area was removed because the lines are inaccurate, and these appear to have priority over the triangles. }
Sketches you submit on sketchPatch will be licensed under the
Creative Commons Attribution 3.0 Unported License
. If you upload code based on other people's work, please check the licence compatibility.
Click below to see an example
Get Started...
Copy this code into the text area to set up a basic sketch...
void setup() {
size(500,500);
}
void draw() {
background(200,30,90);
fill(20,40,150);
rect(100,100, 100,100);
}
Draw basic Shapes
Rectangle
Copy this code into the 'void draw ()' area of your code in the text area to draw a basic rectangle...
rect(100,100,100,100);
Triangle
Copy this code into the 'void draw ()' area of your code in the text area to draw a basic triangle...
triangle(30, 75, 58, 20, 86, 75);
Ellipse
Copy this code into the 'void draw ()' area of your code in the text area to draw a basic ellipse...
ellipse(56, 46, 55, 55);
Randomise
You can change how things look at random by using "random", all you need to do is specify the minimum and the maximum value you want.
Copy this code into the text area to randomly change the size and colour of your ellipse:
fill(random(0,255),20,200);
stroke(255,255,0);
ellipse(150, 150, random(10,150), 150);
Animate
You can animate your graphics by replacing numbers with "mouseX" , "mouseY" or "frameCount". In this example we change colors and shape size using the mouse:
background(20,30,mouseX);
fill(20,mouseY,150);
rect(100,100, 100,mouseX);
Drawing Tool
Copy this code into the 'void draw ()' area of your code to make a drawing tool...
fill(0,0,0);
noStroke();
ellipse(mouseX,mouseY, 2,2);
Then remove the line 'background();'
Repeat
You can repeat any piece of code by using a 'for loop'. A for loop changes a variable of a quantity you decide, until it reaches a number you want.
Example: add 10 each time to a variable called "i", until it gets to 200:
Copy this code into the text area to see a rectangle repeat across the sketch:
for (int i=0; i<200; i=i+10) {
rect(i,i, 100,100);
}
Ooops, found some glitches.
Write your sketch here
Check the Processing language
reference
(
most
of it works).
Need inspiration? Play with the examples in
the gallery
.
Title
Tags
Publish
(come on, let other people see your sketch!)
Your comments about the sketch
This idea and sketch was created when I wanted to do something.. different, and definetly different every time you looked at it.