Guest User

Untitled

a guest
Oct 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. -- Lua routing for drawing reflective spheres
  2. -- by Bri_G
  3.  
  4. Polar = class()
  5.  
  6. function Polar:init(w)
  7. -- you can accept and set parameters here
  8. self.bigrad = w or 20
  9. self.smallrad = self.bigrad * 0.4 or 8
  10. self.colour = color(0, 255, 55, 255)
  11. self.shine = color(247, 247, 247, 228)
  12. self.shaded = color(69, 100, 66, 255)
  13. end
  14.  
  15. function Polar:draw(x,y,z)
  16. -- Codea does not automatically call this method
  17. local offset = self.bigrad/6
  18. pushMatrix()
  19. pushStyle()
  20. noStroke()
  21. if z < 0 then
  22. fill(self.shaded)
  23. ellipse(x, y, self.smallrad, self.smallrad)
  24. else
  25. fill(self.colour)
  26. ellipse(x, y, self.bigrad, self.bigrad)
  27. fill(self.shine)
  28. ellipse(x - offset , y + offset, self.smallrad, self.smallrad)
  29. end
  30. popStyle()
  31. popMatrix()
  32. end
  33.  
  34. function Polar:touched(touch)
  35. -- Codea does not automatically call this method
  36. end
Add Comment
Please, Sign In to add comment