@genocode/core 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/genetics.d.ts +54 -0
- package/dist/genetics.d.ts.map +1 -0
- package/dist/genetics.js +276 -0
- package/dist/genetics.js.map +1 -0
- package/dist/help.d.ts +36 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +431 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/reference/LANGUAGE.md +10 -0
- package/reference/creatures/StarBurstShell.genie +102 -0
- package/reference/creatures/StarBurstShell9.genie +102 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CheckResult } from "./checker.js";
|
|
2
|
+
import { type GeneInfo } from "./genes.js";
|
|
3
|
+
import { type Value } from "./values.js";
|
|
4
|
+
/** Gene values by full name. A gene that isn't listed has the value written in the program. */
|
|
5
|
+
export type GeneValues = ReadonlyMap<string, Value>;
|
|
6
|
+
/** A creature for breeding and morphing: its genes, and the values they have. */
|
|
7
|
+
export interface GeneSet {
|
|
8
|
+
genes: readonly GeneInfo[];
|
|
9
|
+
values?: GeneValues;
|
|
10
|
+
}
|
|
11
|
+
export interface GeneticsOptions {
|
|
12
|
+
/** A random number from 0 up to 1, such as `Math.random` or `mulberry32(seed)`. */
|
|
13
|
+
random: () => number;
|
|
14
|
+
/** Full names of genes to keep as they are. */
|
|
15
|
+
locked?: ReadonlySet<string>;
|
|
16
|
+
}
|
|
17
|
+
export interface MutateOptions extends GeneticsOptions {
|
|
18
|
+
/** How far genes move, from 0 to 1. */
|
|
19
|
+
strength: number;
|
|
20
|
+
/** The chance that each gene is changed. ½ unless the app lets the user choose. */
|
|
21
|
+
rate?: number;
|
|
22
|
+
}
|
|
23
|
+
/** Every gene's value: the one given, or the one written in the program. */
|
|
24
|
+
export declare function valuesOf(genes: readonly GeneInfo[], values?: GeneValues): Map<string, Value>;
|
|
25
|
+
/** A mutated copy of the gene values. */
|
|
26
|
+
export declare function mutate(genes: readonly GeneInfo[], values: GeneValues | undefined, options: MutateOptions): Map<string, Value>;
|
|
27
|
+
/** The gene values of a child of A and B. The child has A's program. */
|
|
28
|
+
export declare function breed(a: GeneSet, b: GeneSet, options: GeneticsOptions): Map<string, Value>;
|
|
29
|
+
/**
|
|
30
|
+
* The creature at `t` (0 to 1) between A and B: which program it has (A's before the halfway
|
|
31
|
+
* point, B's from it on) and its gene values. Values aren't limited to either range.
|
|
32
|
+
*/
|
|
33
|
+
export declare function morph(a: GeneSet, b: GeneSet, t: number): {
|
|
34
|
+
from: "a" | "b";
|
|
35
|
+
values: Map<string, Value>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The program's text with each gene's value written in, laid out by the formatter. Genes whose
|
|
39
|
+
* value hasn't changed keep the text they were written with. The automatic `seed` gene has no
|
|
40
|
+
* line to write into, so it isn't saved.
|
|
41
|
+
*/
|
|
42
|
+
export declare function writeGenes(program: CheckResult, values: GeneValues): string;
|
|
43
|
+
/**
|
|
44
|
+
* The edits that write each changed gene's value into the program's text, in order, without
|
|
45
|
+
* laying anything else out. Editors apply them so the rest of the text and the cursor stay put.
|
|
46
|
+
*/
|
|
47
|
+
export declare function geneEdits(program: CheckResult, values: GeneValues): {
|
|
48
|
+
start: number;
|
|
49
|
+
end: number;
|
|
50
|
+
text: string;
|
|
51
|
+
}[];
|
|
52
|
+
/** A gene value written readably, and still within the gene's range. */
|
|
53
|
+
export declare function geneLiteral(g: GeneInfo, v: Value): string;
|
|
54
|
+
//# sourceMappingURL=genetics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genetics.d.ts","sourceRoot":"","sources":["../src/genetics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAA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,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;CAAE,CAgBjD;AAsBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAQ3E;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,GACjB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAShD;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAkBzD"}
|
package/dist/genetics.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// Mutating, breeding and morphing genes (docs/LANGUAGE.md section 19), and writing a creature's
|
|
2
|
+
// gene values back into its program, which is how a bred creature is saved.
|
|
3
|
+
import { hueDelta, mixHue, wrapHue } from "./colour.js";
|
|
4
|
+
import { formatText } from "./format.js";
|
|
5
|
+
import { inHueArc } from "./genes.js";
|
|
6
|
+
import { formatValue, isColour, isVec, valuesEqual, } from "./values.js";
|
|
7
|
+
/** Every gene's value: the one given, or the one written in the program. */
|
|
8
|
+
export function valuesOf(genes, values) {
|
|
9
|
+
return new Map(genes.map((g) => [g.fullName, values?.get(g.fullName) ?? g.value]));
|
|
10
|
+
}
|
|
11
|
+
// ---------- mutation (section 19.1) ----------
|
|
12
|
+
/** A mutated copy of the gene values. */
|
|
13
|
+
export function mutate(genes, values, options) {
|
|
14
|
+
const { random, strength } = options;
|
|
15
|
+
const rate = options.rate ?? 0.5;
|
|
16
|
+
const out = valuesOf(genes, values);
|
|
17
|
+
for (const g of genes) {
|
|
18
|
+
if (options.locked?.has(g.fullName))
|
|
19
|
+
continue;
|
|
20
|
+
if (random() >= rate)
|
|
21
|
+
continue;
|
|
22
|
+
out.set(g.fullName, mutateGene(g, out.get(g.fullName), strength, random));
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
function mutateGene(g, v, strength, random) {
|
|
27
|
+
if (isSeed(g))
|
|
28
|
+
return random() < strength ? Math.floor(random() * 2 ** 32) : v;
|
|
29
|
+
switch (g.kind) {
|
|
30
|
+
case "bool":
|
|
31
|
+
return random() < strength ? !v : v;
|
|
32
|
+
case "choice":
|
|
33
|
+
case "part": {
|
|
34
|
+
if (random() >= strength)
|
|
35
|
+
return v;
|
|
36
|
+
const others = g.options.filter((o) => !valuesEqual(o, v));
|
|
37
|
+
return others.length > 0 ? others[Math.floor(random() * others.length)] : v;
|
|
38
|
+
}
|
|
39
|
+
case "number":
|
|
40
|
+
return mutateNumber(v, g.min, g.max, g, strength, random);
|
|
41
|
+
case "vector": {
|
|
42
|
+
const [a, lo, hi] = [v, g.min, g.max];
|
|
43
|
+
const axis = (k) => mutateNumber(a[k], lo[k], hi[k], g, strength, random);
|
|
44
|
+
return { type: "vector", x: axis("x"), y: axis("y"), z: axis("z") };
|
|
45
|
+
}
|
|
46
|
+
case "colour": {
|
|
47
|
+
const [c, lo, hi] = [v, g.min, g.max];
|
|
48
|
+
const channel = (k) => mutateNumber(c[k], lo[k], hi[k], g, strength, random);
|
|
49
|
+
return {
|
|
50
|
+
type: "colour",
|
|
51
|
+
h: mutateHue(c.h, g.hue, strength, random),
|
|
52
|
+
s: channel("s"),
|
|
53
|
+
v: channel("v"),
|
|
54
|
+
a: channel("a"),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** A uniformly random point in `v ± strength × (max − min)`, kept within min..max. */
|
|
60
|
+
function mutateNumber(v, min, max, g, strength, random) {
|
|
61
|
+
if (min === max)
|
|
62
|
+
return v;
|
|
63
|
+
if (g.log) {
|
|
64
|
+
const r = strength * (Math.log(max) - Math.log(min));
|
|
65
|
+
const l = Math.log(v);
|
|
66
|
+
const lo = Math.max(Math.log(min), l - r);
|
|
67
|
+
const hi = Math.min(Math.log(max), l + r);
|
|
68
|
+
return clamp(Math.exp(lo + random() * (hi - lo)), min, max);
|
|
69
|
+
}
|
|
70
|
+
const r = strength * (max - min);
|
|
71
|
+
const lo = Math.max(min, v - r);
|
|
72
|
+
const hi = Math.min(max, v + r);
|
|
73
|
+
return snap(lo + random() * (hi - lo), min, max, g.step);
|
|
74
|
+
}
|
|
75
|
+
/** Hue: the window `h ± strength × arc` taken round the circle, limited to the arc unless it's whole. */
|
|
76
|
+
function mutateHue(h, arc, strength, random) {
|
|
77
|
+
const r = strength * arc.length;
|
|
78
|
+
if (arc.whole)
|
|
79
|
+
return wrapHue(h + (random() * 2 - 1) * r);
|
|
80
|
+
const at = wrapHue(h - arc.start);
|
|
81
|
+
const lo = Math.max(0, at - r);
|
|
82
|
+
const hi = Math.min(arc.length, at + r);
|
|
83
|
+
return wrapHue(arc.start + lo + random() * (hi - lo));
|
|
84
|
+
}
|
|
85
|
+
// ---------- breeding (section 19.2) ----------
|
|
86
|
+
/** The gene values of a child of A and B. The child has A's program. */
|
|
87
|
+
export function breed(a, b, options) {
|
|
88
|
+
const { random } = options;
|
|
89
|
+
const av = valuesOf(a.genes, a.values);
|
|
90
|
+
const bv = valuesOf(b.genes, b.values);
|
|
91
|
+
const bGenes = new Map(b.genes.map((g) => [g.fullName, g]));
|
|
92
|
+
const out = new Map(av);
|
|
93
|
+
for (const g of a.genes) {
|
|
94
|
+
const match = bGenes.get(g.fullName);
|
|
95
|
+
if (options.locked?.has(g.fullName) || match === undefined || match.kind !== g.kind)
|
|
96
|
+
continue;
|
|
97
|
+
out.set(g.fullName, breedGene(g, av.get(g.fullName), bv.get(g.fullName), random));
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
function breedGene(g, x, y, random) {
|
|
102
|
+
if (isSeed(g) || g.kind === "bool")
|
|
103
|
+
return random() < 0.5 ? x : y;
|
|
104
|
+
if (g.kind === "choice" || g.kind === "part") {
|
|
105
|
+
const pick = random() < 0.5 ? x : y;
|
|
106
|
+
// B's choice only counts if it's one of A's options.
|
|
107
|
+
return g.options.some((o) => valuesEqual(o, pick)) ? pick : x;
|
|
108
|
+
}
|
|
109
|
+
if (g.kind === "number") {
|
|
110
|
+
return breedNumber(x, y, g.min, g.max, g, random);
|
|
111
|
+
}
|
|
112
|
+
if (g.kind === "vector" && isVec(x) && isVec(y)) {
|
|
113
|
+
const [lo, hi] = [g.min, g.max];
|
|
114
|
+
const axis = (k) => breedNumber(x[k], y[k], lo[k], hi[k], g, random);
|
|
115
|
+
return { type: "vector", x: axis("x"), y: axis("y"), z: axis("z") };
|
|
116
|
+
}
|
|
117
|
+
if (g.kind === "colour" && isColour(x) && isColour(y)) {
|
|
118
|
+
const [lo, hi] = [g.min, g.max];
|
|
119
|
+
const channel = (k) => breedNumber(x[k], y[k], lo[k], hi[k], g, random);
|
|
120
|
+
return {
|
|
121
|
+
type: "colour",
|
|
122
|
+
h: breedHue(x.h, y.h, g.hue, random),
|
|
123
|
+
s: channel("s"),
|
|
124
|
+
v: channel("v"),
|
|
125
|
+
a: channel("a"),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return x;
|
|
129
|
+
}
|
|
130
|
+
/** Half the time a random point between the two, otherwise one or the other; kept within A's range. */
|
|
131
|
+
function breedNumber(x, y, min, max, g, random) {
|
|
132
|
+
let v;
|
|
133
|
+
if (random() < 0.5) {
|
|
134
|
+
const t = random();
|
|
135
|
+
v =
|
|
136
|
+
g.log && x > 0 && y > 0
|
|
137
|
+
? Math.exp(Math.log(x) + t * (Math.log(y) - Math.log(x)))
|
|
138
|
+
: x + t * (y - x);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
v = random() < 0.5 ? x : y;
|
|
142
|
+
}
|
|
143
|
+
return snap(v, min, max, g.step);
|
|
144
|
+
}
|
|
145
|
+
function breedHue(x, y, arc, random) {
|
|
146
|
+
const h = random() < 0.5 ? mixHue(x, y, random()) : random() < 0.5 ? x : y;
|
|
147
|
+
return clampHue(h, arc);
|
|
148
|
+
}
|
|
149
|
+
// ---------- morphing (section 19.3) ----------
|
|
150
|
+
/**
|
|
151
|
+
* The creature at `t` (0 to 1) between A and B: which program it has (A's before the halfway
|
|
152
|
+
* point, B's from it on) and its gene values. Values aren't limited to either range.
|
|
153
|
+
*/
|
|
154
|
+
export function morph(a, b, t) {
|
|
155
|
+
const from = t < 0.5 ? "a" : "b";
|
|
156
|
+
const own = from === "a" ? a : b;
|
|
157
|
+
const other = from === "a" ? b : a;
|
|
158
|
+
const av = valuesOf(a.genes, a.values);
|
|
159
|
+
const bv = valuesOf(b.genes, b.values);
|
|
160
|
+
const otherGenes = new Map(other.genes.map((g) => [g.fullName, g]));
|
|
161
|
+
const out = valuesOf(own.genes, own.values);
|
|
162
|
+
for (const g of own.genes) {
|
|
163
|
+
const match = otherGenes.get(g.fullName);
|
|
164
|
+
if (match === undefined || match.kind !== g.kind)
|
|
165
|
+
continue;
|
|
166
|
+
const x = av.get(g.fullName);
|
|
167
|
+
const y = bv.get(g.fullName);
|
|
168
|
+
out.set(g.fullName, morphGene(g, x, y, t));
|
|
169
|
+
}
|
|
170
|
+
return { from, values: out };
|
|
171
|
+
}
|
|
172
|
+
function morphGene(g, x, y, t) {
|
|
173
|
+
const num = (p, q) => g.log && p > 0 && q > 0 ? p * (q / p) ** t : p + (q - p) * t;
|
|
174
|
+
if (typeof x === "number" && typeof y === "number" && !isSeed(g))
|
|
175
|
+
return num(x, y);
|
|
176
|
+
if (isVec(x) && isVec(y))
|
|
177
|
+
return { type: "vector", x: num(x.x, y.x), y: num(x.y, y.y), z: num(x.z, y.z) };
|
|
178
|
+
if (isColour(x) && isColour(y)) {
|
|
179
|
+
return {
|
|
180
|
+
type: "colour",
|
|
181
|
+
h: mixHue(x.h, y.h, t),
|
|
182
|
+
s: x.s + (y.s - x.s) * t,
|
|
183
|
+
v: x.v + (y.v - x.v) * t,
|
|
184
|
+
a: x.a + (y.a - x.a) * t,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return t < 0.5 ? x : y;
|
|
188
|
+
}
|
|
189
|
+
// ---------- writing genes into the program ----------
|
|
190
|
+
/**
|
|
191
|
+
* The program's text with each gene's value written in, laid out by the formatter. Genes whose
|
|
192
|
+
* value hasn't changed keep the text they were written with. The automatic `seed` gene has no
|
|
193
|
+
* line to write into, so it isn't saved.
|
|
194
|
+
*/
|
|
195
|
+
export function writeGenes(program, values) {
|
|
196
|
+
const edits = geneEdits(program, values);
|
|
197
|
+
if (edits.length === 0)
|
|
198
|
+
return program.text;
|
|
199
|
+
let text = program.text;
|
|
200
|
+
for (const e of [...edits].reverse()) {
|
|
201
|
+
text = text.slice(0, e.start) + e.text + text.slice(e.end);
|
|
202
|
+
}
|
|
203
|
+
return formatText(text).text ?? text;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The edits that write each changed gene's value into the program's text, in order, without
|
|
207
|
+
* laying anything else out. Editors apply them so the rest of the text and the cursor stay put.
|
|
208
|
+
*/
|
|
209
|
+
export function geneEdits(program, values) {
|
|
210
|
+
const edits = [];
|
|
211
|
+
for (const g of program.genes) {
|
|
212
|
+
const v = values.get(g.fullName);
|
|
213
|
+
if (g.decl === undefined || v === undefined || valuesEqual(v, g.value))
|
|
214
|
+
continue;
|
|
215
|
+
const span = g.decl.value.span;
|
|
216
|
+
edits.push({ start: span.start, end: span.end, text: geneLiteral(g, v) });
|
|
217
|
+
}
|
|
218
|
+
return edits.sort((p, q) => p.start - q.start);
|
|
219
|
+
}
|
|
220
|
+
/** A gene value written readably, and still within the gene's range. */
|
|
221
|
+
export function geneLiteral(g, v) {
|
|
222
|
+
if (g.kind === "number" && typeof v === "number") {
|
|
223
|
+
return numberLiteral(v, g.min, g.max, g.step);
|
|
224
|
+
}
|
|
225
|
+
if (g.kind === "vector" && isVec(v)) {
|
|
226
|
+
const [lo, hi] = [g.min, g.max];
|
|
227
|
+
const axis = (k) => numberLiteral(v[k], lo[k], hi[k], undefined);
|
|
228
|
+
return `(${axis("x")}, ${axis("y")}, ${axis("z")})`;
|
|
229
|
+
}
|
|
230
|
+
if (g.kind === "colour" && isColour(v)) {
|
|
231
|
+
const [lo, hi] = [g.min, g.max];
|
|
232
|
+
let h = Number(clampHue(v.h, g.hue).toFixed(1));
|
|
233
|
+
if (!inHueArc(h, g.hue))
|
|
234
|
+
h = clampHue(v.h, g.hue);
|
|
235
|
+
const ch = (k) => short(clamp(Number(v[k].toFixed(2)), lo[k], hi[k]));
|
|
236
|
+
const alpha = ch("a");
|
|
237
|
+
return `hsv(${short(h)}, ${ch("s")}, ${ch("v")}${alpha === "1" ? "" : `, ${alpha}`})`;
|
|
238
|
+
}
|
|
239
|
+
return formatValue(v);
|
|
240
|
+
}
|
|
241
|
+
function numberLiteral(v, min, max, step) {
|
|
242
|
+
if (step !== undefined)
|
|
243
|
+
return short(snap(v, min, max, step));
|
|
244
|
+
return short(clamp(Number(v.toPrecision(4)), min, max));
|
|
245
|
+
}
|
|
246
|
+
/** A number without floating-point noise, such as `0.3` rather than `0.30000000000000004`. */
|
|
247
|
+
function short(n) {
|
|
248
|
+
const s = String(Number(n.toPrecision(12)));
|
|
249
|
+
return s === "-0" ? "0" : s;
|
|
250
|
+
}
|
|
251
|
+
// ---------- helpers ----------
|
|
252
|
+
function isSeed(g) {
|
|
253
|
+
return g.fullName === "seed" && g.decl === undefined;
|
|
254
|
+
}
|
|
255
|
+
function clamp(x, lo, hi) {
|
|
256
|
+
return x < lo ? lo : x > hi ? hi : x;
|
|
257
|
+
}
|
|
258
|
+
/** Clamps into min..max, and onto the nearest whole step within it if the gene has one. */
|
|
259
|
+
function snap(v, min, max, step) {
|
|
260
|
+
v = clamp(v, min, max);
|
|
261
|
+
if (step === undefined)
|
|
262
|
+
return v;
|
|
263
|
+
let k = Math.round((v - min) / step);
|
|
264
|
+
if (min + k * step > max + 1e-9)
|
|
265
|
+
k--;
|
|
266
|
+
return min + k * step;
|
|
267
|
+
}
|
|
268
|
+
/** The hue itself if it's on the arc, otherwise the nearer end of the arc. */
|
|
269
|
+
function clampHue(h, arc) {
|
|
270
|
+
h = wrapHue(h);
|
|
271
|
+
if (inHueArc(h, arc))
|
|
272
|
+
return h;
|
|
273
|
+
const end = wrapHue(arc.start + arc.length);
|
|
274
|
+
return Math.abs(hueDelta(h, arc.start)) <= Math.abs(hueDelta(h, end)) ? arc.start : end;
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=genetics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genetics.js","sourceRoot":"","sources":["../src/genetics.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,4EAA4E;AAG5E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAA8B,MAAM,YAAY,CAAC;AAClE,OAAO,EACL,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,GAIZ,MAAM,aAAa,CAAC;AAyBrB,4EAA4E;AAC5E,MAAM,UAAU,QAAQ,CAAC,KAA0B,EAAE,MAAmB;IACtE,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,gDAAgD;AAEhD,yCAAyC;AACzC,MAAM,UAAU,MAAM,CACpB,KAA0B,EAC1B,MAA8B,EAC9B,OAAsB;IAEtB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IA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ker.js";
|
|
2
|
+
import type { GeneInfo } from "./genes.js";
|
|
3
|
+
import type { Span } from "./source.js";
|
|
4
|
+
export interface Help {
|
|
5
|
+
/** How it's written, such as `clamp(x, lo, hi)`. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** What it does, in a sentence or two. */
|
|
8
|
+
text: string;
|
|
9
|
+
/** The section of docs/LANGUAGE.md that explains it, such as `18.1`. */
|
|
10
|
+
section: string;
|
|
11
|
+
}
|
|
12
|
+
export type CompletionKind = "keyword" | "function" | "constant" | "input" | "gene" | "part" | "variable" | "member";
|
|
13
|
+
export interface Completion {
|
|
14
|
+
label: string;
|
|
15
|
+
kind: CompletionKind;
|
|
16
|
+
/** A short note shown beside the label. */
|
|
17
|
+
detail: string;
|
|
18
|
+
}
|
|
19
|
+
/** The built-in functions. */
|
|
20
|
+
export declare const FUNCTION_HELP: ReadonlyMap<string, Help>;
|
|
21
|
+
/** The built-in constants: numbers, vectors, colours, shapes and pattern kinds. */
|
|
22
|
+
export declare function constantHelp(name: string): Help | undefined;
|
|
23
|
+
/** Keywords, and the inputs `time`, `beat`, `music` and `turtle`. */
|
|
24
|
+
export declare const KEYWORD_HELP: ReadonlyMap<string, Help>;
|
|
25
|
+
/** The parts of `music` and `turtle`. */
|
|
26
|
+
export declare const MEMBER_HELP: ReadonlyMap<string, ReadonlyMap<string, Help>>;
|
|
27
|
+
/** A gene's range in words, such as `3 to 16, steps of 1`. */
|
|
28
|
+
export declare function geneRange(g: GeneInfo): string;
|
|
29
|
+
/** Help for the word at `offset`, and where that word is. */
|
|
30
|
+
export declare function helpAt(program: CheckResult, offset: number): {
|
|
31
|
+
span: Span;
|
|
32
|
+
help: Help;
|
|
33
|
+
} | undefined;
|
|
34
|
+
/** What can be typed at `offset`: everything in scope, built-ins and keywords. */
|
|
35
|
+
export declare function completionsAt(program: CheckResult, offset: number): Completion[];
|
|
36
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,CAmBxC;AAID,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAoChF"}
|
package/dist/help.js
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
// Help for editors: what a name means when you point at it, and which names can be typed where.
|
|
2
|
+
// The text follows docs/LANGUAGE.md, and help.test.ts keeps every built-in covered.
|
|
3
|
+
import { BUILTIN_CONSTANTS } from "./builtins.js";
|
|
4
|
+
import { NAMED_COLOURS } from "./colour.js";
|
|
5
|
+
import { KEYWORDS, lex } from "./lexer.js";
|
|
6
|
+
import { formatValue, PATTERN_KINDS, SHAPES } from "./values.js";
|
|
7
|
+
const h = (title, text, section) => ({ title, text, section });
|
|
8
|
+
/** The built-in functions. */
|
|
9
|
+
export const FUNCTION_HELP = new Map([
|
|
10
|
+
["abs", h("abs(x)", "The absolute value of `x`.", "18.1")],
|
|
11
|
+
["sign", h("sign(x)", "−1, 0 or 1, depending on the sign of `x`.", "18.1")],
|
|
12
|
+
["floor", h("floor(x)", "`x` rounded down.", "18.1")],
|
|
13
|
+
["ceil", h("ceil(x)", "`x` rounded up.", "18.1")],
|
|
14
|
+
["round", h("round(x)", "The nearest whole number, halves rounded up.", "18.1")],
|
|
15
|
+
[
|
|
16
|
+
"frac",
|
|
17
|
+
h("frac(x)", "`x` minus its whole part, keeping the sign: `frac(-1.25)` is `-0.25`.", "18.1"),
|
|
18
|
+
],
|
|
19
|
+
["min", h("min(a, b)", "The smaller of `a` and `b`.", "18.1")],
|
|
20
|
+
["max", h("max(a, b)", "The larger of `a` and `b`.", "18.1")],
|
|
21
|
+
["clamp", h("clamp(x, lo, hi)", "`x` limited to lo..hi.", "18.1")],
|
|
22
|
+
["wrap", h("wrap(x, lo, hi)", "`x` wrapped round into lo..hi, so that hi wraps to lo.", "18.1")],
|
|
23
|
+
["bounce", h("bounce(x, lo, hi)", "`x` folded back and forth between lo and hi.", "18.1")],
|
|
24
|
+
["sqrt", h("sqrt(x)", "The square root of `x`.", "18.1")],
|
|
25
|
+
["exp", h("exp(x)", "e to the power `x`.", "18.1")],
|
|
26
|
+
["ln", h("ln(x)", "The natural logarithm of `x`.", "18.1")],
|
|
27
|
+
["log10", h("log10(x)", "The base-10 logarithm of `x`.", "18.1")],
|
|
28
|
+
["sin", h("sin(a)", "The sine of `a`, in degrees.", "18.1")],
|
|
29
|
+
["cos", h("cos(a)", "The cosine of `a`, in degrees.", "18.1")],
|
|
30
|
+
["tan", h("tan(a)", "The tangent of `a`, in degrees.", "18.1")],
|
|
31
|
+
["asin", h("asin(x)", "The angle whose sine is `x`, in degrees.", "18.1")],
|
|
32
|
+
["acos", h("acos(x)", "The angle whose cosine is `x`, in degrees.", "18.1")],
|
|
33
|
+
["atan", h("atan(x)", "The angle whose tangent is `x`, in degrees.", "18.1")],
|
|
34
|
+
["atan2", h("atan2(y, x)", "The angle of the point (x, y) from the x axis, in degrees.", "18.1")],
|
|
35
|
+
["degrees", h("degrees(r)", "Converts radians to degrees.", "18.1")],
|
|
36
|
+
["radians", h("radians(d)", "Converts degrees to radians.", "18.1")],
|
|
37
|
+
[
|
|
38
|
+
"wave",
|
|
39
|
+
h("wave(t)", "`sin(t × 360)`: one full wave (0, 1, 0, −1, 0) as `t` goes from 0 to 1.", "18.1"),
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"bump",
|
|
43
|
+
h("bump(t)", "`sin(t × 180)`: rises from 0 to 1 and back to 0 as `t` goes from 0 to 1.", "18.1"),
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
"mix",
|
|
47
|
+
h("mix(a, b, t)", "`(1 − t)·a + t·b`, for numbers, vectors and colours. Colours blend hue the short way round.", "18.1"),
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"smoothmix",
|
|
51
|
+
h("smoothmix(a, b, t)", "Like `mix`, but eases in and out. `t` is clamped to 0–1.", "18.1"),
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
"mandel",
|
|
55
|
+
h("mandel(x, y)", "How quickly the point x + iy escapes the Mandelbrot set, from 0 to 1. 1 means never.", "18.1"),
|
|
56
|
+
],
|
|
57
|
+
["vec", h("vec(x, y, z)", "The vector `(x, y, z)`.", "18.2")],
|
|
58
|
+
["length", h("length(v)", "The length of the vector `v`.", "18.2")],
|
|
59
|
+
["normalize", h("normalize(v)", "`v` scaled to length 1. The zero vector stays zero.", "18.2")],
|
|
60
|
+
["dot", h("dot(a, b)", "The dot product of two vectors.", "18.2")],
|
|
61
|
+
["cross", h("cross(a, b)", "The cross product of two vectors.", "18.2")],
|
|
62
|
+
[
|
|
63
|
+
"hsv",
|
|
64
|
+
h("hsv(h, s, v)", "A colour from hue (degrees), saturation and value, 0–1. A fourth argument is alpha.", "13.1"),
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"rgb",
|
|
68
|
+
h("rgb(r, g, b)", "A colour from red, green and blue, 0–1. A fourth argument is alpha.", "13.1"),
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"noise",
|
|
72
|
+
h("noise(x)", "Smooth noise from −1 to 1 that changes gently with `x` (a number or vector).", "18.5"),
|
|
73
|
+
],
|
|
74
|
+
["fbm", h("fbm(x)", "Fractal noise: five layers of `noise`, from −1 to 1.", "18.5")],
|
|
75
|
+
[
|
|
76
|
+
"random",
|
|
77
|
+
h("random(lo, hi)", "A random number from `lo` up to `hi`. The creature's `seed` gene decides the sequence.", "18.5"),
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"pattern",
|
|
81
|
+
h("pattern(kind, hue, seed)", "A texture: a pattern kind such as `marble`, a hue that sets the palette, and a seed.", "14"),
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"gradient",
|
|
85
|
+
h("gradient(c1, c2 at p, …)", "Colours blended along 0 to 1. Sample it like a call: `skin(0.5)`.", "13.3"),
|
|
86
|
+
],
|
|
87
|
+
]);
|
|
88
|
+
const NUMBER_CONSTANTS = new Map([
|
|
89
|
+
["pi", "π, 3.14159…"],
|
|
90
|
+
["tau", "2π, 6.28318…"],
|
|
91
|
+
["golden", "The golden ratio, 1.61803…"],
|
|
92
|
+
["sqrt2", "The square root of 2."],
|
|
93
|
+
["sqrt3", "The square root of 3."],
|
|
94
|
+
["ln2", "The natural logarithm of 2."],
|
|
95
|
+
["x_axis", "The vector `(1, 0, 0)`."],
|
|
96
|
+
["y_axis", "The vector `(0, 1, 0)`."],
|
|
97
|
+
["z_axis", "The vector `(0, 0, 1)`."],
|
|
98
|
+
["none", "No texture: `texture none`."],
|
|
99
|
+
]);
|
|
100
|
+
const SHAPE_TEXT = {
|
|
101
|
+
tube: "A cylinder 1 across and 1 long, along the heading.",
|
|
102
|
+
cube: "A cube with sides of 1.",
|
|
103
|
+
cone: "A cone 1 long along the heading, its tip at the front.",
|
|
104
|
+
ball: "A sphere 1 across.",
|
|
105
|
+
ring: "A thin torus around the heading, 1 across.",
|
|
106
|
+
donut: "A fat torus around the heading, 1 across.",
|
|
107
|
+
};
|
|
108
|
+
/** The built-in constants: numbers, vectors, colours, shapes and pattern kinds. */
|
|
109
|
+
export function constantHelp(name) {
|
|
110
|
+
const text = NUMBER_CONSTANTS.get(name);
|
|
111
|
+
if (text !== undefined)
|
|
112
|
+
return h(name, text, name === "none" ? "14" : "18.1");
|
|
113
|
+
const colour = NAMED_COLOURS.get(name);
|
|
114
|
+
if (colour) {
|
|
115
|
+
const alpha = colour.a === 1 ? "" : `, ${colour.a}`;
|
|
116
|
+
return h(name, `The colour hsv(${colour.h}, ${colour.s}, ${colour.v}${alpha}).`, "13.1");
|
|
117
|
+
}
|
|
118
|
+
if (SHAPES.includes(name))
|
|
119
|
+
return h(name, `A shape. ${SHAPE_TEXT[name]}`, "12");
|
|
120
|
+
if (PATTERN_KINDS.includes(name))
|
|
121
|
+
return h(name, "A pattern kind, for `pattern(kind, hue, seed)`.", "14");
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
/** Keywords, and the inputs `time`, `beat`, `music` and `turtle`. */
|
|
125
|
+
export const KEYWORD_HELP = new Map([
|
|
126
|
+
["creature", h("creature Name", "Starts a creature file.", "3")],
|
|
127
|
+
[
|
|
128
|
+
"gene",
|
|
129
|
+
h("gene name = value in min..max", "A value the app may change when mutating, breeding and morphing.", "6.1"),
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
"part",
|
|
133
|
+
h("part name(a, b) { … }", "A piece of creature: it may move the turtle and lay shapes.", "10"),
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
"function",
|
|
137
|
+
h("function name(a, b) { … }", "Calculates a value with `return`. It can't change the turtle or lay shapes.", "10"),
|
|
138
|
+
],
|
|
139
|
+
["return", h("return value", "Leaves a function with a value, or a part early.", "10")],
|
|
140
|
+
["let", h("let name = value", "Creates a variable in the current block.", "7")],
|
|
141
|
+
["if", h("if condition { … } else { … }", "Runs a block when the condition is true.", "9")],
|
|
142
|
+
["else", h("else { … }", "What `if` runs when its condition is false.", "9")],
|
|
143
|
+
["repeat", h("repeat n as i { … }", "Runs a block `n` times, with `i` counting from 0.", "9")],
|
|
144
|
+
["as", h("repeat n as i", "Names the counter of a `repeat` loop.", "9")],
|
|
145
|
+
[
|
|
146
|
+
"for",
|
|
147
|
+
h("for v from a to b by s { … }", "Runs a block for `v` from `a` to `b`, in steps of `s` (1 if left out).", "9"),
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
"from",
|
|
151
|
+
h("from", "In `for`: where the loop starts. In a gene: the options it chooses from.", "9"),
|
|
152
|
+
],
|
|
153
|
+
["to", h("to", "In `for`: where the loop ends.", "9")],
|
|
154
|
+
["by", h("by", "In `for`: the step.", "9")],
|
|
155
|
+
["while", h("while condition { … }", "Runs a block for as long as the condition is true.", "9")],
|
|
156
|
+
["branch", h("branch { … }", "Runs a block, then puts the turtle back as it was.", "11.5")],
|
|
157
|
+
[
|
|
158
|
+
"lay",
|
|
159
|
+
h("lay / lay { … }", "Lays the current shape, optionally with an extra shape transform.", "12"),
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
"reshape",
|
|
163
|
+
h("reshape { … }", "Changes the shape transform for every shape laid afterwards.", "11.7"),
|
|
164
|
+
],
|
|
165
|
+
[
|
|
166
|
+
"symmetric",
|
|
167
|
+
h("symmetric x { … }", "Runs a block twice, the second time mirrored. `side` is 1, then −1.", "11.6"),
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
"shape",
|
|
171
|
+
h("shape s", "The shape for later `lay`s: tube, cube, cone, ball, ring or donut.", "12"),
|
|
172
|
+
],
|
|
173
|
+
["colour", h("colour c", "The colour for later shapes.", "13.2")],
|
|
174
|
+
["color", h("color c", "The colour for later shapes.", "13.2")],
|
|
175
|
+
["shine", h("shine x", "Strength of highlights, 0–1.", "13.2")],
|
|
176
|
+
["sharpness", h("sharpness x", "How tight the highlights are, 0–1.", "13.2")],
|
|
177
|
+
["texture", h("texture p", "The texture for later shapes: a `pattern(…)`, or `none`.", "13.2")],
|
|
178
|
+
[
|
|
179
|
+
"background",
|
|
180
|
+
h("background { … fill p }", "The background the creature is shown against.", "15"),
|
|
181
|
+
],
|
|
182
|
+
["fill", h("fill p", "What the background shows: a pattern, a colour or a gradient.", "15")],
|
|
183
|
+
["dance", h("dance { … }", "The creature's dance style: how music moves it as a whole.", "17")],
|
|
184
|
+
["forward", h("forward d", "Moves the turtle `d` along its heading.", "11.2")],
|
|
185
|
+
["back", h("back d", "Moves the turtle `d` backwards.", "11.2")],
|
|
186
|
+
["move", h("move (x, y, z)", "Moves the turtle along its side, up and heading axes.", "11.2")],
|
|
187
|
+
["pitch", h("pitch a", "Turns about the side axis: positive tips the nose down.", "11.3")],
|
|
188
|
+
["yaw", h("yaw a", "Turns about the up axis, towards the side axis.", "11.3")],
|
|
189
|
+
["roll", h("roll a", "Turns about the heading.", "11.3")],
|
|
190
|
+
[
|
|
191
|
+
"rotate",
|
|
192
|
+
h("rotate a around v", "Turns `a` degrees about the axis `v`, in the turtle's own axes.", "11.3"),
|
|
193
|
+
],
|
|
194
|
+
["around", h("rotate a around v", "The axis that `rotate` turns about.", "11.3")],
|
|
195
|
+
[
|
|
196
|
+
"grow",
|
|
197
|
+
h("grow k / grow (x, y, z)", "Multiplies the turtle's size. Negative values mirror.", "11.4"),
|
|
198
|
+
],
|
|
199
|
+
["mirror", h("mirror x", "Reverses one of the turtle's axes: x, y or z.", "11.4")],
|
|
200
|
+
["in", h("gene name = v in min..max", "A gene's range.", "6.1")],
|
|
201
|
+
["step", h("in min..max step s", "A gene that moves in whole steps of `s`.", "6.1")],
|
|
202
|
+
["log", h("in min..max log", "A gene that changes by ratios rather than amounts.", "6.1")],
|
|
203
|
+
["at", h("colour at p", "Where a gradient stop sits, from 0 to 1.", "13.3")],
|
|
204
|
+
["and", h("a and b", "True if both sides are.", "8.1")],
|
|
205
|
+
["or", h("a or b", "True if either side is.", "8.1")],
|
|
206
|
+
["not", h("not a", "The opposite of a bool.", "8.1")],
|
|
207
|
+
["true", h("true", "A bool.", "5")],
|
|
208
|
+
["false", h("false", "A bool.", "5")],
|
|
209
|
+
["print", h("print(a, b, …)", "Writes its arguments to the app's console.", "18.6")],
|
|
210
|
+
[
|
|
211
|
+
"turtle",
|
|
212
|
+
h("turtle.position", "Reads the turtle: position, heading, up, side, size, mirrored, shape, colour…", "18.4"),
|
|
213
|
+
],
|
|
214
|
+
["time", h("time", "Seconds since the creature started being shown.", "16")],
|
|
215
|
+
["beat", h("beat", "Position within the current beat: 0 on the beat, rising towards 1.", "16")],
|
|
216
|
+
[
|
|
217
|
+
"music",
|
|
218
|
+
h("music.bass", "The music: `bass`, `mid`, `high`, `level` and `hit`, each 0–1.", "16"),
|
|
219
|
+
],
|
|
220
|
+
]);
|
|
221
|
+
/** The parts of `music` and `turtle`. */
|
|
222
|
+
export const MEMBER_HELP = new Map([
|
|
223
|
+
[
|
|
224
|
+
"music",
|
|
225
|
+
new Map([
|
|
226
|
+
["bass", h("music.bass", "Level of the low frequencies, 0–1.", "16")],
|
|
227
|
+
["mid", h("music.mid", "Level of the middle frequencies, 0–1.", "16")],
|
|
228
|
+
["high", h("music.high", "Level of the high frequencies, 0–1.", "16")],
|
|
229
|
+
["level", h("music.level", "Overall loudness, 0–1.", "16")],
|
|
230
|
+
["hit", h("music.hit", "Jumps up on each drum hit or note, then falls back, 0–1.", "16")],
|
|
231
|
+
]),
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
"turtle",
|
|
235
|
+
new Map([
|
|
236
|
+
[
|
|
237
|
+
"position",
|
|
238
|
+
h("turtle.position", "The turtle's position in world space (a vector).", "18.4"),
|
|
239
|
+
],
|
|
240
|
+
["heading", h("turtle.heading", "The heading, as a unit vector in world space.", "18.4")],
|
|
241
|
+
["up", h("turtle.up", "The up axis, as a unit vector.", "18.4")],
|
|
242
|
+
["side", h("turtle.side", "The side axis, as a unit vector.", "18.4")],
|
|
243
|
+
["size", h("turtle.size", "The size per axis (a vector).", "18.4")],
|
|
244
|
+
["mirrored", h("turtle.mirrored", "Whether the turtle is mirrored (a bool).", "18.4")],
|
|
245
|
+
["shape", h("turtle.shape", "The current shape.", "18.4")],
|
|
246
|
+
["colour", h("turtle.colour", "The current colour.", "18.4")],
|
|
247
|
+
["color", h("turtle.color", "The current colour.", "18.4")],
|
|
248
|
+
["shine", h("turtle.shine", "The current shine.", "18.4")],
|
|
249
|
+
["sharpness", h("turtle.sharpness", "The current sharpness.", "18.4")],
|
|
250
|
+
["texture", h("turtle.texture", "The current texture.", "18.4")],
|
|
251
|
+
]),
|
|
252
|
+
],
|
|
253
|
+
]);
|
|
254
|
+
/** A gene's range in words, such as `3 to 16, steps of 1`. */
|
|
255
|
+
export function geneRange(g) {
|
|
256
|
+
if (g.options)
|
|
257
|
+
return `one of ${g.options.map(formatValue).join(", ")}`;
|
|
258
|
+
if (g.kind === "bool")
|
|
259
|
+
return "true or false";
|
|
260
|
+
if (g.kind === "colour")
|
|
261
|
+
return g.hue?.whole ? "any hue" : `hues ${g.hue.start}° + ${g.hue.length}°`;
|
|
262
|
+
if (g.min === undefined || g.max === undefined)
|
|
263
|
+
return "";
|
|
264
|
+
let text = `${formatValue(g.min)} to ${formatValue(g.max)}`;
|
|
265
|
+
if (g.step !== undefined)
|
|
266
|
+
text += `, steps of ${g.step}`;
|
|
267
|
+
if (g.log)
|
|
268
|
+
text += ", by ratios";
|
|
269
|
+
return text;
|
|
270
|
+
}
|
|
271
|
+
const signature = (name, params) => params.length === 0 ? name : `${name}(${params.map((p) => p.name).join(", ")})`;
|
|
272
|
+
const contains = (s, offset) => s.start <= offset && offset <= s.end;
|
|
273
|
+
/** The names that can be used at `offset`, innermost last so they win over outer ones. */
|
|
274
|
+
function symbolsAt(program, offset) {
|
|
275
|
+
const out = [];
|
|
276
|
+
const geneOf = (stmt) => program.genes.find((g) => g.decl === stmt);
|
|
277
|
+
const geneSymbol = (g) => ({
|
|
278
|
+
name: g.name,
|
|
279
|
+
kind: "gene",
|
|
280
|
+
help: h(`gene ${g.fullName}`, [g.description, geneRange(g)].filter(Boolean).join(" · ") || "A gene.", "6"),
|
|
281
|
+
});
|
|
282
|
+
const variable = (name, text, section) => ({
|
|
283
|
+
name,
|
|
284
|
+
kind: "variable",
|
|
285
|
+
help: h(name, text, section),
|
|
286
|
+
});
|
|
287
|
+
// Declarations that can be used from anywhere in the creature.
|
|
288
|
+
const items = program.file.items;
|
|
289
|
+
const selfContained = items.find((s) => (s.kind === "Background" || s.kind === "Dance") && contains(s.span, offset));
|
|
290
|
+
if (!selfContained) {
|
|
291
|
+
for (const s of items) {
|
|
292
|
+
if (s.kind === "Part" || s.kind === "Function") {
|
|
293
|
+
out.push({
|
|
294
|
+
name: s.name,
|
|
295
|
+
kind: s.kind === "Part" ? "part" : "function",
|
|
296
|
+
help: h(`${s.kind === "Part" ? "part" : "function"} ${signature(s.name, s.params)}`, s.kind === "Part"
|
|
297
|
+
? "A part defined in this creature."
|
|
298
|
+
: "A function defined in this creature.", "10"),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const visit = (stmts, inBody) => {
|
|
304
|
+
for (const s of stmts) {
|
|
305
|
+
if (s.kind === "Gene") {
|
|
306
|
+
const g = geneOf(s);
|
|
307
|
+
if (g)
|
|
308
|
+
out.push(geneSymbol(g));
|
|
309
|
+
}
|
|
310
|
+
else if (s.kind === "Let" && s.span.start < offset) {
|
|
311
|
+
out.push(variable(s.name, inBody ? "A variable." : "A global variable.", "7"));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
for (const s of stmts) {
|
|
315
|
+
if (!contains(s.span, offset))
|
|
316
|
+
continue;
|
|
317
|
+
const into = (b) => {
|
|
318
|
+
if (b && contains(b.span, offset))
|
|
319
|
+
visit(b.items, inBody);
|
|
320
|
+
};
|
|
321
|
+
switch (s.kind) {
|
|
322
|
+
case "Part":
|
|
323
|
+
case "Function":
|
|
324
|
+
if (!contains(s.body.span, offset))
|
|
325
|
+
break;
|
|
326
|
+
for (const p of s.params)
|
|
327
|
+
out.push(variable(p.name, `A parameter of \`${s.name}\`.`, "10"));
|
|
328
|
+
visit(s.body.items, true);
|
|
329
|
+
break;
|
|
330
|
+
case "Background":
|
|
331
|
+
case "Dance":
|
|
332
|
+
into(s.body);
|
|
333
|
+
break;
|
|
334
|
+
case "If":
|
|
335
|
+
for (const b of s.branches)
|
|
336
|
+
into(b.block);
|
|
337
|
+
into(s.elseBlock);
|
|
338
|
+
break;
|
|
339
|
+
case "Repeat":
|
|
340
|
+
if (s.as && contains(s.block.span, offset))
|
|
341
|
+
out.push(variable(s.as.name, "The loop's counter, from 0.", "9"));
|
|
342
|
+
into(s.block);
|
|
343
|
+
break;
|
|
344
|
+
case "For":
|
|
345
|
+
if (contains(s.block.span, offset))
|
|
346
|
+
out.push(variable(s.variable.name, "The loop's variable.", "9"));
|
|
347
|
+
into(s.block);
|
|
348
|
+
break;
|
|
349
|
+
case "Symmetric":
|
|
350
|
+
if (contains(s.block.span, offset))
|
|
351
|
+
out.push(variable("side", "1 on the first run, −1 on the mirrored one.", "11.6"));
|
|
352
|
+
into(s.block);
|
|
353
|
+
break;
|
|
354
|
+
case "While":
|
|
355
|
+
case "Branch":
|
|
356
|
+
case "Reshape":
|
|
357
|
+
case "Lay":
|
|
358
|
+
into(s.block);
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
visit(selfContained ? [selfContained] : items, false);
|
|
364
|
+
return out;
|
|
365
|
+
}
|
|
366
|
+
// ---------- hover ----------
|
|
367
|
+
/** The token at `offset`, counting a position just after a word as on it. */
|
|
368
|
+
function tokenAt(tokens, offset) {
|
|
369
|
+
return tokens.findIndex((t) => t.kind !== "newline" && t.kind !== "eof" && t.span.start <= offset && offset <= t.span.end);
|
|
370
|
+
}
|
|
371
|
+
/** Help for the word at `offset`, and where that word is. */
|
|
372
|
+
export function helpAt(program, offset) {
|
|
373
|
+
const { tokens } = lex(program.text);
|
|
374
|
+
const i = tokenAt(tokens, offset);
|
|
375
|
+
const t = tokens[i];
|
|
376
|
+
if (!t || (t.kind !== "name" && t.kind !== "keyword"))
|
|
377
|
+
return undefined;
|
|
378
|
+
const found = (help) => (help ? { span: t.span, help } : undefined);
|
|
379
|
+
// `music.bass`, `turtle.heading`: the word after the dot.
|
|
380
|
+
const dot = tokens[i - 1];
|
|
381
|
+
const owner = tokens[i - 2];
|
|
382
|
+
if (dot?.text === "." && owner && MEMBER_HELP.has(owner.text)) {
|
|
383
|
+
return found(MEMBER_HELP.get(owner.text).get(t.text));
|
|
384
|
+
}
|
|
385
|
+
if (t.kind === "name") {
|
|
386
|
+
const symbols = symbolsAt(program, offset).filter((s) => s.name === t.text);
|
|
387
|
+
if (symbols.length > 0)
|
|
388
|
+
return found(symbols[symbols.length - 1].help);
|
|
389
|
+
return found(FUNCTION_HELP.get(t.text) ?? constantHelp(t.text));
|
|
390
|
+
}
|
|
391
|
+
return found(KEYWORD_HELP.get(t.text));
|
|
392
|
+
}
|
|
393
|
+
// ---------- completion ----------
|
|
394
|
+
/** What can be typed at `offset`: everything in scope, built-ins and keywords. */
|
|
395
|
+
export function completionsAt(program, offset) {
|
|
396
|
+
// After `music.` or `turtle.`, only their parts.
|
|
397
|
+
const before = lex(program.text).tokens.filter((t) => t.kind !== "newline" && t.kind !== "eof" && t.span.end <= offset);
|
|
398
|
+
let k = before.length - 1;
|
|
399
|
+
const last = before[k];
|
|
400
|
+
if (last && (last.kind === "name" || last.kind === "keyword") && last.span.end === offset)
|
|
401
|
+
k--;
|
|
402
|
+
const dot = before[k];
|
|
403
|
+
const owner = before[k - 1];
|
|
404
|
+
if (dot?.text === "." && owner && MEMBER_HELP.has(owner.text)) {
|
|
405
|
+
return [...MEMBER_HELP.get(owner.text).entries()].map(([label, help]) => ({
|
|
406
|
+
label,
|
|
407
|
+
kind: "member",
|
|
408
|
+
detail: help.text,
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
const out = new Map();
|
|
412
|
+
const add = (c) => out.set(c.label, c);
|
|
413
|
+
for (const k of KEYWORDS) {
|
|
414
|
+
if (k === "time" || k === "beat" || k === "music" || k === "turtle") {
|
|
415
|
+
add({ label: k, kind: "input", detail: KEYWORD_HELP.get(k).text });
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
add({ label: k, kind: "keyword", detail: KEYWORD_HELP.get(k)?.title ?? "" });
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
for (const [name, help] of FUNCTION_HELP)
|
|
422
|
+
add({ label: name, kind: "function", detail: help.title });
|
|
423
|
+
for (const name of BUILTIN_CONSTANTS.keys()) {
|
|
424
|
+
add({ label: name, kind: "constant", detail: constantHelp(name)?.text ?? "" });
|
|
425
|
+
}
|
|
426
|
+
for (const s of symbolsAt(program, offset)) {
|
|
427
|
+
add({ label: s.name, kind: s.kind, detail: s.kind === "gene" ? s.help.text : s.help.title });
|
|
428
|
+
}
|
|
429
|
+
return [...out.values()];
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=help.js.map
|
package/dist/help.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,oFAAoF;AAGpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAc,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqBjE,MAAM,CAAC,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,OAAe,EAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAE7F,8BAA8B;AAC9B,MAAM,CAAC,MAAM,aAAa,GAA8B,IAAI,GAAG,CAAC;IAC9D,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,4BAA4B,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,2CAA2C,EAAE,MAAM,CAAC,CAAC;IAC3E,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,8CAA8C,EAAE,MAAM,CAAC,CAAC;IAChF;QACE,MAAM;QACN,CAAC,CAAC,SAAS,EAAE,uEAAuE,EAAE,MAAM,CAAC;KAC9F;IACD,CAAC,KAAK,EAAE,CAAC,CAAC,WA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,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,aAAa;QACtC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7D,KAAK,MAAM,IAAI,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5C,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export { check, type CheckResult } from "./checker.js";
|
|
|
7
7
|
export { format, formatText, type FormatResult } from "./format.js";
|
|
8
8
|
export { build, buildBackground, DEFAULT_LIMITS, type BackgroundResult, type BuildOptions, type BuildResult, type Inputs, type LaidShape, type Limits, type MusicInputs, } from "./interpreter.js";
|
|
9
9
|
export type { GeneInfo, GeneKind, GeneSection, HueArc } from "./genes.js";
|
|
10
|
+
export { breed, geneEdits, geneLiteral, morph, mutate, valuesOf, writeGenes, type GeneSet, type GeneticsOptions, type GeneValues, type MutateOptions, } from "./genetics.js";
|
|
11
|
+
export { completionsAt, constantHelp, FUNCTION_HELP, geneRange, helpAt, KEYWORD_HELP, MEMBER_HELP, type Completion, type CompletionKind, type Help, } from "./help.js";
|
|
12
|
+
export { mulberry32 } from "./noise.js";
|
|
10
13
|
export { BUILTIN_CONSTANTS, BUILTIN_FUNCTIONS, isBuiltinName, type BuiltinFunction, } from "./builtins.js";
|
|
11
14
|
export { hsv, rgb, hexColour, toRgb, mixColour, sampleGradient, NAMED_COLOURS } from "./colour.js";
|
|
12
15
|
export { formatValue, typeOf, SHAPES, PATTERN_KINDS } from "./values.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,6CAA6C;AAC7C,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC,mBAAmB,UAAU,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,KAAK,EACL,eAAe,EACf,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,MAA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1,5 +1,5 @@
|
|
|
1
1
|
// The GenoCode language: lexer, parser, checker, formatter and interpreter
|
|
2
|
-
// (docs/LANGUAGE.md)
|
|
2
|
+
// (docs/LANGUAGE.md), and genetics: mutating, breeding and morphing genes.
|
|
3
3
|
/** The file extension for GenoCode files. */
|
|
4
4
|
export const FILE_EXTENSION = ".genie";
|
|
5
5
|
export { lex, KEYWORDS } from "./lexer.js";
|
|
@@ -7,6 +7,9 @@ export { parse } from "./parser.js";
|
|
|
7
7
|
export { check } from "./checker.js";
|
|
8
8
|
export { format, formatText } from "./format.js";
|
|
9
9
|
export { build, buildBackground, DEFAULT_LIMITS, } from "./interpreter.js";
|
|
10
|
+
export { breed, geneEdits, geneLiteral, morph, mutate, valuesOf, writeGenes, } from "./genetics.js";
|
|
11
|
+
export { completionsAt, constantHelp, FUNCTION_HELP, geneRange, helpAt, KEYWORD_HELP, MEMBER_HELP, } from "./help.js";
|
|
12
|
+
export { mulberry32 } from "./noise.js";
|
|
10
13
|
export { BUILTIN_CONSTANTS, BUILTIN_FUNCTIONS, isBuiltinName, } from "./builtins.js";
|
|
11
14
|
export { hsv, rgb, hexColour, toRgb, mixColour, sampleGradient, NAMED_COLOURS } from "./colour.js";
|
|
12
15
|
export { formatValue, typeOf, SHAPES, PATTERN_KINDS } from "./values.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAE3E,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAGvC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAA8C,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,KAAK,EAAoB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAoB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,KAAK,EACL,eAAe,EACf,cAAc,GAQf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,KAAK,EACL,SAAS,EACT,WAAW,EACX,KAAK,EACL,MAAM,EACN,QAAQ,EACR,UAAU,GAKX,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,WAAW,GAIZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GAEd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAWzE,OAAO,EACL,gBAAgB,EAChB,OAAO,GAKR,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
package/reference/LANGUAGE.md
CHANGED
|
@@ -912,6 +912,16 @@ A morph through several creatures (a loop) is a chain of these morphs between ne
|
|
|
912
912
|
and B share a program, a morph is smooth all the way; when their programs differ, the creature
|
|
913
913
|
changes shape at the halfway point.
|
|
914
914
|
|
|
915
|
+
### 19.4 Saving
|
|
916
|
+
|
|
917
|
+
A creature that has been mutated, bred or morphed is saved as an ordinary creature file: its
|
|
918
|
+
program, with each gene's new value written into the gene's line. Nothing else in the program
|
|
919
|
+
changes, except that the file is laid out by the formatter, and a gene whose value hasn't changed
|
|
920
|
+
keeps the text it was written with. The new values are written readably: stepped numbers exactly,
|
|
921
|
+
other numbers to four significant figures, colours as `hsv(…)`, and choices by name, always within
|
|
922
|
+
the gene's range. The automatic `seed` gene has no line of its own, so it isn't saved yet: a saved
|
|
923
|
+
creature that uses `random` starts again from seed 0.
|
|
924
|
+
|
|
915
925
|
## 20. Building a creature
|
|
916
926
|
|
|
917
927
|
1. **Checking.** The file is read and checked: syntax, names, gene rules, function rules, and types
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
creature StarBurstShell
|
|
2
|
+
// A spiraling geometric shell composed of bead spikes that unfurls into a sprawling celestial star.
|
|
3
|
+
// Fixed color gene ranges and reserved keyword variables.
|
|
4
|
+
|
|
5
|
+
gene unfurl = 0.45 in 0..1 // 0 packs the spikes into a tight spiral shell; 1 explodes them into a star
|
|
6
|
+
gene gloss = 0.75 in 0..1 // intensity of the metallic shell sheen
|
|
7
|
+
gene focus = 0.40 in 0..1 // sharpness of the light reflections
|
|
8
|
+
gene heightOffset = 8.0 in -15..15 // vertical expansion amplitude as it opens
|
|
9
|
+
|
|
10
|
+
shine gloss
|
|
11
|
+
sharpness focus
|
|
12
|
+
|
|
13
|
+
// Wrap the top-level part call in a branch to protect downstream rendering
|
|
14
|
+
branch {
|
|
15
|
+
shellSpikes
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
forward heightOffset * unfurl
|
|
19
|
+
pitch 90
|
|
20
|
+
|
|
21
|
+
// Generate 6 primary crown spikes circling the top axis
|
|
22
|
+
repeat 6 {
|
|
23
|
+
branch {
|
|
24
|
+
crownSpike
|
|
25
|
+
}
|
|
26
|
+
yaw 60
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The core body structure: 10 concentric, winding layers of beads
|
|
30
|
+
part shellSpikes {
|
|
31
|
+
gene maxRadius = 12 in 5..20
|
|
32
|
+
gene baseBeadSize = 0.75 in 0.2..1.5
|
|
33
|
+
|
|
34
|
+
// Galactic neon palette gradient with mandatory range specifications
|
|
35
|
+
gene coreColor = hsv(240, 0.85, 0.2) in hsv(0, 0, 0)..hsv(360, 1, 1) // Deep space blue
|
|
36
|
+
gene midColor1 = hsv(300, 0.90, 0.5) in hsv(0, 0, 0)..hsv(360, 1, 1) // Cosmic magenta
|
|
37
|
+
gene midColor2 = hsv(340, 0.95, 0.8) in hsv(0, 0, 0)..hsv(360, 1, 1) // Electric pink
|
|
38
|
+
gene outerColor = hsv(15, 0.80, 0.95) in hsv(0, 0, 0)..hsv(360, 1, 1) // Nebula orange
|
|
39
|
+
|
|
40
|
+
let skin = gradient(coreColor, midColor1, midColor2, outerColor)
|
|
41
|
+
shape ball
|
|
42
|
+
|
|
43
|
+
repeat 10 as layer {
|
|
44
|
+
let latAngle = 180 * layer / 10
|
|
45
|
+
colour skin(layer / 10)
|
|
46
|
+
|
|
47
|
+
// As unfurl approaches 1, structural layout transitions from flat spirals to a wide-latitude sphere
|
|
48
|
+
let distance = mix(layer, sin(latAngle) * maxRadius, unfurl)
|
|
49
|
+
let verticalZ = unfurl * cos(latAngle) * maxRadius
|
|
50
|
+
let stepCount = tau * layer
|
|
51
|
+
|
|
52
|
+
repeat floor(stepCount) as s {
|
|
53
|
+
let lonAngle = 360 * s / stepCount
|
|
54
|
+
|
|
55
|
+
branch {
|
|
56
|
+
// Positional placement using standard trigonometric displacement
|
|
57
|
+
move (distance * cos(lonAngle), distance * sin(lonAngle), verticalZ)
|
|
58
|
+
lay { grow baseBeadSize }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// A twisting, needle-sharp spike branch that reacts heavily to the unfurl gene
|
|
65
|
+
part crownSpike {
|
|
66
|
+
gene twistFactor = 1.25 in -3..3 // how sharply the crown arms curve outward
|
|
67
|
+
|
|
68
|
+
// Crown color parameters with mandatory range specifications
|
|
69
|
+
gene rootColor = hsv(160, 0.70, 0.6) in hsv(0, 0, 0)..hsv(360, 1, 1) // Turquoise heart
|
|
70
|
+
gene bodyColor = hsv(200, 0.80, 0.8) in hsv(0, 0, 0)..hsv(360, 1, 1) // Cyan mid-section
|
|
71
|
+
gene flareColor = hsv(280, 0.85, 0.7) in hsv(0, 0, 0)..hsv(360, 1, 1) // Violet edge
|
|
72
|
+
gene apexColor = hsv(0, 0.0, 1.0) in hsv(0, 0, 0)..hsv(360, 1, 1) // Pure white tips
|
|
73
|
+
|
|
74
|
+
let skin = gradient(rootColor, bodyColor, flareColor, apexColor)
|
|
75
|
+
|
|
76
|
+
branch {
|
|
77
|
+
forward 3.0
|
|
78
|
+
pitch -25
|
|
79
|
+
yaw 15
|
|
80
|
+
roll 45
|
|
81
|
+
shape ball
|
|
82
|
+
|
|
83
|
+
// Iteratively chain 25 progressively scaling segments to build a fine tip
|
|
84
|
+
for segment from 1 to 25 {
|
|
85
|
+
let taper = bump(segment / 26) // custom envelope tracking
|
|
86
|
+
colour skin(taper)
|
|
87
|
+
|
|
88
|
+
yaw 8
|
|
89
|
+
branch {
|
|
90
|
+
forward 0.15
|
|
91
|
+
pitch 45 * taper * twistFactor
|
|
92
|
+
// Drastically changes length/width profile when unrolled
|
|
93
|
+
lay { grow (unfurl, unfurl, unfurl * 4 * (taper + 0.5)) }
|
|
94
|
+
}
|
|
95
|
+
move (0.35 * unfurl, 0, 0)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
background {
|
|
101
|
+
fill gradient(hsv(275, 0.6, 0.08), hsv(220, 0.5, 0.25))
|
|
102
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
creature StarBurstShell
|
|
2
|
+
// A spiraling geometric shell composed of bead spikes that unfurls into a sprawling celestial star.
|
|
3
|
+
// Fixed color gene ranges and reserved keyword variables.
|
|
4
|
+
|
|
5
|
+
gene unfurl = 0.2016 in 0..1 // 0 packs the spikes into a tight spiral shell; 1 explodes them into a star
|
|
6
|
+
gene gloss = 0.5104 in 0..1 // intensity of the metallic shell sheen
|
|
7
|
+
gene focus = 0.3599 in 0..1 // sharpness of the light reflections
|
|
8
|
+
gene heightOffset = 9.545 in -15..15 // vertical expansion amplitude as it opens
|
|
9
|
+
|
|
10
|
+
shine gloss
|
|
11
|
+
sharpness focus
|
|
12
|
+
|
|
13
|
+
// Wrap the top-level part call in a branch to protect downstream rendering
|
|
14
|
+
branch {
|
|
15
|
+
shellSpikes
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
forward heightOffset * unfurl
|
|
19
|
+
pitch 90
|
|
20
|
+
|
|
21
|
+
// Generate 6 primary crown spikes circling the top axis
|
|
22
|
+
repeat 6 {
|
|
23
|
+
branch {
|
|
24
|
+
crownSpike
|
|
25
|
+
}
|
|
26
|
+
yaw 60
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The core body structure: 10 concentric, winding layers of beads
|
|
30
|
+
part shellSpikes {
|
|
31
|
+
gene maxRadius = 10.95 in 5..20
|
|
32
|
+
gene baseBeadSize = 0.6653 in 0.2..1.5
|
|
33
|
+
|
|
34
|
+
// Galactic neon palette gradient with mandatory range specifications
|
|
35
|
+
gene coreColor = hsv(240, 0.85, 0.2) in hsv(0, 0, 0)..hsv(360, 1, 1) // Deep space blue
|
|
36
|
+
gene midColor1 = hsv(300, 0.87, 0.49) in hsv(0, 0, 0)..hsv(360, 1, 1) // Cosmic magenta
|
|
37
|
+
gene midColor2 = hsv(35.9, 0.81, 0.71) in hsv(0, 0, 0)..hsv(360, 1, 1) // Electric pink
|
|
38
|
+
gene outerColor = hsv(38.8, 0.79, 0.75) in hsv(0, 0, 0)..hsv(360, 1, 1) // Nebula orange
|
|
39
|
+
|
|
40
|
+
let skin = gradient(coreColor, midColor1, midColor2, outerColor)
|
|
41
|
+
shape ball
|
|
42
|
+
|
|
43
|
+
repeat 10 as layer {
|
|
44
|
+
let latAngle = 180 * layer / 10
|
|
45
|
+
colour skin(layer / 10)
|
|
46
|
+
|
|
47
|
+
// As unfurl approaches 1, structural layout transitions from flat spirals to a wide-latitude sphere
|
|
48
|
+
let distance = mix(layer, sin(latAngle) * maxRadius, unfurl)
|
|
49
|
+
let verticalZ = unfurl * cos(latAngle) * maxRadius
|
|
50
|
+
let stepCount = tau * layer
|
|
51
|
+
|
|
52
|
+
repeat floor(stepCount) as s {
|
|
53
|
+
let lonAngle = 360 * s / stepCount
|
|
54
|
+
|
|
55
|
+
branch {
|
|
56
|
+
// Positional placement using standard trigonometric displacement
|
|
57
|
+
move (distance * cos(lonAngle), distance * sin(lonAngle), verticalZ)
|
|
58
|
+
lay { grow baseBeadSize }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// A twisting, needle-sharp spike branch that reacts heavily to the unfurl gene
|
|
65
|
+
part crownSpike {
|
|
66
|
+
gene twistFactor = 1.161 in -3..3 // how sharply the crown arms curve outward
|
|
67
|
+
|
|
68
|
+
// Crown color parameters with mandatory range specifications
|
|
69
|
+
gene rootColor = hsv(184.3, 0.71, 0.68) in hsv(0, 0, 0)..hsv(360, 1, 1) // Turquoise heart
|
|
70
|
+
gene bodyColor = hsv(184.8, 0.8, 0.76) in hsv(0, 0, 0)..hsv(360, 1, 1) // Cyan mid-section
|
|
71
|
+
gene flareColor = hsv(253.4, 0.74, 0.7) in hsv(0, 0, 0)..hsv(360, 1, 1) // Violet edge
|
|
72
|
+
gene apexColor = hsv(0, 0.03, 1) in hsv(0, 0, 0)..hsv(360, 1, 1) // Pure white tips
|
|
73
|
+
|
|
74
|
+
let skin = gradient(rootColor, bodyColor, flareColor, apexColor)
|
|
75
|
+
|
|
76
|
+
branch {
|
|
77
|
+
forward 3.0
|
|
78
|
+
pitch -25
|
|
79
|
+
yaw 15
|
|
80
|
+
roll 45
|
|
81
|
+
shape ball
|
|
82
|
+
|
|
83
|
+
// Iteratively chain 25 progressively scaling segments to build a fine tip
|
|
84
|
+
for segment from 1 to 25 {
|
|
85
|
+
let taper = bump(segment / 26) // custom envelope tracking
|
|
86
|
+
colour skin(taper)
|
|
87
|
+
|
|
88
|
+
yaw 8
|
|
89
|
+
branch {
|
|
90
|
+
forward 0.15
|
|
91
|
+
pitch 45 * taper * twistFactor
|
|
92
|
+
// Drastically changes length/width profile when unrolled
|
|
93
|
+
lay { grow (unfurl, unfurl, unfurl * 4 * (taper + 0.5)) }
|
|
94
|
+
}
|
|
95
|
+
move (0.35 * unfurl, 0, 0)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
background {
|
|
101
|
+
fill gradient(hsv(275, 0.6, 0.08), hsv(220, 0.5, 0.25))
|
|
102
|
+
}
|