Advertisement
EmanueleBonin

Henon 1 p5js

Apr 30th, 2020
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DimX=800
  2. DimY=800
  3. Zoom=0.7
  4. Angle=1.11
  5. function setup() {
  6.   createCanvas(DimX, DimY);
  7. }
  8.  
  9. function draw() {
  10.   background(220);
  11.  
  12.   a=Angle
  13.   y=0
  14.   sn=sin(a)
  15.   cs=cos(a)
  16.   xi=-1.2
  17.   xf=1.2
  18.   yi=-1.2
  19.   yf=1.2
  20.   sx=(xf-xi)/(DimX*Zoom)
  21.   sy=(yf-yi)/(DimY*Zoom)
  22.   cl=0
  23.   for(xc=xi; xc<xf;  xc=xc+sx){
  24.       y=xc
  25.       x=xc
  26.       i=1
  27.       while(i <= 1000) {
  28.           if (x > 1.0E+15)
  29.               break;
  30.           yx = y-x*x
  31.           xx=x*cs-yx*sn
  32.           y=x*sn+yx*cs
  33.           x=xx
  34.           px=int((DimX/2)+x/sx)
  35.           py=int((DimY/2)-y/sy)
  36.           if (px>0 && px<=DimX && py>0 && py<=DimY){
  37.               stroke(cl%256, cl%128, cl%64)
  38.               point(px, py)
  39.           }
  40.           i=i+1
  41.       }
  42.       cl=cl+1
  43.   }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement