Advertisement
Tatantyler

Graphics API Demo

Nov 21st, 2012
1,122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. -- Graphics API demo program
  2.  
  3. os.loadAPI("GraphicsAPI")
  4. GraphicsAPI.drawLine( {1,5}, GraphicsAPI.packXY(8, 3), colors.lime ) -- Draw a green line from (1,5) to (8,2).
  5. GraphicsAPI.drawLine( {1,2}, GraphicsAPI.packXY(8, 5), colors.blue ) -- Draw a blue line from (1,2) to (8,5).
  6. -- This 2nd line will appear to be on top of the green line.
  7. -- Points are written as: { x, y }
  8.  
  9. GraphicsAPI.drawCircle( {28,14}, 4, colors.yellow ) -- Draw a circle that is 4 characters wide centered around (28,14).
  10. -- Used as so: GraphicsAPI.drawCircle( midpoint, radius, color )
  11.  
  12. GraphicsAPI.floodFill( {28,14}, colors.white ) -- Flood-fill in the yellow circle with white.
  13.  
  14. GraphicsAPI.drawCircle( {28,14}, 4, {colors.black, "X"} ) -- Now, overlay that same circle with black X's.
  15. -- To write characters to screen, use a table like { color, character } in place of any color argument.
  16.  
  17. GraphicsAPI.floodFill( {28,14}, {colors.lightBlue, "O"} ) -- Do the same to the filling, but with light blue O's instead.
  18.  
  19. GraphicsAPI.drawRect( {9, 3}, {24, 6}, colors.purple ) -- Draw a purple, non-filled in box with the corners at (2,3) and (5,6).
  20. GraphicsAPI.drawRect( {26, 3}, {46, 6}, colors.white, true ) -- Draw a white, filled in box with the corners at (2,3) and (5,6).
  21.  
  22. GraphicsAPI.writeText( "Graphics API Demo", {3, 16}, colors.lightBlue ) -- Write the words "Graphics API Demo" in light blue starting from the point (3,16)
  23. GraphicsAPI.writeText( "Made By KillaVanilla", {20, 14}, colors.lightGray ) -- Write the words "Made By KillaVanilla" in light grey starting from the point {15, 14}
  24. -- This will intersect the circle.
  25.  
  26. GraphicsAPI.drawPoint(12, 12, colors.red) -- Draw a red dot at (12, 12)
  27.  
  28. GraphicsAPI.update() -- Now draw all this to screen.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement