@swf2es/render 0.1.44 → 0.1.46
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/README.md +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/ramps.d.ts +31 -0
- package/dist/ramps.d.ts.map +1 -0
- package/dist/ramps.js +130 -0
- package/dist/ramps.js.map +1 -0
- package/dist/rows.d.ts +28 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +32 -1
- package/dist/rows.js.map +1 -1
- package/dist/scene.d.ts +6 -0
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +6 -0
- package/dist/scene.js.map +1 -1
- package/dist/spans.js +2 -2
- package/dist/spans.js.map +1 -1
- package/dist/textures.d.ts +42 -0
- package/dist/textures.d.ts.map +1 -1
- package/dist/textures.js +80 -14
- package/dist/textures.js.map +1 -1
- package/dist/webgl/backend.d.ts +7 -0
- package/dist/webgl/backend.d.ts.map +1 -1
- package/dist/webgl/backend.js +21 -5
- package/dist/webgl/backend.js.map +1 -1
- package/dist/webgl/draws.d.ts +50 -29
- package/dist/webgl/draws.d.ts.map +1 -1
- package/dist/webgl/draws.js +185 -85
- package/dist/webgl/draws.js.map +1 -1
- package/dist/webgl/gpu-textures.d.ts +31 -1
- package/dist/webgl/gpu-textures.d.ts.map +1 -1
- package/dist/webgl/gpu-textures.js +146 -4
- package/dist/webgl/gpu-textures.js.map +1 -1
- package/dist/webgl/programs.d.ts +40 -9
- package/dist/webgl/programs.d.ts.map +1 -1
- package/dist/webgl/programs.js +111 -18
- package/dist/webgl/programs.js.map +1 -1
- package/dist/webgl/ramps.d.ts +54 -0
- package/dist/webgl/ramps.d.ts.map +1 -0
- package/dist/webgl/ramps.js +277 -0
- package/dist/webgl/ramps.js.map +1 -0
- package/package.json +6 -2
- package/src/index.ts +11 -0
- package/src/ramps.ts +188 -0
- package/src/rows.ts +34 -1
- package/src/scene.ts +6 -0
- package/src/spans.ts +2 -2
- package/src/textures.ts +102 -14
- package/src/webgl/backend.ts +22 -5
- package/src/webgl/draws.ts +252 -91
- package/src/webgl/gpu-textures.ts +185 -5
- package/src/webgl/programs.ts +124 -18
- package/src/webgl/ramps.ts +338 -0
package/dist/webgl/programs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TARGET_TEXEL } from "../geometry.js";
|
|
2
|
-
import { ROWS_A_LINE } from "../rows.js";
|
|
2
|
+
import { RADIAL, RADIAL_LEAST_STEP, ROWS_A_LINE } from "../rows.js";
|
|
3
3
|
import { ADD, ALPHA, BELOW_CLEARED, BELOW_INVERTED, BELOW_SUBTRACTED, DARKEN, DIFFERENCE, ERASE, HARDLIGHT, INVERT, LAYER, LIGHTEN, MULTIPLY, NORMAL, OVERLAY, SCREEN, SUBTRACT, } from "../scene.js";
|
|
4
4
|
/** Texels a row (ROW_FLOATS over four). */
|
|
5
5
|
export const ROW_TEXELS = 4;
|
|
@@ -82,11 +82,15 @@ if (FILL_TEXTURES >= STAGE_TEXEL) {
|
|
|
82
82
|
* `multi`, a merged fill's vertices carry as aDraw where its packed row is
|
|
83
83
|
* in uMergedRows, which the stream keeps for its copy, so that the row
|
|
84
84
|
* changes from frame to frame where the vertices need not; the atlas leaves
|
|
85
|
-
* that attribute disabled and negative.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
85
|
+
* that attribute disabled and negative. A row's line (Rows.line) puts the
|
|
86
|
+
* texel on that line of its texture. With `radial`, a radial gradient's
|
|
87
|
+
* row (Rows.radial) passes on its focal point and its ramp's line in
|
|
88
|
+
* vRadial, the texel its square's place, which the fragment takes to the
|
|
89
|
+
* ramp (radialFillFragment). With `stage`, the stage fill program's
|
|
90
|
+
* (stageFillFragment), a texel of TARGET_TEXEL or below samples the
|
|
91
|
+
* stage's pixel under the fragment instead.
|
|
88
92
|
*/
|
|
89
|
-
export const fillVertex = (multi, merged = multi, stage = false) => `#version 300 es
|
|
93
|
+
export const fillVertex = (multi, merged = multi, stage = false, radial = false) => `#version 300 es
|
|
90
94
|
${multi ? "#extension GL_ANGLE_multi_draw : require" : ""}
|
|
91
95
|
precision highp float;
|
|
92
96
|
layout(location = ${POSITION_AT}) in vec2 aPosition;
|
|
@@ -102,6 +106,7 @@ out vec2 vTexel;
|
|
|
102
106
|
flat out vec4 vMul;
|
|
103
107
|
flat out vec4 vAdd;
|
|
104
108
|
flat out int vSlot;
|
|
109
|
+
${radial ? "flat out vec3 vRadial;" : ""}
|
|
105
110
|
|
|
106
111
|
void main(void) {
|
|
107
112
|
int draw = ${merged ? `aDraw >= 0 ? texelFetch(uMergedRows, ivec2(aDraw & ${MERGED_LINE - 1}, aDraw >> ${Math.log2(MERGED_LINE)}), 0).r : ` : ""}${multi ? `texelFetch(uRunTable, ivec2((uRunBase + gl_DrawID) & ${RUN_MOST - 1}, (uRunBase + gl_DrawID) >> ${Math.log2(RUN_MOST)}), 0).r` : "uRow"};
|
|
@@ -119,12 +124,23 @@ void main(void) {
|
|
|
119
124
|
|
|
120
125
|
gl_Position = vec4(p * uView.xy + uView.zw, 0.0, 1.0);
|
|
121
126
|
vColor = aColor;
|
|
127
|
+
// A ramp kept as a line of a texture of many (Rows.line) is read on that line's centre, a
|
|
128
|
+
// texture of its own on its middle${radial ? "; a radial gradient's, at the place the fragment finds" : ""}.
|
|
129
|
+
${radial
|
|
130
|
+
? ` // Its x the least the place is read at, the middle of the row's least entry: above 0, which
|
|
131
|
+
// tells the fragment to take its place to the ramp.
|
|
132
|
+
bool radial = t.w > 0.0;
|
|
133
|
+
float least = floor((t.w - ${(RADIAL - 1).toFixed(1)}) / ${RADIAL_LEAST_STEP.toFixed(1)});
|
|
134
|
+
float focal = t.w - ${RADIAL.toFixed(1)} - least * ${RADIAL_LEAST_STEP.toFixed(1)};
|
|
135
|
+
vRadial = radial ? vec3(least + 0.5, focal, t.z > 0.0 ? t.z : 0.5) : vec3(0.0);
|
|
136
|
+
vec2 texel = !radial && t.z > 0.0 ? vec2(aTexel.x, t.z) : aTexel;`
|
|
137
|
+
: " vec2 texel = t.z > 0.0 ? vec2(aTexel.x, t.z) : aTexel;"}
|
|
122
138
|
${stage
|
|
123
139
|
? ` // The fragment finds the stage's pixel from its place (STAGE_TEXEL in vSlot).
|
|
124
140
|
bool onStage = aTexel.x <= ${TARGET_TEXEL / 2};
|
|
125
|
-
vTexel = onStage ? p :
|
|
141
|
+
vTexel = onStage ? p : texel;
|
|
126
142
|
vSlot |= onStage ? ${STAGE_TEXEL} : 0;`
|
|
127
|
-
: " vTexel =
|
|
143
|
+
: " vTexel = texel;"}
|
|
128
144
|
}
|
|
129
145
|
`;
|
|
130
146
|
/**
|
|
@@ -138,20 +154,65 @@ ${stage
|
|
|
138
154
|
const slotTexel = Array.from({ length: FILL_TEXTURES }, (_, k) => ` case ${k + 1}:
|
|
139
155
|
t = textureLod(uTextures[${k}], at / vec2(textureSize(uTextures[${k}], 0)), 0.0);
|
|
140
156
|
break;`).join("\n");
|
|
157
|
+
/** Texels a gradient's ramp has across, its line's (Textures.addLine) or a texture's of its own. */
|
|
158
|
+
const RAMP_TEXELS = 256;
|
|
159
|
+
/**
|
|
160
|
+
* Where p, in the gradient square's place (a unit its radius), lies out
|
|
161
|
+
* from the focal point (f, 0) to the circle along the ray through it, as
|
|
162
|
+
* display/gradients.ts's radialPlace finds it: 0 at the focus, 1 on the
|
|
163
|
+
* circle; on a focus off the centre 1, the last stop, and on the centre of
|
|
164
|
+
* one centred 0, which the row's least entry raises (Rows.radial: 8 for a
|
|
165
|
+
* padded one). 1 / s where the ray f + s d meets the circle, in whichever
|
|
166
|
+
* of its two forms subtracts nothing, as a float's few digits would lose a
|
|
167
|
+
* focus near the circle's. A point so far out that its square overflows,
|
|
168
|
+
* as a matrix all but collapsed puts one, is as far out as it is across.
|
|
169
|
+
*/
|
|
170
|
+
export const radialPlace = `float radialPlace(vec2 p, float f) {
|
|
171
|
+
vec2 d = vec2(p.x - f, p.y);
|
|
172
|
+
float across = max(abs(d.x), abs(d.y));
|
|
173
|
+
if (across > 1e18) {
|
|
174
|
+
return across;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
float dd = dot(d, d);
|
|
178
|
+
if (dd < 1e-12) {
|
|
179
|
+
return f != 0.0 ? 1.0 : 0.0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
float fd = f * d.x;
|
|
183
|
+
float k = 1.0 - f * f;
|
|
184
|
+
float root = sqrt(max(fd * fd + dd * k, 0.0));
|
|
185
|
+
if (fd <= 0.0) {
|
|
186
|
+
float den = root - fd;
|
|
187
|
+
return den > 0.0 ? dd / den : 1.0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return k > 0.0 ? (root + fd) / k : 1.0;
|
|
191
|
+
}`;
|
|
192
|
+
/** A radial gradient's texel moved to its ramp's entry at the fragment's place (radialPlace). */
|
|
193
|
+
const radialAt = ` if (vRadial.x > 0.0) {
|
|
194
|
+
// Rounded to the nearest entry, as Flash reads a radial's ramp (radialIndex).
|
|
195
|
+
float entry = radialPlace(vTexel, vRadial.y) * ${RAMP_TEXELS.toFixed(1)} + 0.5;
|
|
196
|
+
at = vec2(max(entry, vRadial.x), vRadial.z);
|
|
197
|
+
}
|
|
198
|
+
`;
|
|
141
199
|
/**
|
|
142
200
|
* Flash's colour transform on the straight colour, clamped, then
|
|
143
201
|
* premultiplied for blending: the vertex' colour, or with a texture the
|
|
144
202
|
* texel's (premultiplied in the texture) times it, as the colour batcher
|
|
145
|
-
* did, a clear texel staying clear. With `
|
|
146
|
-
* (
|
|
203
|
+
* did, a clear texel staying clear. With `radial`, a radial gradient's
|
|
204
|
+
* texel is its ramp's at the fragment's place (radialPlace), each pixel's
|
|
205
|
+
* own as Flash finds it (radialFillFragment). With `stage`, the stage fill
|
|
206
|
+
* program's (stageFillFragment).
|
|
147
207
|
*/
|
|
148
|
-
const fillFragmentOf = (stage) => `#version 300 es
|
|
208
|
+
const fillFragmentOf = (stage, radial) => `#version 300 es
|
|
149
209
|
precision highp float;
|
|
150
210
|
in vec4 vColor;
|
|
151
211
|
in vec2 vTexel;
|
|
152
212
|
flat in vec4 vMul;
|
|
153
213
|
flat in vec4 vAdd;
|
|
154
214
|
flat in int vSlot;
|
|
215
|
+
${radial ? "flat in vec3 vRadial;" : ""}
|
|
155
216
|
uniform sampler2D uTextures[${FILL_TEXTURES}];
|
|
156
217
|
${stage ? "uniform vec4 uStage;\n" : ""}out vec4 finalColor;
|
|
157
218
|
|
|
@@ -175,10 +236,14 @@ ${slotTexel}
|
|
|
175
236
|
return t;
|
|
176
237
|
}
|
|
177
238
|
|
|
239
|
+
${radial ? radialPlace : ""}
|
|
240
|
+
|
|
178
241
|
void main(void) {
|
|
179
242
|
vec4 straight = vColor;
|
|
180
243
|
if (${stage ? `(vSlot & ${STAGE_TEXEL - 1})` : "vSlot"} != 0) {
|
|
181
|
-
|
|
244
|
+
vec2 at = vTexel;
|
|
245
|
+
${radial ? radialAt : ""}
|
|
246
|
+
vec4 t = texel(at);
|
|
182
247
|
if (t.a == 0.0) {
|
|
183
248
|
finalColor = vec4(0.0);
|
|
184
249
|
return;
|
|
@@ -191,8 +256,20 @@ void main(void) {
|
|
|
191
256
|
finalColor = vec4(c.rgb * c.a, c.a);
|
|
192
257
|
}
|
|
193
258
|
`;
|
|
194
|
-
/**
|
|
195
|
-
|
|
259
|
+
/**
|
|
260
|
+
* The fill program's fragment shader, which every fill draws with but a
|
|
261
|
+
* radial gradient's (radialFillFragment) and those of stageFillFragment.
|
|
262
|
+
* A program of its own: in it, the radial gradient's path, though no fill
|
|
263
|
+
* took it, made a frame of plain fills take Intel's GPUs some tenth as long
|
|
264
|
+
* again (bench.ts --shapes 2000, Iris Xe).
|
|
265
|
+
*/
|
|
266
|
+
export const fillFragment = fillFragmentOf(false, false);
|
|
267
|
+
/**
|
|
268
|
+
* The radial fill program's, for runs of fills one of which is a radial
|
|
269
|
+
* gradient's (RADIAL_FILL): every fill as fillFragment draws it, and a radial
|
|
270
|
+
* gradient's texel at the fragment's place.
|
|
271
|
+
*/
|
|
272
|
+
export const radialFillFragment = fillFragmentOf(false, true);
|
|
196
273
|
/**
|
|
197
274
|
* The stage fill program's, for a fill some of whose texels are the
|
|
198
275
|
* stage's pixel (TARGET_TEXEL, Place.stage), drawn alone: the stage's
|
|
@@ -202,7 +279,7 @@ export const fillFragment = fillFragmentOf(false);
|
|
|
202
279
|
* its own: in the fill program, that path, though no fill took it, made a
|
|
203
280
|
* frame of plain fills take Intel's GPUs over half as long again.
|
|
204
281
|
*/
|
|
205
|
-
export const stageFillFragment = fillFragmentOf(true);
|
|
282
|
+
export const stageFillFragment = fillFragmentOf(true, true);
|
|
206
283
|
/**
|
|
207
284
|
* drawTriangles' textured triangles (MESH), placed as fills are, their u
|
|
208
285
|
* and v carried times their depth t, and t, which the GPU interpolates
|
|
@@ -683,16 +760,18 @@ ${BLEND_FRONT}}
|
|
|
683
760
|
/**
|
|
684
761
|
* A fill drawn straight onto what is below it in a blend mode, where its
|
|
685
762
|
* layer would hold it alone (a flat fill, GeometryData.flat): its pixel as
|
|
686
|
-
* fillFragment has it, then as
|
|
687
|
-
*
|
|
763
|
+
* fillFragment, or with `radial` radialFillFragment, has it, then as
|
|
764
|
+
* compositeFragment composites its layer's, coloured by the layer's row
|
|
765
|
+
* (uLayerRow, -1 for none) and blended by uMode.
|
|
688
766
|
*/
|
|
689
|
-
|
|
767
|
+
const blendFillFragmentOf = (radial) => `#version 300 es
|
|
690
768
|
precision highp float;
|
|
691
769
|
in vec4 vColor;
|
|
692
770
|
in vec2 vTexel;
|
|
693
771
|
flat in vec4 vMul;
|
|
694
772
|
flat in vec4 vAdd;
|
|
695
773
|
flat in int vSlot;
|
|
774
|
+
${radial ? "flat in vec3 vRadial;" : ""}
|
|
696
775
|
uniform sampler2D uTextures[${FILL_TEXTURES}];
|
|
697
776
|
uniform sampler2D uBack;
|
|
698
777
|
uniform highp sampler2D uRows;
|
|
@@ -711,12 +790,16 @@ ${slotTexel}
|
|
|
711
790
|
return t;
|
|
712
791
|
}
|
|
713
792
|
|
|
793
|
+
${radial ? radialPlace : ""}
|
|
794
|
+
|
|
714
795
|
void main(void) {
|
|
715
796
|
vec4 front = vec4(0.0);
|
|
716
797
|
vec4 fill = vColor;
|
|
717
798
|
bool clear = false;
|
|
718
799
|
if (vSlot != 0) {
|
|
719
|
-
|
|
800
|
+
vec2 at = vTexel;
|
|
801
|
+
${radial ? radialAt : ""}
|
|
802
|
+
vec4 t = texel(at);
|
|
720
803
|
clear = t.a == 0.0;
|
|
721
804
|
fill = clear ? fill : vec4(t.rgb / t.a * vColor.rgb, t.a * vColor.a);
|
|
722
805
|
}
|
|
@@ -729,4 +812,14 @@ void main(void) {
|
|
|
729
812
|
${layerColor("uLayerRow")}
|
|
730
813
|
${BLEND_FRONT}}
|
|
731
814
|
`;
|
|
815
|
+
/**
|
|
816
|
+
* The blend program's fragment shader, for every fill drawn straight in a
|
|
817
|
+
* blend mode but a radial gradient's (radialBlendFillFragment). A program of
|
|
818
|
+
* its own, as fillFragment is: the radial path in it, though no fill took
|
|
819
|
+
* it, made SwiftShader's frames of 500 shapes in blend modes 3 % longer
|
|
820
|
+
* (bench.ts --blends 500).
|
|
821
|
+
*/
|
|
822
|
+
export const blendFillFragment = blendFillFragmentOf(false);
|
|
823
|
+
/** The radial blend program's, for a radial gradient's fill drawn straight in a blend mode. */
|
|
824
|
+
export const radialBlendFillFragment = blendFillFragmentOf(true);
|
|
732
825
|
//# sourceMappingURL=programs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"programs.js","sourceRoot":"","sources":["../../src/webgl/programs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"programs.js","sourceRoot":"","sources":["../../src/webgl/programs.ts"],"names":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M,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;EAWtB,UAAU,CAAC,WAAW,CAAC;EACvB,WAAW;CACZ,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAE5D,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type GlState } from "@swf2es/context3d/device";
|
|
2
|
+
import type { GpuTextures } from "./gpu-textures.js";
|
|
3
|
+
/**
|
|
4
|
+
* Each instance a run of lines, from its first to past its last, two
|
|
5
|
+
* triangles across them in a viewport of the lines' texture. Drawn a quad
|
|
6
|
+
* each, 240 lines took SwiftShader 2.4 ms with a fragment shader that wrote
|
|
7
|
+
* a constant; one quad of as many texels took it 0.1 ms.
|
|
8
|
+
*/
|
|
9
|
+
export declare const RAMP_VERTEX = "#version 300 es\nprecision highp float;\nprecision highp int;\nuniform highp isampler2D uRuns;\nuniform highp usampler2D uRecords;\n\nvoid main(void) {\n ivec2 run = texelFetch(uRuns, ivec2(gl_InstanceID, 0), 0).rg;\n int c = gl_VertexID;\n float x = c == 1 || c == 2 || c == 4 ? 1.0 : 0.0;\n int row = c == 2 || c == 4 || c == 5 ? run.y : run.x;\n // The records' texture has a row for each of the lines' texture's.\n float room = float(textureSize(uRecords, 0).y);\n gl_Position = vec4(x * 2.0 - 1.0, float(row) / room * 2.0 - 1.0, 0.0, 1.0);\n}\n";
|
|
10
|
+
/**
|
|
11
|
+
* Each texel the entry of its line's ramp at its column, as rampOf finds it:
|
|
12
|
+
* the stop's colour, or the span's c0 + floor(d * j / w) in integers, the
|
|
13
|
+
* colour channels back through TO_SRGB in linear light, premultiplied.
|
|
14
|
+
*/
|
|
15
|
+
export declare const RAMP_FRAGMENT = "#version 300 es\nprecision highp float;\nprecision highp int;\nuniform highp usampler2D uRecords;\nuniform highp usampler2D uSrgb;\nout vec4 finalColor;\nint line;\n\nint ratioOf(int i) {\n uvec4 t = texelFetch(uRecords, ivec2(1 + (i >> 2), line), 0);\n return int(t[i & 3]);\n}\n\nivec4 colorOf(int i) {\n return ivec4(texelFetch(uRecords, ivec2(8 + i, line), 0));\n}\n\nint floorDiv(int n, int w) {\n return n >= 0 ? n / w : -((w - 1 - n) / w);\n}\n\nint srgb(int l) {\n return int(texelFetch(uSrgb, ivec2(l, 0), 0).r);\n}\n\nvoid main(void) {\n line = int(gl_FragCoord.y);\n int k = int(gl_FragCoord.x);\n uvec4 head = texelFetch(uRecords, ivec2(0, line), 0);\n int count = int(head[0]);\n bool linear = head[1] != 0u;\n int from = ratioOf(0);\n ivec4 c;\n if (k <= from) {\n c = colorOf(0);\n } else {\n // The span k lies in, as rampOf walks them: each one entry wide at least.\n int span = 0;\n int w = 0;\n int at = from + 1;\n for (int i = 1; i < 16; i++) {\n if (i >= count || at > 255) {\n break;\n }\n\n int to = ratioOf(i);\n w = to - from;\n int end = w <= 0 ? at : max(at, min(to, 255));\n if (k <= end) {\n span = i;\n break;\n }\n\n at = end + 1;\n from = to;\n }\n\n if (span == 0) {\n c = colorOf(count - 1);\n } else {\n ivec4 x = colorOf(span - 1);\n c = x;\n if (w > 0) {\n ivec4 d = colorOf(span) - x;\n int j = k - from;\n c = ivec4(\n x.r + floorDiv(d.r * j, w),\n x.g + floorDiv(d.g * j, w),\n x.b + floorDiv(d.b * j, w),\n x.a + floorDiv(d.a * j, w)) & 255;\n }\n }\n }\n\n ivec3 rgb = linear ? ivec3(srgb(c.r), srgb(c.g), srgb(c.b)) : c.rgb;\n rgb = (rgb * (c.a + 1)) >> 8;\n finalColor = vec4(vec3(rgb), float(c.a)) / 255.0;\n}\n";
|
|
16
|
+
/**
|
|
17
|
+
* Builds the lines GpuTextures marked (builds) from their records: the
|
|
18
|
+
* records uploaded, then drawn into the lines' texture through a
|
|
19
|
+
* framebuffer of its own, blending off.
|
|
20
|
+
*/
|
|
21
|
+
export declare class RampBuilder {
|
|
22
|
+
private readonly gl;
|
|
23
|
+
private readonly state;
|
|
24
|
+
private program;
|
|
25
|
+
private records;
|
|
26
|
+
private recordRoom;
|
|
27
|
+
private srgb;
|
|
28
|
+
private runList;
|
|
29
|
+
private readonly sorted;
|
|
30
|
+
private readonly runs;
|
|
31
|
+
private framebuffer;
|
|
32
|
+
private target;
|
|
33
|
+
constructor(gl: WebGL2RenderingContext, state: GlState);
|
|
34
|
+
/**
|
|
35
|
+
* As the context comes or comes back, and once what it made is deleted:
|
|
36
|
+
* nothing made yet, the program included, which link makes. Nothing here
|
|
37
|
+
* touches the context, so that destroy works on a lost one.
|
|
38
|
+
*/
|
|
39
|
+
setUp(): void;
|
|
40
|
+
/**
|
|
41
|
+
* The program linked, its samplers told their units: the last of the
|
|
42
|
+
* backend's setUp, so that a context lost meanwhile throws here with all
|
|
43
|
+
* else made, for destroy, and a frame or a BitmapData drawn while links
|
|
44
|
+
* would fail needs none.
|
|
45
|
+
*/
|
|
46
|
+
link(): void;
|
|
47
|
+
/** What it made on the context, deleted. */
|
|
48
|
+
destroy(): void;
|
|
49
|
+
/** The lines `gpu` marked built into its lines' texture, and marked done. */
|
|
50
|
+
build(gpu: GpuTextures, nearest: WebGLSampler): void;
|
|
51
|
+
/** Records `from` up to `to` uploaded; the textures made first where there are none or too few rows. */
|
|
52
|
+
private upload;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=ramps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ramps.d.ts","sourceRoot":"","sources":["../../src/webgl/ramps.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,0BAA0B,CAAC;AAWrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AASrD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,ijBAevB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,k0DA8EzB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAyB;IAC5C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,IAAI,CAA6B;IACzC,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmC;IACxD,OAAO,CAAC,WAAW,CAAiC;IACpD,OAAO,CAAC,MAAM,CAA6B;IAE3C,YAAY,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,OAAO,EAGrD;IAED;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAQZ;IAED;;;;;OAKG;IACH,IAAI,IAAI,IAAI,CAQX;IAED,4CAA4C;IAC5C,OAAO,IAAI,IAAI,CAYd;IAED,6EAA6E;IAC7E,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAwEnD;IAED,wGAAwG;IACxG,OAAO,CAAC,MAAM;CAyDf"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// Ramps built on the GPU (Textures.addRamp): the lines a frame set from
|
|
2
|
+
// records drawn into the lines' texture at once, each texel its entry as
|
|
3
|
+
// ramps.ts's rampOf finds it on the CPU, in the same integers, so that the
|
|
4
|
+
// bytes are the same. One instanced draw for all of them, each instance a
|
|
5
|
+
// run of lines one after another, each texel's record read from a texture of
|
|
6
|
+
// them by its row, uploaded from the first line set to the last; no uniform
|
|
7
|
+
// array, nothing indexed by gl_DrawID.
|
|
8
|
+
import { linkProgram } from "@swf2es/context3d/device";
|
|
9
|
+
import { RAMP_BYTES, RAMP_COLORS, RAMP_COUNT, RAMP_LINEAR, RAMP_RATIOS, RAMP_STOPS, TO_SRGB, } from "../ramps.js";
|
|
10
|
+
import { LINE_TEXELS } from "../textures.js";
|
|
11
|
+
import { BACK_UNIT, LAYER_UNIT, TEXTURE_UNIT } from "./programs.js";
|
|
12
|
+
/** Texels of a record, RGBA: the records' texture's width. */
|
|
13
|
+
const RECORD_TEXELS = RAMP_BYTES / 4;
|
|
14
|
+
/** The most lines built at once: the lines' texture's most, the runs' texture's width. */
|
|
15
|
+
const BUILDS_MOST = 2048;
|
|
16
|
+
/**
|
|
17
|
+
* Each instance a run of lines, from its first to past its last, two
|
|
18
|
+
* triangles across them in a viewport of the lines' texture. Drawn a quad
|
|
19
|
+
* each, 240 lines took SwiftShader 2.4 ms with a fragment shader that wrote
|
|
20
|
+
* a constant; one quad of as many texels took it 0.1 ms.
|
|
21
|
+
*/
|
|
22
|
+
export const RAMP_VERTEX = `#version 300 es
|
|
23
|
+
precision highp float;
|
|
24
|
+
precision highp int;
|
|
25
|
+
uniform highp isampler2D uRuns;
|
|
26
|
+
uniform highp usampler2D uRecords;
|
|
27
|
+
|
|
28
|
+
void main(void) {
|
|
29
|
+
ivec2 run = texelFetch(uRuns, ivec2(gl_InstanceID, 0), 0).rg;
|
|
30
|
+
int c = gl_VertexID;
|
|
31
|
+
float x = c == 1 || c == 2 || c == 4 ? 1.0 : 0.0;
|
|
32
|
+
int row = c == 2 || c == 4 || c == 5 ? run.y : run.x;
|
|
33
|
+
// The records' texture has a row for each of the lines' texture's.
|
|
34
|
+
float room = float(textureSize(uRecords, 0).y);
|
|
35
|
+
gl_Position = vec4(x * 2.0 - 1.0, float(row) / room * 2.0 - 1.0, 0.0, 1.0);
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
/**
|
|
39
|
+
* Each texel the entry of its line's ramp at its column, as rampOf finds it:
|
|
40
|
+
* the stop's colour, or the span's c0 + floor(d * j / w) in integers, the
|
|
41
|
+
* colour channels back through TO_SRGB in linear light, premultiplied.
|
|
42
|
+
*/
|
|
43
|
+
export const RAMP_FRAGMENT = `#version 300 es
|
|
44
|
+
precision highp float;
|
|
45
|
+
precision highp int;
|
|
46
|
+
uniform highp usampler2D uRecords;
|
|
47
|
+
uniform highp usampler2D uSrgb;
|
|
48
|
+
out vec4 finalColor;
|
|
49
|
+
int line;
|
|
50
|
+
|
|
51
|
+
int ratioOf(int i) {
|
|
52
|
+
uvec4 t = texelFetch(uRecords, ivec2(${RAMP_RATIOS / 4} + (i >> 2), line), 0);
|
|
53
|
+
return int(t[i & 3]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ivec4 colorOf(int i) {
|
|
57
|
+
return ivec4(texelFetch(uRecords, ivec2(${RAMP_COLORS / 4} + i, line), 0));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
int floorDiv(int n, int w) {
|
|
61
|
+
return n >= 0 ? n / w : -((w - 1 - n) / w);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
int srgb(int l) {
|
|
65
|
+
return int(texelFetch(uSrgb, ivec2(l, 0), 0).r);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void main(void) {
|
|
69
|
+
line = int(gl_FragCoord.y);
|
|
70
|
+
int k = int(gl_FragCoord.x);
|
|
71
|
+
uvec4 head = texelFetch(uRecords, ivec2(0, line), 0);
|
|
72
|
+
int count = int(head[${RAMP_COUNT}]);
|
|
73
|
+
bool linear = head[${RAMP_LINEAR}] != 0u;
|
|
74
|
+
int from = ratioOf(0);
|
|
75
|
+
ivec4 c;
|
|
76
|
+
if (k <= from) {
|
|
77
|
+
c = colorOf(0);
|
|
78
|
+
} else {
|
|
79
|
+
// The span k lies in, as rampOf walks them: each one entry wide at least.
|
|
80
|
+
int span = 0;
|
|
81
|
+
int w = 0;
|
|
82
|
+
int at = from + 1;
|
|
83
|
+
for (int i = 1; i < ${RAMP_STOPS}; i++) {
|
|
84
|
+
if (i >= count || at > 255) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
int to = ratioOf(i);
|
|
89
|
+
w = to - from;
|
|
90
|
+
int end = w <= 0 ? at : max(at, min(to, 255));
|
|
91
|
+
if (k <= end) {
|
|
92
|
+
span = i;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
at = end + 1;
|
|
97
|
+
from = to;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (span == 0) {
|
|
101
|
+
c = colorOf(count - 1);
|
|
102
|
+
} else {
|
|
103
|
+
ivec4 x = colorOf(span - 1);
|
|
104
|
+
c = x;
|
|
105
|
+
if (w > 0) {
|
|
106
|
+
ivec4 d = colorOf(span) - x;
|
|
107
|
+
int j = k - from;
|
|
108
|
+
c = ivec4(
|
|
109
|
+
x.r + floorDiv(d.r * j, w),
|
|
110
|
+
x.g + floorDiv(d.g * j, w),
|
|
111
|
+
x.b + floorDiv(d.b * j, w),
|
|
112
|
+
x.a + floorDiv(d.a * j, w)) & 255;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
ivec3 rgb = linear ? ivec3(srgb(c.r), srgb(c.g), srgb(c.b)) : c.rgb;
|
|
118
|
+
rgb = (rgb * (c.a + 1)) >> 8;
|
|
119
|
+
finalColor = vec4(vec3(rgb), float(c.a)) / 255.0;
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
/**
|
|
123
|
+
* Builds the lines GpuTextures marked (builds) from their records: the
|
|
124
|
+
* records uploaded, then drawn into the lines' texture through a
|
|
125
|
+
* framebuffer of its own, blending off.
|
|
126
|
+
*/
|
|
127
|
+
export class RampBuilder {
|
|
128
|
+
gl;
|
|
129
|
+
state;
|
|
130
|
+
program = null;
|
|
131
|
+
records = null;
|
|
132
|
+
recordRoom = 0;
|
|
133
|
+
srgb = null;
|
|
134
|
+
runList = null;
|
|
135
|
+
sorted = new Int32Array(BUILDS_MOST);
|
|
136
|
+
runs = new Int32Array(BUILDS_MOST * 2);
|
|
137
|
+
framebuffer = null;
|
|
138
|
+
target = null;
|
|
139
|
+
constructor(gl, state) {
|
|
140
|
+
this.gl = gl;
|
|
141
|
+
this.state = state;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* As the context comes or comes back, and once what it made is deleted:
|
|
145
|
+
* nothing made yet, the program included, which link makes. Nothing here
|
|
146
|
+
* touches the context, so that destroy works on a lost one.
|
|
147
|
+
*/
|
|
148
|
+
setUp() {
|
|
149
|
+
this.program = null;
|
|
150
|
+
this.records = null;
|
|
151
|
+
this.recordRoom = 0;
|
|
152
|
+
this.srgb = null;
|
|
153
|
+
this.runList = null;
|
|
154
|
+
this.framebuffer = null;
|
|
155
|
+
this.target = null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The program linked, its samplers told their units: the last of the
|
|
159
|
+
* backend's setUp, so that a context lost meanwhile throws here with all
|
|
160
|
+
* else made, for destroy, and a frame or a BitmapData drawn while links
|
|
161
|
+
* would fail needs none.
|
|
162
|
+
*/
|
|
163
|
+
link() {
|
|
164
|
+
const gl = this.gl;
|
|
165
|
+
const program = linkProgram(gl, RAMP_VERTEX, RAMP_FRAGMENT);
|
|
166
|
+
this.state.useProgram(program);
|
|
167
|
+
gl.uniform1i(gl.getUniformLocation(program, "uRecords"), TEXTURE_UNIT);
|
|
168
|
+
gl.uniform1i(gl.getUniformLocation(program, "uSrgb"), LAYER_UNIT);
|
|
169
|
+
gl.uniform1i(gl.getUniformLocation(program, "uRuns"), BACK_UNIT);
|
|
170
|
+
this.program = program;
|
|
171
|
+
}
|
|
172
|
+
/** What it made on the context, deleted. */
|
|
173
|
+
destroy() {
|
|
174
|
+
const gl = this.gl;
|
|
175
|
+
for (const texture of [this.records, this.srgb, this.runList]) {
|
|
176
|
+
if (texture) {
|
|
177
|
+
this.state.dropTexture(texture);
|
|
178
|
+
gl.deleteTexture(texture);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
gl.deleteFramebuffer(this.framebuffer);
|
|
182
|
+
gl.deleteProgram(this.program);
|
|
183
|
+
this.setUp();
|
|
184
|
+
}
|
|
185
|
+
/** The lines `gpu` marked built into its lines' texture, and marked done. */
|
|
186
|
+
build(gpu, nearest) {
|
|
187
|
+
const gl = this.gl;
|
|
188
|
+
const state = this.state;
|
|
189
|
+
const program = this.program;
|
|
190
|
+
const lines = gpu.lines;
|
|
191
|
+
if (!program || !lines || gpu.builds.length === 0) {
|
|
192
|
+
gpu.builtAll();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
// The lines in order, into runs of lines one after another, each [first, past its last).
|
|
196
|
+
const count = Math.min(gpu.builds.length, BUILDS_MOST);
|
|
197
|
+
const sorted = this.sorted;
|
|
198
|
+
for (let i = 0; i < count; i++) {
|
|
199
|
+
sorted[i] = gpu.builds[i];
|
|
200
|
+
}
|
|
201
|
+
sorted.subarray(0, count).sort();
|
|
202
|
+
const runs = this.runs;
|
|
203
|
+
let made = 0;
|
|
204
|
+
for (let i = 0; i < count;) {
|
|
205
|
+
const first = sorted[i];
|
|
206
|
+
let past = first + 1;
|
|
207
|
+
i++;
|
|
208
|
+
while (i < count && sorted[i] === past) {
|
|
209
|
+
past++;
|
|
210
|
+
i++;
|
|
211
|
+
}
|
|
212
|
+
runs[made * 2] = first;
|
|
213
|
+
runs[made * 2 + 1] = past;
|
|
214
|
+
made++;
|
|
215
|
+
}
|
|
216
|
+
// The records from the first line built to the last, uploaded in one call.
|
|
217
|
+
this.upload(gpu, sorted[0], sorted[count - 1] + 1);
|
|
218
|
+
state.bindTexture(BACK_UNIT, this.runList);
|
|
219
|
+
state.activeTexture(BACK_UNIT);
|
|
220
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, made, 1, gl.RG_INTEGER, gl.INT, runs);
|
|
221
|
+
if (this.target !== lines) {
|
|
222
|
+
if (this.framebuffer) {
|
|
223
|
+
gl.deleteFramebuffer(this.framebuffer);
|
|
224
|
+
}
|
|
225
|
+
this.framebuffer = gl.createFramebuffer();
|
|
226
|
+
state.bindFramebuffer(this.framebuffer);
|
|
227
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, lines, 0);
|
|
228
|
+
this.target = lines;
|
|
229
|
+
}
|
|
230
|
+
state.bindFramebuffer(this.framebuffer);
|
|
231
|
+
state.viewport(0, 0, LINE_TEXELS, gpu.lineRoom);
|
|
232
|
+
state.scissor(null);
|
|
233
|
+
state.colorMask(15);
|
|
234
|
+
state.stencil(null);
|
|
235
|
+
state.setBlend(null);
|
|
236
|
+
state.useProgram(program);
|
|
237
|
+
state.bindVertexArray(null);
|
|
238
|
+
state.bindTexture(TEXTURE_UNIT, this.records);
|
|
239
|
+
state.bindSampler(TEXTURE_UNIT, nearest);
|
|
240
|
+
state.bindTexture(LAYER_UNIT, this.srgb);
|
|
241
|
+
state.bindSampler(LAYER_UNIT, nearest);
|
|
242
|
+
state.bindSampler(BACK_UNIT, nearest);
|
|
243
|
+
gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, made);
|
|
244
|
+
// Integer textures left on units a float sampler of the next program names, whether it reads
|
|
245
|
+
// them or not, fail its draws (INVALID_OPERATION).
|
|
246
|
+
state.bindTexture(TEXTURE_UNIT, null);
|
|
247
|
+
state.bindTexture(LAYER_UNIT, null);
|
|
248
|
+
state.bindTexture(BACK_UNIT, null);
|
|
249
|
+
gpu.builtAll();
|
|
250
|
+
}
|
|
251
|
+
/** Records `from` up to `to` uploaded; the textures made first where there are none or too few rows. */
|
|
252
|
+
upload(gpu, from, to) {
|
|
253
|
+
const gl = this.gl;
|
|
254
|
+
const state = this.state;
|
|
255
|
+
if (!this.srgb) {
|
|
256
|
+
this.srgb = gl.createTexture();
|
|
257
|
+
state.bindTexture(LAYER_UNIT, this.srgb);
|
|
258
|
+
state.activeTexture(LAYER_UNIT);
|
|
259
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.R8UI, 256, 1, 0, gl.RED_INTEGER, gl.UNSIGNED_BYTE, TO_SRGB);
|
|
260
|
+
this.runList = gl.createTexture();
|
|
261
|
+
state.bindTexture(BACK_UNIT, this.runList);
|
|
262
|
+
state.activeTexture(BACK_UNIT);
|
|
263
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32I, BUILDS_MOST, 1, 0, gl.RG_INTEGER, gl.INT, null);
|
|
264
|
+
}
|
|
265
|
+
const made = !this.records || this.recordRoom !== gpu.lineRoom;
|
|
266
|
+
this.records ??= gl.createTexture();
|
|
267
|
+
state.bindTexture(TEXTURE_UNIT, this.records);
|
|
268
|
+
state.activeTexture(TEXTURE_UNIT);
|
|
269
|
+
if (made) {
|
|
270
|
+
this.recordRoom = gpu.lineRoom;
|
|
271
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8UI, RECORD_TEXELS, this.recordRoom, 0, gl.RGBA_INTEGER, gl.UNSIGNED_BYTE, gpu.rampRecords);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, from, RECORD_TEXELS, to - from, gl.RGBA_INTEGER, gl.UNSIGNED_BYTE, gpu.rampRecords, from * RAMP_BYTES);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=ramps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ramps.js","sourceRoot":"","sources":["../../src/webgl/ramps.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,uCAAuC;AACvC,OAAO,EAAgB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC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C,EACD,EAAE,CAAC,OAAO,EACV,aAAa,EACb,IAAI,CAAC,UAAU,EACf,CAAC,EACD,EAAE,CAAC,YAAY,EACf,EAAE,CAAC,aAAa,EAChB,GAAG,CAAC,WAAW,CAChB,CAAC;YACF,OAAO;QACT,CAAC;QAED,EAAE,CAAC,aAAa,CACd,EAAE,CAAC,UAAU,EACb,CAAC,EACD,CAAC,EACD,IAAI,EACJ,aAAa,EACb,EAAE,GAAG,IAAI,EACT,EAAE,CAAC,YAAY,EACf,EAAE,CAAC,aAAa,EAChB,GAAG,CAAC,WAAW,EACf,IAAI,GAAG,UAAU,CAClB,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swf2es/render",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"description": "swf2es's own renderer: a scene list, a planner and a WebGL 2 backend (docs/renderer.md)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"swf",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
24
|
},
|
|
25
|
+
"./ramps": {
|
|
26
|
+
"types": "./dist/ramps.d.ts",
|
|
27
|
+
"default": "./dist/ramps.js"
|
|
28
|
+
},
|
|
25
29
|
"./webgl": {
|
|
26
30
|
"types": "./dist/webgl/index.d.ts",
|
|
27
31
|
"default": "./dist/webgl/index.js"
|
|
@@ -33,6 +37,6 @@
|
|
|
33
37
|
"src"
|
|
34
38
|
],
|
|
35
39
|
"dependencies": {
|
|
36
|
-
"@swf2es/context3d": "0.1.
|
|
40
|
+
"@swf2es/context3d": "0.1.46"
|
|
37
41
|
}
|
|
38
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,16 @@ export {
|
|
|
53
53
|
wholeBitmap,
|
|
54
54
|
} from "./measure.js";
|
|
55
55
|
export { plan } from "./plan.js";
|
|
56
|
+
export {
|
|
57
|
+
RAMP_BYTES,
|
|
58
|
+
RAMP_COLORS,
|
|
59
|
+
RAMP_COUNT,
|
|
60
|
+
RAMP_LINEAR,
|
|
61
|
+
RAMP_RATIOS,
|
|
62
|
+
RAMP_STOPS,
|
|
63
|
+
rampOf,
|
|
64
|
+
TO_LINEAR,
|
|
65
|
+
} from "./ramps.js";
|
|
56
66
|
export { type ColorRow, ROW_FLOATS, ROWS_A_LINE, Rows } from "./rows.js";
|
|
57
67
|
export {
|
|
58
68
|
ADD,
|
|
@@ -86,6 +96,7 @@ export {
|
|
|
86
96
|
NORMAL,
|
|
87
97
|
OVERLAY,
|
|
88
98
|
PLANE,
|
|
99
|
+
RADIAL_FILL,
|
|
89
100
|
REPEAT,
|
|
90
101
|
SCREEN,
|
|
91
102
|
SceneList,
|