Browse Source

Document hexcodes;

bjorn 6 years ago
parent
commit
b0e931ec0d

+ 89 - 6
api/init.lua

@@ -5721,7 +5721,7 @@ return {
           description = "Clears the screen, resetting the color, depth, and stencil information to default values.  This function is called automatically by `lovr.run` at the beginning of each frame to clear out the data from the previous frame.",
           key = "lovr.graphics.clear",
           module = "lovr.graphics",
-          notes = "The two variants of this function can be mixed and matched, meaning you can use booleans for some of the values and numeric values for others.\n\nIf you are using `lovr.graphics.setStencilTest`, it will not affect how the screen gets cleared. Instead, you can use `lovr.graphics.fill` to draw a fullscreen quad, which will get masked by the active stencil.",
+          notes = "The first two variants of this function can be mixed and matched, meaning you can use booleans for some of the values and numeric values for others.\n\nIf you are using `lovr.graphics.setStencilTest`, it will not affect how the screen gets cleared. Instead, you can use `lovr.graphics.fill` to draw a fullscreen quad, which will get masked by the active stencil.",
           variants = {
             {
               description = "Clears the color, depth, and stencil to their default values.  Color will be cleared to the current background color, depth will be cleared to 1.0, and stencil will be cleared to 0.",
@@ -5783,6 +5783,16 @@ return {
                 }
               },
               returns = {}
+            },
+            {
+              arguments = {
+                {
+                  name = "hex",
+                  type = "number",
+                  description = "A hexcode to clear the color to, in the form `0xffffff` (alpha unsupported)."
+                }
+              },
+              returns = {}
             }
           },
           related = {
@@ -7515,6 +7525,23 @@ return {
                   description = "The new Material."
                 }
               }
+            },
+            {
+              arguments = {
+                {
+                  name = "hex",
+                  type = "number",
+                  description = "A hexcode to use for the diffuse color (alpha is not supported).",
+                  default = "0xffffff"
+                }
+              },
+              returns = {
+                {
+                  name = "material",
+                  type = "Material",
+                  description = "The new Material."
+                }
+              }
             }
           }
         },
