MrThoe

P5 Example (Variable, rotate, text)

Sep 2nd, 2020
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /* Example Snowman
  2. * @Author: Allen Thoe
  3. */
  4.  
  5. //Global Variables -> Can be used in ANY FUNCTION
  6. var x = 0; //Make the variable an INTEGER
  7. var name = "THOE"; //Make the Variable a STRING
  8. var y = false; //BOOLEAN
  9. var someNewVariable; //DECLARE a variable
  10.  
  11. function setup() {
  12. createCanvas(400, 400);
  13. someNewVariable = 2.7;
  14. }
  15.  
  16. function draw() {
  17. background(220);
  18. textSize(32);
  19. fill(0,095,0);
  20. text(name, 10, 30);
  21. fill(0, 102, 153);
  22. text(x, 10, 60);
  23. rotate(PI); //RADIANS -> PI = 180 (EXAMPLE = 30 deg)
  24. fill(255, 0, 0, 101); //(RED, GREEN, BLUE, OPACITY)
  25. text(someNewVariable, -110, -90); //! means NOT
  26. x++; // MEANS x = x + 1;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment