Advertisement
ahorsewithnoname

Módulo 2

May 9th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. float radio;
  2. float tablaDel = 0;
  3. int x = 255;
  4.  
  5. void setup(){
  6.   size(640,640);
  7.   radio = width/2 - 16;
  8.   colorMode(HSB, 360, 100, 100);
  9.   textAlign(CENTER, CENTER);
  10.   textSize(20);
  11. }
  12.  
  13. PVector crearVector(float indice, float total){
  14.   float angle = map(indice % total, 0, total, 0, TWO_PI);
  15.   PVector v = PVector.fromAngle(angle + PI);
  16.   v.mult(radio);
  17.   return v;
  18. }
  19.  
  20. void draw(){
  21.   background(0);
  22.   fill(255);
  23.   text("Tabla del\n" + nfc(tablaDel,2),55,40);
  24.   x--;
  25.   if(x==0)x=360;
  26.   println(x);
  27.  
  28.   int total = int(map(mouseX,0, width, 0, 200));
  29.  
  30.   tablaDel += 0.008;
  31.  
  32.   translate(width/2, height/2);
  33.   stroke(x, 255, 255);
  34.   noFill();
  35.   circle(0,0,radio*2);
  36.   for(int i = 0; i < total; i++){
  37.     PVector v = crearVector(i,total);
  38.     fill(255);
  39.     circle(v.x, v.y, 8);
  40.   }
  41.  
  42.   for(int i = 0; i < total; i++){
  43.     PVector a = crearVector(i,total);
  44.     PVector b = crearVector(i * tablaDel,total);
  45.     line(a.x,a.y,b.x,b.y);
  46.   }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement