Skip to content

Commit

Permalink
refactor(examples): update @thi.ng/color usage
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 25, 2021
1 parent ccf6a95 commit d54d943
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/commit-heatmap/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withoutKeysObj } from "@thi.ng/associative";
import { cosineGradient, GRADIENTS } from "@thi.ng/color";
import { cosineGradient, COSINE_GRADIENTS } from "@thi.ng/color";
import { threadLast } from "@thi.ng/compose";
import { serialize } from "@thi.ng/hiccup";
import { defs, group, line, rect, svg, text } from "@thi.ng/hiccup-svg";
Expand Down Expand Up @@ -55,7 +55,7 @@ const IGNORE_PACKAGES = [
];

// heatmap gradient
const GRAD = <any[]>cosineGradient(32, GRADIENTS["blue-magenta-orange"]);
const GRAD = <any[]>cosineGradient(32, COSINE_GRADIENTS["blue-magenta-orange"]);

const MIN_DATE = Date.parse("2018-01-01T00:00:00+00:00");
const MAX_DATE = Date.now();
Expand Down
4 changes: 2 additions & 2 deletions examples/grid-iterators/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hueRgba, srgbaCss } from "@thi.ng/color";
import { hueRgb, srgbCss } from "@thi.ng/color";
import {
diagonal2d,
hilbert2d,
Expand Down Expand Up @@ -49,6 +49,6 @@ setInterval(() => {
let [x, y] = <number[]>b.value;
x *= BW;
y *= BH;
ctx.fillStyle = srgbaCss(hueRgba([], frame++ / (NB * NB)));
ctx.fillStyle = srgbCss(hueRgb([], frame++ / (NB * NB)));
ctx.fillRect(x, y, BW, BH);
}, 16);
4 changes: 2 additions & 2 deletions examples/hdom-canvas-shapes/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hsva } from "@thi.ng/color";
import { hsv } from "@thi.ng/color";
import { download } from "@thi.ng/dl-asset";
import { pathBuilder, points } from "@thi.ng/geom";
import { canvas, normalizeTree } from "@thi.ng/hdom-canvas";
Expand Down Expand Up @@ -284,7 +284,7 @@ const TESTS: any = {
map(
(x) => [
"ellipse",
{ stroke: hsva(x / 20, 1, 1) },
{ stroke: hsv(x / 20, 1, 1) },
[150, 150], // pos
addN(null, sincos(t + x * 0.1, 75), 75), // radii
Math.sin(t * 0.25), // axis
Expand Down
4 changes: 2 additions & 2 deletions examples/hiccup-canvas-arcs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hsla } from "@thi.ng/color";
import { hsl } from "@thi.ng/color";
import {
arc,
asCubic,
Expand Down Expand Up @@ -34,7 +34,7 @@ const arcs = [
// stroke width
w: SYSTEM.minmax(1, 5),
// randomized HSLA color
col: hsla([SYSTEM.norm(0.1), SYSTEM.minmax(0.5, 1), 0.5]),
col: hsl([SYSTEM.norm(0.1), SYSTEM.minmax(0.5, 1), 0.5]),
// start angle
theta: SYSTEM.float(TAU),
// angle spread
Expand Down
4 changes: 2 additions & 2 deletions examples/shader-ast-tunnel/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { swizzle8 } from "@thi.ng/binary";
import { int32Srgba } from "@thi.ng/color";
import { int32Srgb } from "@thi.ng/color";
import {
$x,
$xy,
Expand Down Expand Up @@ -123,7 +123,7 @@ if (JS_MODE) {
let y = ((uv[1] * TH) | 0) % TH;
x < 0 && (x += TW);
y < 0 && (y += TH);
return int32Srgba([], swizzle8(texData[y * TW + x], 0, 3, 2, 1));
return int32Srgb([], swizzle8(texData[y * TW + x], 0, 3, 2, 1));
};

// compile AST to actual JS:
Expand Down
4 changes: 2 additions & 2 deletions examples/shader-ast-workers/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { timedResult } from "@thi.ng/bench";
import { hueRgba } from "@thi.ng/color";
import { hueRgb } from "@thi.ng/color";
import {
$x,
$xyz,
Expand Down Expand Up @@ -43,7 +43,7 @@ import { sma } from "@thi.ng/transducers-stats";
import { NUM_WORKERS, WorkerJob, WorkerResult } from "./api";

// color table to tint each worker's region
const COLORS = [...map((i) => hueRgba([], i), normRange(NUM_WORKERS))];
const COLORS = [...map((i) => hueRgb([], i), normRange(NUM_WORKERS))];

// shader AST functions from the shader-ast-raymarch example
const scene = defn("vec2", "scene", ["vec3"], (pos) => {
Expand Down

0 comments on commit d54d943

Please sign in to comment.