setColor.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. return {
  2. tag = 'graphicsState',
  3. summary = 'Set the global color factor.',
  4. description = [[
  5. Sets the color used for drawing objects. Color components are from 0.0 to 1.0. Every pixel drawn
  6. will be multiplied (i.e. tinted) by this color. This is a global setting, so it will affect all
  7. subsequent drawing operations.
  8. ]],
  9. arguments = {
  10. r = {
  11. type = 'number',
  12. description = 'The red component of the color.'
  13. },
  14. g = {
  15. type = 'number',
  16. description = 'The green component of the color.'
  17. },
  18. b = {
  19. type = 'number',
  20. description = 'The blue component of the color.'
  21. },
  22. a = {
  23. type = 'number',
  24. default = '1.0',
  25. description = 'The alpha component of the color.'
  26. },
  27. hex = {
  28. type = 'number',
  29. description = 'A hexcode like `0xffffff` to use for the color (does not support alpha).'
  30. },
  31. color = {
  32. type = 'table',
  33. description = 'A table containing 3 or 4 color components.'
  34. }
  35. },
  36. returns = {},
  37. variants = {
  38. {
  39. arguments = { 'r', 'g', 'b', 'a' },
  40. returns = {}
  41. },
  42. {
  43. arguments = { 'hex' },
  44. returns = {}
  45. },
  46. {
  47. arguments = { 'color' },
  48. returns = {}
  49. }
  50. },
  51. notes = 'The default color is `(1.0, 1.0, 1.0, 1.0)`.',
  52. example = {
  53. description = 'Draw a red cube.',
  54. code = [[
  55. function lovr.draw()
  56. lovr.graphics.setColor(1.0, 0, 0)
  57. lovr.graphics.cube('fill', 0, 1.7, -1, .5, lovr.timer.getTime())
  58. end
  59. ]]
  60. }
  61. }