Increasing a counter every loop of a circle

Hello, I have this program that draws a curve from the centre of a circle to each point on the circumference and I want to increase a counter for each loop that it does. I am using cos and sin to get the coordinates of a unit circle. I know it has completed a loop when the x coordinate goes from positive to negative (and the y value is positive) but as my values never reach zero I can't use a simple if statement. Any ideas would be much appreciated.

submitted by /u/Zoe512
[link] [comments]

Help with inconsistencies with key presses?

Hello! I am very new to processing and am trying to apply different filters to an image based on what key is pressed. However the keys will either work or not work, somewhat randomly and I can't figure out why. Also, my edge detection algorithm will not get rid of the color, I have spent days trying to figure this and would really appreciate some help. Thanks! Code posted here: https://codeshare.io/G7YXlD

submitted by /u/hirohussain
[link] [comments]

[Help] Trying to show sin wave property but it is not matching up to an actual sin wave.

https://www.openprocessing.org/sketch/500702 I explained it poorly in the title but if you watch the animation go through you can see what i'm trying to show.

void setup() { size(1920, 1080); background(100); } int period = 1; float at = 0; //Moves the circle to the right and increments the trig angles int offset = 0; void draw() { color pink = color(255, 102, 204); color pink2 = color(255, 102, 0); color pink3 = color(255, 0, 0); background(100); noFill(); stroke(20); rect(0, 0, 1919, 1079); loadPixels(); translate(map(at, 0, 2*PI, 0, 1920)-250, height/2); //Moves the circle to the right sets it to mid screen -250 to offset by radius of the circle ellipse(0, 0, 500, 500); //draws circle that the other circle follows ellipse(250*cos(at), 250*sin(-at), 15, 15); //Moving circle that follows above circle for (int i=0; i%1921<1920; i++) { set(i, (int)map(-1*sin(map(i, 0, 1919, 0, 2*PI)), -1, 1, 0, 500)+height/4, pink); //Draws a sin wave } at+=PI/144; //increments position of the circle and angle of trig functions // // //set(i,map(cos(map(i,0,1919,0,2*PI)),-1,1,0,1079),pink2); //set(i,map(tan(map(i,0,1919,0,2*PI)),-1,1,0,1079),pink3); //qset(i,map(pow(sin(map(i,0,1919,0,2*PI)),1000),-1,1,0,1079),pink); //} } 
submitted by /u/CthulhuLies
[link] [comments]

[HELP] How do i get processing to take a picture when the space bar is pressed??

I have a limited amount of knowledge in processing, but I believe I should be able to wrap my head around how to code this with a little guidance!

I have downloaded the Video Library, and have worked out a way to get Processing to access my webcam.

I really need to be able to take a picture when the space bar is pressed. I do not even need to be displaying the webcam before, i simply need it to work like a camera.

My guess is that I would be using the keyPressed function along with the saveFrame function, but cannot quite work out how to code it all.

EDIT: This is my current code. I'm using the mouse rather than the spacebar in this example. It's probably all wrong so don't judge.

import processing.video.*; Capture video; void setup() { size(640,480); video = new Capture(this,640,480,30); video.start(); } void draw() { if (video.available()) { video.read(); } background(0); image(video,0,0); } int x = 0; void saveFrame() { background(204); if (mousePressed == true) { save("subFolder/file.jpg"); } else { noLoop(); } // Saves each frame as line-000001.png, line-000002.png, etc. saveFrame("line-######.png"); } 
submitted by /u/joecarlse
[link] [comments]