Toggle navigation
Explora
(current)
Aprende
Crea
Retos
×
Aspectos básicos
void main() {...}
for ( int i = 0 ; i < N ; i++ ) {...}
while (condición) {...}
do {...} while (condición);
if (condición) {...}
if (condición) {...} else {...}
switch (valor) {...}
Mostrar y pedir datos
print()
println()
readInteger()
readDouble()
readChar()
readString()
Funciones matemáticas
abs(n)
log(n)
sqrt(n)
pow(b,e)
floor(n)
ceil(n)
round(n)
sin(n)
cos(n)
tan(n)
asin(n)
acos(n)
atan(n)
random(n)
Funciones gráficas
point(x,y)
line(x1,y1,x2,y2)
ellipse(x,y,w,h)
rect(x,y,w,h)
triangle(x1,y1,x2,y2,x3,y3)
text(msg,x,y)
textWidth(msg)
textSize(n)
background(r,g,b,a)
strokeWeight(n)
stroke(r,g,b,a)
noStroke()
fill(r,g,b,a)
noFill()
image(url, x,y,w,h)
Nuevo
Ayuda
Probar
...
double getpopl(double last, double rate) { // Population is entered and returned in percentages // New percentage is calculated with the logistic function return rate*last*(1-last); } double tmp = 0.00037; double rt = 3.78; double normhash(double inp) { // Denormalizing double b = inp * 1000000000; // Squaring to hash it better b = b*b; // Modulo hashing return (b % 1235789) / 1235789; } double prand() { // Getting and updating population tmp = getpopl(tmp, rt); // Hashing population to get the random number double res = tmp; for (int i = 0; i < 4; i++) res = normhash(res); // Return value return res; } double rand(double min, double max) { return (prand()*(max-min))+min; } void main() { background(255); rt = 3.78; animate(draw); } double avgx1 = 160; double avgx2 = 160; double avgy1 = 160; double avgy2 = 160; double cnt1 = 0; double cnt2 = 0; void draw() { stroke(0); strokeWeight(1); line(160, 0, 160, 320); line(0, 160, 320, 160); //background(255); for (int i = 0; i < 100; i++) { stroke(0); strokeWeight(1); double x1 = rand(0, 320); double y1 = rand(0, 320); double x2 = random(0, 320); double y2 = random(0, 320); point(x1, y1); stroke(255, 0, 0); point(x2, y2); avgx1 += x1; avgx2 += x2; avgy1 += y1; avgy2 += y2; cnt1++; cnt2++; } strokeWeight(3); stroke(0, 255, 0); point(avgx1/cnt1, avgy1/cnt1); stroke(63, 63, 255); point(avgx2/cnt2, avgy2/cnt2); }
Canvas not supported.
Programado por
segfaultdev
0 votos
221 descargas
57 usos