//Alternates b/w continuous and discontinuous patterns based on the state
40
// result = condition ? expression1 : expression2
41
// ((state == true) ? 1.0 : 1 )
42
43
44
culr=noise(x/(((state==true) ?1.0 : 1 )*fix*factor)+shiftX, y/(((state==true) ?1.0 : 1 ) *fix*factor)+shiftY, moveZ)*360; // note the "1", multiplying by all 'ints' keeps the value of (1 *fix*factor) an int,
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution ShareAlike
Archived Sketch
This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.
View Source Code
New Candy
Tunio
xxxxxxxxxx
float culr;
float Pculr;
float moveZ;
float score;
float Fscore;
int fix =100;
int factor =1;
boolean state = true;
int counter;
float shiftX = 0;
float shiftY = 0;
float Sx;
float Sy;
void setup() {
size(500, 500);
background(0);
colorMode(HSB);
frameRate(30);
}
void draw() {
background(0);
for (int x = 0; x < width; x = x + 25) {
for (int y = 0; y < height; y = y + 25) {
noStroke();
//if (state == true) {
//Alternates b/w continuous and discontinuous patterns based on the state
// result = condition ? expression1 : expression2
// ((state == true) ? 1.0 : 1 )
culr = noise(x/(((state == true) ? 1.0 : 1 )*fix*factor)+ shiftX, y/(((state == true) ? 1.0 : 1 ) *fix*factor)+ shiftY, moveZ)*360; // note the "1", multiplying by all 'ints' keeps the value of (1 *fix*factor) an int,
// thus producting discontinuos pattern of colors
fill(culr, 360, 360);
roundedRect(x+2.5, y+2.5, 20, 20, 10, 10);
}
}
// Pculr = noise(Sx/(1*fix*factor)+ shiftX, Sy/(1 *fix*factor)+ shiftY, moveZ)*360;
// fill(Pculr,255,255);
//strokeWeight(3);
// stroke(0);
// roundedRect(Sx+2.5, Sy+2.5, 20, 20, 10, 10);
// print(Sx);
// print("~~");
// println(Sy);
// print("::");
// println(score);
//score+= abs(Pculr - culr);
moveZ+=0.01; // increments the Z input of noise so that the pattern changes
// print(nf(score,7,2));
// print("~~~");
// println(millis());
// if ((millis()/1000)>10){
// background(0);
// fill(255);
// Fscore = score;
// println(Fscore);
// noLoop();
// }
}
void roundedRect(float x, float y, float w, float h, float rx, float ry) { //Code adapted from "cefnhoile", heres the link: https://forum.processing.org/topic/rounded-rectangle .
smooth();
beginShape();
vertex(x, y+ry); //top of left side
bezierVertex(x, y, x, y, x+rx, y); //top left corner
vertex(x+w-rx, y); //right of top side
bezierVertex(x+w, y, x+w, y, x+w, y+ry); //top right corner
vertex(x+w, y+h-ry); //bottom of right side
bezierVertex(x+w, y+h, x+w, y+h, x+w-rx, y+h); //bottom right corner
vertex(x+rx, y+h); //left of bottom side
bezierVertex(x, y+h, x, y+h, x, y+h-ry); //bottom left corner
endShape(CLOSE);
}
void mousePressed() { // changes the 'factor' and 'fix' vars using the bottom right rect ,
// bottom left rect, and rects of those two as buttons
if (mousePressed && mouseX>=480 && mouseY>=460 && mouseY<480) { // rect above bottom right
fix *=10;
}
if (mousePressed && mouseX>=480 && mouseY>=480 && fix !=1) { //bottom right
fix /=10;
}
if (mousePressed && mouseX<=20 && mouseY>=460 && mouseY<480) { // rect above bottom left
factor +=1;
}
if (mousePressed && mouseX<=20 && mouseY>=480 && factor !=1) { //bottom left
factor -=1;
}
}
void keyPressed() {
if (key == ' ') {
counter++;
}
if (counter%2 ==0) { //everytime the spacebar is pressed the states
//alternate b/w continuous and "blocky" color
state = true;
}
else {
state = false;
}
}
See More Shortcuts