@@ -8544,6 +8571,7 @@ return {
           description = "Sets the background color used to clear the screen.  Color components are from 0.0 to 1.0.",
           key = "lovr.graphics.setBackgroundColor",
           module = "lovr.graphics",
+          notes = "The default background color is `(0, 0, 0, 1)`.",
           variants = {
             {
               arguments = {
@@ -8570,9 +8598,28 @@ return {
                 }
               },
               returns = {}
+            },
+            {
+              arguments = {
+                {
+                  name = "hex",
+                  type = "number",
+                  description = "A hexcode like `0xffffff` to use for the background (does not support alpha)."
+                }
+              },
+              returns = {}
+            },
+            {
+              arguments = {
+                {
+                  name = "color",
+                  type = "table",
+                  description = "A table containing 3 or 4 color components."
+                }
+              },
+              returns = {}
             }
-          },
-          notes = "The default background color is black."
+          }
         },
         {
           name = "setBlendMode",
@@ -8640,7 +8687,7 @@ return {
           description = "Sets the color used for drawing objects.  Color components are from 0.0 to 1.0.  Every pixel drawn will be multiplied (i.e. tinted) by this color.  This is a global setting, so it will affect all subsequent drawing operations.",
           key = "lovr.graphics.setColor",
           module = "lovr.graphics",
-          notes = "The default color is white.",
+          notes = "The default color is `(1, 1, 1, 1)`.",
           variants = {
             {
               arguments = {
@@ -8668,12 +8715,22 @@ return {
               },
               returns = {}
             },
+            {
+              arguments = {
+                {
+                  name = "hex",
+                  type = "number",
+                  description = "A hexcode like `0xffffff` to use for the color (does not support alpha)."
+                }
+              },
+              returns = {}
+            },
             {
               arguments = {
                 {
                   name = "color",
                   type = "table",
-                  description = "A table containing the color components."
+                  description = "A table containing 3 or 4 color components."
                 }
               },
               returns = {}
@@ -10108,7 +10165,7 @@ return {
                     {
                       name = "colorType",
                       type = "MaterialColor",
-                      description = "The type of color to get.",
+                      description = "The type of color to set.",
                       default = "'diffuse'"
                     },
                     {
@@ -10160,6 +10217,32 @@ return {
                     }
                   },
                   returns = {}
+                },
+                {
+                  arguments = {
+                    {
+                      name = "colorType",
+                      type = "MaterialColor",
+                      description = "The type of color to set.",
+                      default = "'diffuse'"
+                    },
+                    {
+                      name = "hex",
+                      type = "number",
+                      description = "A hexcode to use for the color (alpha is not supported)."
+                    }
+                  },
+                  returns = {}
+                },
+                {
+                  arguments = {
+                    {
+                      name = "hex",
+                      type = "number",
+                      description = "A hexcode to use for the color (alpha is not supported)."
+                    }
+                  },
+                  returns = {}
                 }
               }
             },

+ 13 - 1
api/lovr/graphics/Material/setColor.lua

@@ -9,7 +9,7 @@ return {
     colorType = {
       type = 'MaterialColor',
       default = [['diffuse']],
-      description = 'The type of color to get.'
+      description = 'The type of color to set.'
     },
     r = {
       type = 'number',
@@ -27,6 +27,10 @@ return {
       type = 'number',
       default = '1.0',
       description = 'The alpha component of the color.'
+    },
+    hex = {
+      type = 'number',
+      description = 'A hexcode to use for the color (alpha is not supported).'
     }
   },
   returns = {},
@@ -38,6 +42,14 @@ return {
     {
       arguments = { 'r', 'g', 'b', 'a' },
       returns = {}
+    },
+    {
+      arguments = { 'colorType', 'hex' },
+      returns = {}
+    },
+    {
+      arguments = { 'hex' },
+      returns = {}
     }
   },
   related = {

+ 10 - 2
api/lovr/graphics/clear.lua

@@ -38,6 +38,10 @@ return {
       type = 'number',
       description = 'The value to clear the alpha channel to, from 0.0 to 1.0.'
     },
+    hex = {
+      type = 'number',
+      description = 'A hexcode to clear the color to, in the form `0xffffff` (alpha unsupported).'
+    },
     z = {
       type = 'number',
       default = '1.0',
@@ -62,11 +66,15 @@ return {
     {
       arguments = { 'r', 'g', 'b', 'a', 'z', 's' },
       returns = {}
+    },
+    {
+      arguments = { 'hex' },
+      returns = {}
     }
   },
   notes = [[
-    The two variants of this function can be mixed and matched, meaning you can use booleans for
-    some of the values and numeric values for others.
+    The first two variants of this function can be mixed and matched, meaning you can use booleans
+    for some of the values and numeric values for others.
 
     If you are using `lovr.graphics.setStencilTest`, it will not affect how the screen gets cleared.
     Instead, you can use `lovr.graphics.fill` to draw a fullscreen quad, which will get masked by

+ 9 - 0
api/lovr/graphics/newMaterial.lua

@@ -34,6 +34,11 @@ return {
       type = 'number',
       default = '1',
       description = 'The alpha component of the diffuse color.'
+    },
+    hex = {
+      type = 'number',
+      default = '0xffffff',
+      description = 'A hexcode to use for the diffuse color (alpha is not supported).'
     }
   },
   returns = {
@@ -58,6 +63,10 @@ return {
     {
       arguments = { 'r', 'g', 'b', 'a' },
       returns = { 'material' }
+    },
+    {
+      arguments = { 'hex' },
+      returns = { 'material' }
     }
   },
   notes = [[

+ 27 - 9
api/lovr/graphics/setBackgroundColor.lua

@@ -5,28 +5,46 @@ return {
     Sets the background color used to clear the screen.  Color components are from 0.0 to 1.0.
   ]],
   arguments = {
-    {
-      name = 'r',
+    r = {
       type = 'number',
       description = 'The red component of the background color.'
     },
-    {
-      name = 'g',
+    g = {
       type = 'number',
       description = 'The green component of the background color.'
     },
-    {
-      name = 'b',
+    b = {
       type = 'number',
       description = 'The blue component of the background color.'
     },
-    {
-      name = 'a',
+    a = {
       type = 'number',
       default = '1.0',
       description = 'The alpha component of the background color.'
+    },
+    hex = {
+      type = 'number',
+      description = 'A hexcode like `0xffffff` to use for the background (does not support alpha).'
+    },
+    color = {
+      type = 'table',
+      description = 'A table containing 3 or 4 color components.'
     }
   },
   returns = {},
-  notes = 'The default background color is black.'
+  variants = {
+    {
+      arguments = { 'r', 'g', 'b', 'a' },
+      returns = {}
+    },
+    {
+      arguments = { 'hex' },
+      returns = {}
+    },
+    {
+      arguments = { 'color' },
+      returns = {}
+    }
+  },
+  notes = 'The default background color is `(0, 0, 0, 1)`.'
 }

+ 10 - 2
api/lovr/graphics/setColor.lua

@@ -24,9 +24,13 @@ return {
       default = '1.0',
       description = 'The alpha component of the color.'
     },
+    hex = {
+      type = 'number',
+      description = 'A hexcode like `0xffffff` to use for the color (does not support alpha).'
+    },
     color = {
       type = 'table',
-      description = 'A table containing the color components.'
+      description = 'A table containing 3 or 4 color components.'
     }
   },
   returns = {},
@@ -35,12 +39,16 @@ return {
       arguments = { 'r', 'g', 'b', 'a' },
       returns = {}
     },
+    {
+      arguments = { 'hex' },
+      returns = {}
+    },
     {
       arguments = { 'color' },
       returns = {}
     }
   },
-  notes = 'The default color is white.',
+  notes = 'The default color is `(1, 1, 1, 1)`.',
   example = {
     description = 'Draw a red cube.',
     code = [[

+ 2 - 0
api/main.lua

@@ -107,10 +107,12 @@ local function processFunction(path, parent)
       }
     }
   else
+    assert(fn.arguments, string.format('Function %q with variants does not have arguments list', fn.key))
     for name, arg in pairs(fn.arguments) do
       arg.name = name
     end
 
+    assert(fn.returns, string.format('Function %q with variants does not have returns list', fn.key))
     for name, ret in pairs(fn.returns) do
       ret.name = name
     end