I’m new to the Processing, and I have a background in pyhton. I used to make patterns with python, but now I need something better. I’m having trouble finding examples of processing in python, but I have found many codes like this.
Can someone rewrite this (it doesn’t have to be this one, provide any other) code in processing and python processing? It would help me to compare differences and to learn.
As @GoToLoop has pointed out, this is JavaScript (p5.js) code. Any JavaScript guide for Python programmers will prove helpful to you. But – nobody actually writes JavaScript like this unless they’re trying to cram it into a single tweet (and I’m assuming you might have found this on Twitter?). In any other context, it’s bad practice.
Here’s a Python translation. Note that I haven’t crammed it all into a single line, although I could have (in addition to adding other tricks to abbreviate it at the expense of readability) –
w, f = 640, 0
def setup():
size(w, w)
stroke(36, 28, 24)
background(255)
fill(5, 6, 3)
def draw():
global f
blendMode(DIFFERENCE)
if f < 90:
beginShape()
for i in range(-2, 642):
curveVertex(i*2, 200+f*6-320*noise(i/100., f))
curveVertex(w, w)
curveVertex(0, w)
curveVertex(-w, w)
endShape()
f += 1
The Processing IDE includes a bunch of Python Mode examples (File > Examples), and there are other collections of Python sketches online – to list a few: