Guest User

Untitled

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. static class Avatar {
  2.  
  3. // If the texture is to be a permanent part
  4. // of the avatar, instead of supplying the texture
  5. // to the draw function, a PImage field could be
  6. // added at the top of the Avatar class and set
  7. // in the constructor.
  8. Avatar draw(PGraphics2D rndr, PImage texture) {
  9. rndr.pushStyle();
  10. rndr.noStroke();
  11.  
  12. rndr.pushMatrix();
  13. rndr.translate(x, y);
  14. rndr.rotate(rot);
  15. rndr.scale(size);
  16.  
  17. rndr.beginShape(QUADS);
  18. rndr.texture(texture);
  19. rndr.vertex(-0.5, 0.5, 0.0, 0.0);
  20. rndr.vertex(0.5, 0.5, 1.0, 0.0);
  21. rndr.vertex(0.5, -0.5, 1.0, 1.0);
  22. rndr.vertex(-0.5, -0.5, 0.0, 1.0);
  23. rndr.endShape(CLOSE);
  24.  
  25. rndr.popMatrix();
  26. rndr.popStyle();
  27. return this;
  28. }
  29. }
Add Comment
Please, Sign In to add comment