# th.um ``` Module with useful variables and types. Variables: time, delta, platform Constants: black, white, red, green, blue, yellow, magenta, cyan. ``` ## struct fu* ```go type fu* = real32 ``` standard type for real values ## struct iu* ```go type iu* = int32 ``` standard type for integer values ## struct uu* ```go type uu* = uint32 ``` standard type for unsigned values ## struct Vf2* ```go type Vf2* = struct { x, y: fu } ``` vector 2 ## fn mkVf2* `fn mkVf2*(x: fu = 0, y: fu = 0): Vf2 {` Vf2 constructor ## fn rotated* `fn (p: ^th.Vf2) rotated*(origin: th.Vf2, rot: th.fu): th.Vf2 {` rotates `p` around `origin` with `rot` in degrees ## fn distanceTo* `fn (p1: ^th.Vf2) distanceTo*(p2: th.Vf2): th.fu {` distance between p1 and p2 ## fn angleTo* `fn (p1: ^th.Vf2) angleTo*(p2: th.Vf2): real {` Angle between p1 and p2 ## fn abs* `fn (p: ^th.Vf2) abs*(): th.Vf2 {` Absolute value of a vector. ## fn round* `fn (p: ^th.Vf2) round*(): th.Vf2 {` Rounds a vector. ## fn trunc* `fn (p: ^th.Vf2) trunc*(): th.Vf2 {` Truncates a vector. ## fn floor* `fn (p: ^th.Vf2) floor*(): th.Vf2 {` Floors a vector. ## fn ceil* `fn (p: ^th.Vf2) ceil*(): th.Vf2 {` Ceils a vector. ## fn vf2f* `fn vf2f*(f: th.fu): th.Vf2 {` Creates a vector with both x and y set to f ## fn sub* `fn (p: ^th.Vf2) sub*(p2: th.Vf2): th.Vf2 {` Subtracts a vector from another one. ## fn subf* `fn (p: ^th.Vf2) subf*(f: th.fu): th.Vf2 {` Subtracts a fu from a vector. ## fn add* `fn (p: ^th.Vf2) add*(p2: th.Vf2): th.Vf2 {` Adds a vector to another one. ## fn addf* `fn (p: ^th.Vf2) addf*(f: th.fu): th.Vf2 {` Adds a fu to a vector. ## fn div* `fn (p: ^th.Vf2) div*(p2: th.Vf2): th.Vf2 {` Divides a vector by another one. ## fn divf* `fn (p: ^th.Vf2) divf*(f: th.fu): th.Vf2 {` Divides a vector by a fu. ## fn mul* `fn (p: ^th.Vf2) mul*(p2: th.Vf2): th.Vf2 {` Multiplies a vector by another one. ## fn mulf* `fn (p: ^th.Vf2) mulf*(f: th.fu): th.Vf2 {` Multiplies a vector by a fu. ## fn mag* `fn (p: ^th.Vf2) mag*(): th.fu {` Returns the magnitude of a vector p. ## fn norm* `fn (p: ^th.Vf2) norm*(): th.Vf2 {` Normalizes a vector. ## fn dot* `fn (p: ^th.Vf2) dot*(q: th.Vf2): fu {` Calculates dot product between 2 vectors. ## struct Transform* ```go type Transform* = struct { p: Vf2 // position s: Vf2 // scale o: Vf2 // origin r: fu // rotation } ``` Struct defining transformation. Used for example by entities. ## fn mkTransform* `fn mkTransform*(p: Vf2, s: Vf2 = Vf2{1, 1}, o: Vf2 = Vf2{0, 0}, r: fu = 0.0): Transform {` Transform constructor ## fn transformed* `fn (v: ^Vf2) transformed*(t: Transform): Vf2 {` Transforms a vf2 to another vf2. Order: 1. scale 2. rotation 3. position This allows conversion from a relative to an absolute vf2. ## struct Quad* ```go type Quad* = [4]th.Vf2 ``` ## fn transformed* `fn (q: ^Quad) transformed*(t: Transform): Quad {` Transforms a quad into another quad. Order: 1. scale 2. rotation 3. position ## fn getGlobal* `fn getGlobal*(): ^struct{} {` returns a pointer to the th_global. Set this as your extensions thg. ## fn getFuncs* `fn getFuncs*(): ^struct{} {` returns pointer to tophat functions. Pass this to th_ext_set.