-
Notifications
You must be signed in to change notification settings - Fork 20
/
node-raylib-definitions.js
96 lines (85 loc) · 3.6 KB
/
node-raylib-definitions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const ArgumentTypeConversion = require('./ArgumentTypeConversion')
const FunctionDefinition = (func) => {
return `/** ${func.description} */
export function ${func.name}(${!func.params
? ''
: func.params
.map(param => `${param.name}: ${ArgumentTypeConversion(param.type)}`)
.join(', ')
}): ${ArgumentTypeConversion(func.returnType)}
`
}
const StructInterface = (struct) => {
return `/** ${struct.description} */
export interface ${struct.name} {
${struct.fields
.map(field => `/** ${field.description}. (${field.type}) */\n ${field.name}: ${ArgumentTypeConversion(field.type)}`)
.join('\n ')
}
}`
}
module.exports = ({ functions, structs, enums, blocklist }) => {
return `// GENERATED CODE: DO NOT MODIFY
declare module "raylib" {
${structs
.map(StructInterface)
.join('\n ')
}
/** RenderTexture, fbo for texture rendering */
export type RenderTexture2D = RenderTexture
/** Texture, tex data stored in GPU memory (VRAM) */
export type Texture2D = Texture
/** Texture, tex data stored in GPU memory (VRAM) */
export type TextureCubemap = Texture
/** Camera, defines position/orientation in 3d space */
export type Camera = Camera3D | Camera2D
/** Quaternion, same as Vector4 */
export type Quaternion = Vector4
${functions
.filter(({ name }) => !blocklist.includes(name))
.map(FunctionDefinition)
.join('\n ')
}
/** Set shader uniform float */
export function SetShaderFloat(shader: Shader, locIndex: number, value: number): void
/** Set shader uniform int */
export function SetShaderInt(shader: Shader, locIndex: number, value: number): void
/** Set shader uniform Vec2 */
export function SetShaderVec2(shader: Shader, locIndex: number, value: Vector2): void
/** Set shader uniform Vec3 */
export function SetShaderVec3(shader: Shader, locIndex: number, value: Vector3): void
/** Set shader uniform Vec4 */
export function SetShaderVec4(shader: Shader, locIndex: number, value: Vector4): void
${enums
.map((e) => { return e.values.map(v => ` /** ${v.description} */\n export const ${v.name} = ${v.value}`).join('\n') })
.join('\n')
}
export const LIGHTGRAY: { r: 200, g: 200, b: 200, a: 255 }
export const GRAY: { r: 130, g: 130, b: 130, a: 255 }
export const DARKGRAY: { r: 80, g: 80, b: 80, a: 255 }
export const YELLOW: { r: 253, g: 249, b: 0, a: 255 }
export const GOLD: { r: 255, g: 203, b: 0, a: 255 }
export const ORANGE: { r: 255, g: 161, b: 0, a: 255 }
export const PINK: { r: 255, g: 109, b: 194, a: 255 }
export const RED: { r: 230, g: 41, b: 55, a: 255 }
export const MAROON: { r: 190, g: 33, b: 55, a: 255 }
export const GREEN: { r: 0, g: 228, b: 48, a: 255 }
export const LIME: { r: 0, g: 158, b: 47, a: 255 }
export const DARKGREEN: { r: 0, g: 117, b: 44, a: 255 }
export const SKYBLUE: { r: 102, g: 191, b: 255, a: 255 }
export const BLUE: { r: 0, g: 121, b: 241, a: 255 }
export const DARKBLUE: { r: 0, g: 82, b: 172, a: 255 }
export const PURPLE: { r: 200, g: 122, b: 255, a: 255 }
export const VIOLET: { r: 135, g: 60, b: 190, a: 255 }
export const DARKPURPLE: { r: 112, g: 31, b: 126, a: 255 }
export const BEIGE: { r: 211, g: 176, b: 131, a: 255 }
export const BROWN: { r: 127, g: 106, b: 79, a: 255 }
export const DARKBROWN: { r: 76, g: 63, b: 47, a: 255 }
export const WHITE: { r: 255, g: 255, b: 255, a: 255 }
export const BLACK: { r: 0, g: 0, b: 0, a: 255 }
export const BLANK: { r: 0, g: 0, b: 0, a: 0 }
export const MAGENTA: { r: 255, g: 0, b: 255, a: 255 }
export const RAYWHITE: { r: 245, g: 245, b: 245, a: 255 }
}
`
}