Drawing a certain number of circles, and other issues with draw()

I need to create a program that draws 100 circles at random locations with random radii. I'm struggling to work out how to get it to stop drawing after 100 under the draw() function. I'm fairly new to this sort of stuff. Here is my current code:

void setup() { size(500,500); background(0); frameRate(30); } void draw() { for (int i = 0; i < 30; i++) { int radius = int(random(1, 30)); int ellipseX = int(random(0 + radius, width - radius)); int ellipseY = int(random(0 + radius, height - radius)); fill(255,100); noStroke(); ellipseMode(RADIUS); ellipse(ellipseX, ellipseY, radius, radius); } } 

In this program, I also need to draw a vertical red line that sweeps across the sketch from left to right, and as it touches a circle, they start to move with the line. When the line reaches the end of the sketch, the program must draw a new set of 100 random circles, and the line sweeps back from right to left and drags the new circles.

I'd really appreciate any help or advice with either issue.

submitted by /u/hi-i-need-advice
[link] [comments]

Drawing a certain number of circles, and other issues with draw()

I need to create a program that draws 100 circles at random locations with random radii. I'm struggling to work out how to get it to stop drawing after 100 under the draw() function. I'm fairly new to this sort of stuff. Here is my current code:

void setup() { size(500,500); background(0); frameRate(30); } void draw() { for (int i = 0; i < 30; i++) { int radius = int(random(1, 30)); int ellipseX = int(random(0 + radius, width - radius)); int ellipseY = int(random(0 + radius, height - radius)); fill(255,100); noStroke(); ellipseMode(RADIUS); ellipse(ellipseX, ellipseY, radius, radius); } } 

In this program, I also need to draw a vertical red line that sweeps across the sketch from left to right, and as it touches a circle, they start to move with the line. When the line reaches the end of the sketch, the program must draw a new set of 100 random circles, and the line sweeps back from right to left and drags the new circles.

I'd really appreciate any help or advice with either issue.

submitted by /u/hi-i-need-advice
[link] [comments]

Windchill formula and output help please!!

Totally new to coding and I have a project I'm working on I have to create an output on processing that reads something like if the temperature is -5°F and the wind speed is 15mph the wind chill is ..... this is what I have so far can anyone help?

size(860, 500); background (255,153,0); String s = "When the temperature is -5°F."; String x = "and the wind speed is 15mph."; String textSize(50); text(s, 10, 200); println(s, x); float windChill; float T = -5; float V = 15; windChill = (35.74 + 0.6215*T) - (35.75*pow(V,0.16)) + (0.4275*T*pow(V,0.16)); println(windChill); 
submitted by /u/archemides
[link] [comments]

Using Scanner class in Processing 3.4? I can’t get it to allow me to input.

Hi, I'm a pretty inexperienced coder and was struggling with the scanner class for my final project. Here's the code. Why is the scanner class not working? I tried using a input.close() and it didn't change anything. I even switched to keyPressed() and key and that was horrible. Also, the code is definitely not complete. Any advice helps!!

import java.util.Scanner; Words words; Man man; void setup() { size(400, 400); background(240); man = new Man(); words = new Words(); } void draw() { man.manDisplay(); } { Scanner input = new Scanner(System.in); System.out.print("Play Game? Type 1."); int start = input.nextInt(); if (start == 1) { boolean inWord; String pickedLetter= input.nextLine(); String pickedWord = words.wordsList[(int)(Math.random()*(words.wordsList.length))]; //arraylist System.out.println("Welcome to Hangman - You must find the word before you pick 7 wrong letters!"); if (pickedWord.indexOf(pickedLetter) !=-1) { inWord =true; } inWord = false; if (inWord == true) { } System.out.print(pickedLetter +" is not in " + pickedWord +"."); System.out.println("You lose!...And so does he :("); } } 
submitted by /u/Amazinc
[link] [comments]

Need help with a relatively simple ‘connect the dots’ program

I need to write a program that draws 'dots' and each subsequent dot is connected by a line. I've done this successfully (I think) but I also need to add some keyboard functions to it, such as:

press 'n' - connects the last dot drawn to the first dot drawn to close the shape, and then the next sequence of dots drawn will be a new series of dots/lines.

press 'e' - ends the current sequence without closing the shape (i.e. connecting first dot to last dot). Again, next sequence of dots draw will be a new, separate series.

press 'r' - resets the canvas completely

My current code:

int lastX; int lastY; int initialX; int initialY; int pointsDrawn = 0; void setup() { size(500,500); background(255); } void draw() { } void mouseClicked() { if (key == 'c') { line(lastX, lastY, initialX, initialY); } if (pointsDrawn == 0) { ellipse(mouseX, mouseY, 1, 1); pointsDrawn++; lastX = mouseX; lastY = mouseY; initialX = mouseX; initialY = mouseY; } else if (pointsDrawn >= 1) { ellipse(mouseX, mouseY, 1, 1); stroke(2); line(lastX, lastY, mouseX, mouseY); lastX = mouseX; lastY = mouseY; pointsDrawn++; } } 

I'd really appreciate some advice or direction. Thanks!

submitted by /u/hi-i-need-advice
[link] [comments]

How can I reset a canvas to its original state, without stopping the program from running?

I’m fairly new to Processing and I’ve been tasked with making a relatively simple game. I’m currently stuck with how I can create a sort of ‘Game Over’ scenario wherein the player runs out of lives and the game displays a ‘Game Over’ screen before returning to the start screen. Would really appreciate any advice or if someone can point me in the right direction.

submitted by /u/hi-i-need-advice
[link] [comments]

Programming for Artists

Privacy Statement