User Tools

Site Tools


data-types

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

data-types [2020/01/23 13:38] (current)
maxime created
Line 1: Line 1:
 +====== Data types ======
 +
 +----
 +
 +==== boolean ====
 +
 +<file lua>
 +local value = true
 +</​file>​
 +
 +----
 +
 +==== integer ====
 +
 +Integer number
 +
 +<file lua>
 +local value = 42
 +</​file>​
 +
 +----
 +
 +==== float ====
 +
 +Floating-point number with single precision
 +
 +<file lua>
 +local value = 17.44
 +</​file>​
 +
 +----
 +
 +==== double ====
 +
 +Floating-point number with double precision
 +
 +<file lua>
 +local value = -61.7267023355
 +</​file>​
 +
 +----
 +
 +==== string ====
 +
 +<file lua>
 +local value = "​String value"
 +</​file>​
 +
 +----
 +
 +==== vec2i ====
 +
 +2D integer vector
 +
 +To initialize a ''​vec2i''​ with ''​x = 54''​ and ''​y = 97'':​
 +<file lua>
 +local value = { 54, 97 }
 +</​file>​
 +
 +----
 +
 +==== vec2f ====
 +
 +2D float vector
 +
 +To initialize a ''​vec2f''​ with ''​x = 73''​ and ''​y = 15.66'':​
 +<file lua>
 +local value = { 73.0, 15.66 }
 +</​file>​
 +
 +----
 +
 +==== vec3i ====
 +
 +3D integer vector
 +
 +To initialize a ''​vec3i''​ with ''​x = 19'',​ ''​y = 86''​ and ''​z = 45'':​
 +<file lua>
 +local value = { 19, 86, 45 }
 +</​file>​
 +
 +----
 +
 +==== vec3f ====
 +
 +3D float vector
 +
 +To initialize a ''​vec3f''​ with ''​x = -15.71'',​ ''​y = -71''​ and ''​z = 93.03'':​
 +<file lua>
 +local value = { -15.71, -71.0, 93.03 }
 +</​file>​
 +
 +----
 +
 +==== quaternion ====
 +
 +4D float vector representing a rotation
 +
 +To initialize a ''​quaternion''​ with ''​x = 0.302268'',​ ''​y = 0.075567'',​ ''​z = 0.6347627''​ and ''​w = 0.7071068'':​
 +<file lua>
 +local value = { 0.302268, 0.075567, 0.6347627, 0.7071068 }
 +</​file>​
 +
 +Quaternion properties can also be set with a ''​vec3f''​ containing the euler angles in degrees.
 +
 +----
 +
 +==== color ====
 +
 +A color is stored as four float numbers, representing the four channels. Each channel can have a value superior to 1, in case of HDR use.
 +
 +To initialize a ''​color''​ with ''​R = 1'',​ ''​G = 0.549'',​ ''​B = 0''​ and ''​A = 0.9''​ (dark orange with 90% opacity; hex ''​FF8C00E6''​):​
 +<file lua>
 +local value = { 1, 0.549, 0, 0.9 }
 +</​file>​
 +
 +----
 +
 +==== polygon ====
 +
 +A 2D polygon is a list of 2D points (''​vec2f''​) defining a shape.
 +
 +To initialize a square polygon with a side length of ''​4.5''​ and centered around the point ''​[1;​ 1]'':​
 +<file lua>
 +local value = {
 +    { 5.5, 5.5 },
 +    { 5.5, -3.5 },
 +    { -3.5, -3.5 },
 +    { -3.5, 5.5 }
 +}
 +</​file>​
 +
 +You can also create simple polygons with the following functions:
 +
 +  * ''​polygon.**createRectangle**(//​_size//​ [, //​_offset//​])''​
 +
 +^ Name ^ Type ^ Description ^
 +| //''​_size''//​ | ''​vec2f''​ | Size of the rectangle |
 +| //''​_offset''//​ | ''​vec2f''​ | Offset of the center of the rectange from [0; 0] |
 +
 +  * ''​polygon.**createCircle**(//​_radius//​ [, //_offset// [, //​_step//​]])''​
 +
 +^ Name ^ Type ^ Description ^
 +| //''​_radius''//​ | ''​float''​ | Radius of the circle |
 +| //''​_offset''//​ | ''​vec2f''​ | Offset of the center of the circle from [0; 0] |
 +| //''​_step''//​ | ''​integer''​ | Amount of sides of the circle |
  
data-types.txt ยท Last modified: 2020/01/23 13:38 by maxime