I’m just having a wild crash curse of processing (generative Design) at university. As we haven’t enough time, we are just learning to code with processing and not with p5js. Unfortunaly most of the example codes witch inspire me at the internet are for web processing. I found one that I really would like to work with and I want to ask if you might help me to translate it to orders for processing? I know that function is void for example and I know the lenguages are quiet similar, but for me as a absolut beginner it is to difficult to find the right translation for all “variables” for example. As the code is not to long you might could help me please? I would appreciate that a lot!!! Tank you!
The p5js-code:
var prevPos = {}
var pos = {}
var dir = 1
var radius = 1
var angle = 0
var pg
function setup() {
createCanvas(600, 600);
background(255);
prevPos = {x: width/2, y: height/2}
pos = {x: width/2, y: height/2}
strokeWeight(1)
}
function draw() {
angle += 1/radius*dir
pos.x += cos(angle) * radius
pos.y += sin(angle) * radius
if(get(round(pos.x), round(pos.y))[0] < 255 || pos.x < 0 || pos.x > width || pos.y < 0 || pos.y > height){
dir *= -1
radius = random(1, 20)
angle += PI * dir
}
line(prevPos.x, prevPos.y, pos.x, pos.y)
prevPos.x = pos.x
prevPos.y = pos.y
}
color c = get(round(pos.x), round(pos.y)); // get color from new position and use only red of RGB
if ( red(c) < 255 || pos.x < 0 || pos.x > width || pos.y < 0 || pos.y > height) { //
Hey, thank you for your advises!
I already tried on my one to advance through the reference in my understanding of processing and p5sj-codes, but as I am at the very beginning and I have only short time it is too complex. I’m just starting to manage a little bit of processing and it is very confusing for me to go directly over to p5sj and spend a lot of time to understand the translation thing.
The effect of the code I’m interested on is these one: https://www.openprocessing.org/sketch/624877
Hey thank you so much … incredible! That looks exactly like the original. I see what you mean with the if included in color c. I will copy the code to make him more understandable for me by changing things. Thank you so much for your help, great job!
And thanks for the advice, but it is just for praxis and understanding at university classes, I will not use it for any publication or other important thing.