I am working on a project building off of the pointillism example. I am starting the point size at 100 and reducing it to 1 to get a clear image and at each different point size I am saving the pictures so I can assemble them later to show the overall product evolution. Here is a picture of one I have done already:
I showed this to my school art teacher and he thought it would be a good project to put in our areas art show/competition, but I need to use a photo of my own so this monkey one can't be used.
Currently I have the code set up so when I hit space it saves the frame, resets the background, and reduces the point size by one. The problem is that waiting for each picture to finish and pressing space for each picture takes a lot of time. I would like to add to the code so it can decide if it's done on its own. Like maybe by detecting if there was still pixels from the original background present. I'm not sure how to do this though. Here is my current code:
PImage BlueJelly;
void setup() {
size(2117, 1601);
BlueJelly = loadImage("BlueJelly.JPG");
imageMode(CENTER);
noStroke();
background(255);
pointsize = 100;
}
int pointsize;
void draw() {
display();
if (pointsize < 1) {
noLoop();
}
}
void display() {
int x = int(random(BlueJelly.width));
int y = int(random(BlueJelly.height));
color pic_color = BlueJelly.get(x, y);
fill(pic_color, 128);
ellipse(x, y, pointsize, pointsize);
}
void keyPressed() {
if (key == ' ') {
saveFrame("PixBlueJelly"+pointsize+".JPG");
background(255);
pointsize -= 1;
}
}
The "BlueJelly" is referring to a jelly fish picture.
Any help or suggestions on this would be greatly appreciated!
I was looking through the basic learning topics and saw recursion and thought I would try adapting it so equilateral triangles would occur inside of one another.
Here is my code:
void setup() {
size(500, 500);
smooth();
}
void draw() {
translate(width/2, height/2);
background(255);
Triangles(0, -200, 173, 100, -173, 100, 3);
}
void Triangles(int x1, int y1, int x2, int y2, int x3, int y3, int level) {
The trouble with this is that if I make the number of levels more than 2 it wont work correctly. Can someone help me find the mistake I made in programming this? Thanks!
I made a brick breaker game that works pretty well besides a few problems with the ball and brick collisions. I have it set up so if the ball touches a brick just its y-speed will change, but I need it to be able to detect the sides of bricks also. I'm not quite sure how to do this though. I think booleans could work well, but I don't know how to set it up so just the sides or just the top and bottom are detected.
I'm in a computer programming class and one of our assignments was to make a quadratic formula solver and I found that really easy. I wanted to make it more difficult and give the user the ability to change the a, b, and c in the equation. Here is my code so you can see how it's set up currently.
I am trying to make a program that has a flock of geometric shapes following the mouse cursor and I found this forum thread:
Forum. It showed an example of how to make an object follow another by using trig and vectors, but
m.peres also says you could use the rotate function. How would you use the rotate function in order to do what I am wanting? Thanks!
I am making a random Shakespearian Insult Genorator and I am just making finishing touches to specify grammar differences in the first line. I want it to change from "an" to "a" according to words that start with vowels. Here is my code:
This part is the end of the code. I counted which adjectives would need the word "an" and made the following if statement.
void vowels() {
if (a == 0 || 12 || 20 || 21 || 42) {
text("You are an...", width/2, height/3);
} else {
text("You are a...", width/2, height/3);
}
}
After I test the program I get an error saying "The operator || is undefined for the argument types int." How can I fix this problem and still have the program work the way I would like it to?
I am practicing OOP because I am new to programming and I just finished working on a code that will create a randomly placed block that changes color when it hits a wall, but I can't figure out what the error is.
It says, "syntax error, maybe missing a right parenthesis." Any help or advice would be greatly appreciated.
I am very new to programming and am learning the basics. I made a block that bounces off of the walls and I wanted to make the color of the block randomly generate every time I clicked the mouse. I did some research and learned how to make the random color, but it will only work for my first click.
Here is my code:
int xspeed = 2;
int yspeed = 1;
float xpos;
float ypos;
float R = random(255);
float G = random (255);
float B = random (255);
void setup() {
fill(255, 150, 0);
size(600, 200);
noStroke();
smooth();
xpos = 20;
ypos = 20;
}
void draw() {
background (0);
xpos = xpos + xspeed;
if (xpos+20 > 600 || xpos-20 < 0) {
xspeed *= -1;
}
ypos = ypos + yspeed;
if (ypos+20 > 200 || ypos-20 < 0) {
yspeed *= -1;
}
rectMode(CENTER);
rect(xpos, ypos, 40, 40);
if (mousePressed) {
fill(R, G, B);
}
}
Any advice about this would be very much appreciated! Thanks!