Advertisement
GilesCartmel

Lerp Example

Aug 17th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. /* LERP example (c) 2015 Giles Cartmel */
  2.  
  3. int squares = 25; // well, rectangles anyway
  4.  
  5. void setup() {
  6. size(900,600); // choose any screen size
  7. background(0);
  8. stroke(255);
  9. noLoop(); // just draw once
  10. }
  11.  
  12. void draw() {
  13. // split the x size (width) into the defined equal squares
  14. for (int x = 0; x <= squares; x++) {
  15. line(lerp(0,width-1,(float) x/squares)
  16. ,0
  17. ,lerp(0,width-1,(float) x/squares)
  18. ,height-1
  19. );
  20. }
  21. // split the y size (height) into the defined equal squares
  22. for (int y = 0; y <= squares; y++) {
  23. line(0
  24. ,lerp(0,height-1,(float) y/squares)
  25. ,width-1
  26. ,lerp(0,height-1,(float) y/squares)
  27. );
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement