1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Fix util.color docs

This commit is contained in:
uramer 2022-02-02 20:30:28 +00:00 committed by psi29a
parent 406e950052
commit 2945f6238e

View File

@ -1,11 +1,11 @@
------------------------------------------------------------------------------- ---
-- `openmw.util` defines utility functions and classes like 3D vectors, that don't depend on the game world. -- `openmw.util` defines utility functions and classes like 3D vectors, that don't depend on the game world.
-- @module util -- @module util
-- @usage local util = require('openmw.util') -- @usage local util = require('openmw.util')
------------------------------------------------------------------------------- ---
-- Limits given value to the interval [`from`, `to`]. -- Limits given value to the interval [`from`, `to`].
-- @function [parent=#util] clamp -- @function [parent=#util] clamp
-- @param #number value -- @param #number value
@ -13,20 +13,20 @@
-- @param #number to -- @param #number to
-- @return #number min(max(value, from), to) -- @return #number min(max(value, from), to)
------------------------------------------------------------------------------- ---
-- Adds `2pi*k` and puts the angle in range `[-pi, pi]`. -- Adds `2pi*k` and puts the angle in range `[-pi, pi]`.
-- @function [parent=#util] normalizeAngle -- @function [parent=#util] normalizeAngle
-- @param #number angle Angle in radians -- @param #number angle Angle in radians
-- @return #number Angle in range `[-pi, pi]` -- @return #number Angle in range `[-pi, pi]`
------------------------------------------------------------------------------- ---
-- Makes a table read only. -- Makes a table read only.
-- @function [parent=#util] makeReadOnly -- @function [parent=#util] makeReadOnly
-- @param #table table Any table. -- @param #table table Any table.
-- @return #table The same table wrapped with read only userdata. -- @return #table The same table wrapped with read only userdata.
------------------------------------------------------------------------------- ---
-- Immutable 2D vector -- Immutable 2D vector
-- @type Vector2 -- @type Vector2
-- @field #number x -- @field #number x
@ -46,26 +46,26 @@
-- v1 * x -- multiplication by a number -- v1 * x -- multiplication by a number
-- v1 / x -- division by a number -- v1 / x -- division by a number
------------------------------------------------------------------------------- ---
-- Creates a new 2D vector. Vectors are immutable and can not be changed after creation. -- Creates a new 2D vector. Vectors are immutable and can not be changed after creation.
-- @function [parent=#util] vector2 -- @function [parent=#util] vector2
-- @param #number x. -- @param #number x.
-- @param #number y. -- @param #number y.
-- @return #Vector2. -- @return #Vector2.
------------------------------------------------------------------------------- ---
-- Length of the vector. -- Length of the vector.
-- @function [parent=#Vector2] length -- @function [parent=#Vector2] length
-- @param self -- @param self
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Square of the length of the vector. -- Square of the length of the vector.
-- @function [parent=#Vector2] length2 -- @function [parent=#Vector2] length2
-- @param self -- @param self
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Normalizes vector. -- Normalizes vector.
-- Returns two values: normalized vector and the length of the original vector. -- Returns two values: normalized vector and the length of the original vector.
-- It doesn't change the original vector. -- It doesn't change the original vector.
@ -73,14 +73,14 @@
-- @param self -- @param self
-- @return #Vector2, #number -- @return #Vector2, #number
------------------------------------------------------------------------------- ---
-- Rotates 2D vector clockwise. -- Rotates 2D vector clockwise.
-- @function [parent=#Vector2] rotate -- @function [parent=#Vector2] rotate
-- @param self -- @param self
-- @param #number angle Angle in radians -- @param #number angle Angle in radians
-- @return #Vector2 Rotated vector. -- @return #Vector2 Rotated vector.
------------------------------------------------------------------------------- ---
-- Dot product. -- Dot product.
-- @function [parent=#Vector2] dot -- @function [parent=#Vector2] dot
-- @param self -- @param self
@ -88,7 +88,7 @@
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Immutable 3D vector -- Immutable 3D vector
-- @type Vector3 -- @type Vector3
-- @field #number x -- @field #number x
@ -110,7 +110,7 @@
-- v1 * x -- multiplication by a number -- v1 * x -- multiplication by a number
-- v1 / x -- division by a number -- v1 / x -- division by a number
------------------------------------------------------------------------------- ---
-- Creates a new 3D vector. Vectors are immutable and can not be changed after creation. -- Creates a new 3D vector. Vectors are immutable and can not be changed after creation.
-- @function [parent=#util] vector3 -- @function [parent=#util] vector3
-- @param #number x. -- @param #number x.
@ -118,19 +118,19 @@
-- @param #number z. -- @param #number z.
-- @return #Vector3. -- @return #Vector3.
------------------------------------------------------------------------------- ---
-- Length of the vector -- Length of the vector
-- @function [parent=#Vector3] length -- @function [parent=#Vector3] length
-- @param self -- @param self
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Square of the length of the vector -- Square of the length of the vector
-- @function [parent=#Vector3] length2 -- @function [parent=#Vector3] length2
-- @param self -- @param self
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Normalizes vector. -- Normalizes vector.
-- Returns two values: normalized vector and the length of the original vector. -- Returns two values: normalized vector and the length of the original vector.
-- It doesn't change the original vector. -- It doesn't change the original vector.
@ -138,14 +138,14 @@
-- @param self -- @param self
-- @return #Vector3, #number -- @return #Vector3, #number
------------------------------------------------------------------------------- ---
-- Dot product. -- Dot product.
-- @function [parent=#Vector3] dot -- @function [parent=#Vector3] dot
-- @param self -- @param self
-- @param #Vector3 v -- @param #Vector3 v
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Cross product. -- Cross product.
-- @function [parent=#Vector3] cross -- @function [parent=#Vector3] cross
-- @param self -- @param self
@ -153,7 +153,7 @@
-- @return #Vector3 -- @return #Vector3
------------------------------------------------------------------------------- ---
-- Immutable 4D vector. -- Immutable 4D vector.
-- @type Vector4 -- @type Vector4
-- @field #number x -- @field #number x
@ -174,7 +174,7 @@
-- v1 * x -- multiplication by a number -- v1 * x -- multiplication by a number
-- v1 / x -- division by a number -- v1 / x -- division by a number
------------------------------------------------------------------------------- ---
-- Creates a new 4D vector. Vectors are immutable and can not be changed after creation. -- Creates a new 4D vector. Vectors are immutable and can not be changed after creation.
-- @function [parent=#util] vector4 -- @function [parent=#util] vector4
-- @param #number x. -- @param #number x.
@ -183,19 +183,19 @@
-- @param #number w. -- @param #number w.
-- @return #Vector4. -- @return #Vector4.
------------------------------------------------------------------------------- ---
-- Length of the vector -- Length of the vector
-- @function [parent=#Vector4] length -- @function [parent=#Vector4] length
-- @param self -- @param self
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Square of the length of the vector -- Square of the length of the vector
-- @function [parent=#Vector4] length2 -- @function [parent=#Vector4] length2
-- @param self -- @param self
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Normalizes vector. -- Normalizes vector.
-- Returns two values: normalized vector and the length of the original vector. -- Returns two values: normalized vector and the length of the original vector.
-- It doesn't change the original vector. -- It doesn't change the original vector.
@ -203,14 +203,14 @@
-- @param self -- @param self
-- @return #Vector4, #number -- @return #Vector4, #number
------------------------------------------------------------------------------- ---
-- Dot product. -- Dot product.
-- @function [parent=#Vector4] dot -- @function [parent=#Vector4] dot
-- @param self -- @param self
-- @param #Vector4 v -- @param #Vector4 v
-- @return #number -- @return #number
------------------------------------------------------------------------------- ---
-- Color in RGBA format. All of the component values are in the range [0, 1]. -- Color in RGBA format. All of the component values are in the range [0, 1].
-- @type Color -- @type Color
-- @field #number r Red component -- @field #number r Red component
@ -218,29 +218,33 @@
-- @field #number b Blue component -- @field #number b Blue component
-- @field #number a Alpha (transparency) component -- @field #number a Alpha (transparency) component
------------------------------------------------------------------------------- ---
-- Returns a Vector4 with RGBA components of the Color. -- Returns a Vector4 with RGBA components of the Color.
-- @function [parent=#Color] asRgba -- @function [parent=#Color] asRgba
-- @param self -- @param self
-- @return #Vector4 -- @return #Vector4
------------------------------------------------------------------------------- ---
-- Returns a Vector3 with RGB components of the Color. -- Returns a Vector3 with RGB components of the Color.
-- @function [parent=#Color] asRgb -- @function [parent=#Color] asRgb
-- @param self -- @param self
-- @return #Vector3 -- @return #Vector3
------------------------------------------------------------------------------- ---
-- Converts the color into a HEX string. -- Converts the color into a HEX string.
-- @function [parent=#Color] asHex -- @function [parent=#Color] asHex
-- @param self -- @param self
-- @return #string -- @return #string
------------------------------------------------------------------------------- ---
-- Methods for creating #Color values from different formats.
-- @type COLOR -- @type COLOR
-- @field [parent=#util] #COLOR color Methods for creating #Color values from different formats.
------------------------------------------------------------------------------- ---
-- Methods for creating #Color values from different formats.
-- @field [parent=#util] #COLOR color
---
-- Creates a Color from RGBA format -- Creates a Color from RGBA format
-- @function [parent=#COLOR] rgba -- @function [parent=#COLOR] rgba
-- @param #number r -- @param #number r
@ -249,7 +253,7 @@
-- @param #number a -- @param #number a
-- @return #Color -- @return #Color
------------------------------------------------------------------------------- ---
-- Creates a Color from RGB format. Equivalent to calling util.rgba with a = 1. -- Creates a Color from RGB format. Equivalent to calling util.rgba with a = 1.
-- @function [parent=#COLOR] rgb -- @function [parent=#COLOR] rgb
-- @param #number r -- @param #number r
@ -257,26 +261,26 @@
-- @param #number b -- @param #number b
-- @return #Color -- @return #Color
------------------------------------------------------------------------------- ---
-- Parses a hex color string into a Color. -- Parses a hex color string into a Color.
-- @function [parent=#COLOR] hex -- @function [parent=#COLOR] hex
-- @param #string hex A hex color string in RRGGBB format (e. g. "ff0000"). -- @param #string hex A hex color string in RRGGBB format (e. g. "ff0000").
-- @return #Color -- @return #Color
------------------------------------------------------------------------------- ---
-- @type Transform -- @type Transform
------------------------------------------------------------------------------- ---
-- Returns the inverse transform. -- Returns the inverse transform.
-- @function [parent=#Transform] inverse -- @function [parent=#Transform] inverse
-- @param self -- @param self
-- @return #Transform. -- @return #Transform.
------------------------------------------------------------------------------- ---
-- @type TRANSFORM -- @type TRANSFORM
-- @field [parent=#TRANSFORM] #Transform identity Empty transform. -- @field [parent=#TRANSFORM] #Transform identity Empty transform.
------------------------------------------------------------------------------- ---
-- Movement by given vector. -- Movement by given vector.
-- @function [parent=#TRANSFORM] move -- @function [parent=#TRANSFORM] move
-- @param #Vector3 offset. -- @param #Vector3 offset.
@ -286,7 +290,7 @@
-- util.transform.move(x, y, z) -- util.transform.move(x, y, z)
-- util.transform.move(util.vector3(x, y, z)) -- util.transform.move(util.vector3(x, y, z))
------------------------------------------------------------------------------- ---
-- Scale transform. -- Scale transform.
-- @function [parent=#TRANSFORM] scale -- @function [parent=#TRANSFORM] scale
-- @param #number scaleX. -- @param #number scaleX.
@ -299,32 +303,32 @@
-- util.transform.scale(util.vector3(x, y, z)) -- util.transform.scale(util.vector3(x, y, z))
------------------------------------------------------------------------------- ---
-- Rotation around a vector (counterclockwise if the vector points to us). -- Rotation around a vector (counterclockwise if the vector points to us).
-- @function [parent=#TRANSFORM] rotate -- @function [parent=#TRANSFORM] rotate
-- @param #number angle -- @param #number angle
-- @param #Vector3 axis. -- @param #Vector3 axis.
-- @return #Transform. -- @return #Transform.
------------------------------------------------------------------------------- ---
-- X-axis rotation (equivalent to `rotate(angle, vector3(-1, 0, 0))`). -- X-axis rotation (equivalent to `rotate(angle, vector3(-1, 0, 0))`).
-- @function [parent=#TRANSFORM] rotateX -- @function [parent=#TRANSFORM] rotateX
-- @param #number angle -- @param #number angle
-- @return #Transform. -- @return #Transform.
------------------------------------------------------------------------------- ---
-- Y-axis rotation (equivalent to `rotate(angle, vector3(0, -1, 0))`). -- Y-axis rotation (equivalent to `rotate(angle, vector3(0, -1, 0))`).
-- @function [parent=#TRANSFORM] rotateY -- @function [parent=#TRANSFORM] rotateY
-- @param #number angle -- @param #number angle
-- @return #Transform. -- @return #Transform.
------------------------------------------------------------------------------- ---
-- Z-axis rotation (equivalent to `rotate(angle, vector3(0, 0, -1))`). -- Z-axis rotation (equivalent to `rotate(angle, vector3(0, 0, -1))`).
-- @function [parent=#TRANSFORM] rotateZ -- @function [parent=#TRANSFORM] rotateZ
-- @param #number angle -- @param #number angle
-- @return #Transform. -- @return #Transform.
------------------------------------------------------------------------------- ---
-- 3D transforms (scale/move/rotate) that can be applied to 3D vectors. -- 3D transforms (scale/move/rotate) that can be applied to 3D vectors.
-- Several transforms can be combined and applied to a vector using multiplication. -- Several transforms can be combined and applied to a vector using multiplication.
-- Combined transforms apply in reverse order (from right to left). -- Combined transforms apply in reverse order (from right to left).