Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Lua routing for drawing reflective spheres
- -- by Bri_G
- Polar = class()
- function Polar:init(w)
- -- you can accept and set parameters here
- self.bigrad = w or 20
- self.smallrad = self.bigrad * 0.4 or 8
- self.colour = color(0, 255, 55, 255)
- self.shine = color(247, 247, 247, 228)
- self.shaded = color(69, 100, 66, 255)
- end
- function Polar:draw(x,y,z)
- -- Codea does not automatically call this method
- local offset = self.bigrad/6
- pushMatrix()
- pushStyle()
- noStroke()
- if z < 0 then
- fill(self.shaded)
- ellipse(x, y, self.smallrad, self.smallrad)
- else
- fill(self.colour)
- ellipse(x, y, self.bigrad, self.bigrad)
- fill(self.shine)
- ellipse(x - offset , y + offset, self.smallrad, self.smallrad)
- end
- popStyle()
- popMatrix()
- end
- function Polar:touched(touch)
- -- Codea does not automatically call this method
- end
Add Comment
Please, Sign In to add comment