JoshuaDavis

HOscillator to strokeWeight

Jan 19th, 2021
1,053
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import hype.*;
  2. import hype.extended.behavior.HOscillator;
  3.  
  4. HOscillator lineScale;
  5.  
  6. void setup() {
  7.     H.init(this);
  8.     background(#242424);
  9.     size(900, 900, P3D);
  10.  
  11.     lineScale = new HOscillator().range(1.0, 50.0).speed(5).freq(1).waveform(H.SINE); // creates an instance of HOscillator
  12. }
  13.  
  14. void draw() {
  15.     background(#242424);
  16.  
  17.     lineScale.nextRaw(); // fire the next position in the oscillator / this an update function
  18.  
  19.     strokeWeight( lineScale.curr() ); // .curr() gets the current value
  20.     stroke(#FF3300);
  21.     fill(#00616f);
  22.     rect(100, 100, 200, 200);
  23.  
  24.     line(100, 400, 600, 400);
  25. }
RAW Paste Data