Skip to content

Commit

Permalink
feat(color): add AColor.set()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 25, 2021
1 parent c0b9e9d commit 7e7a05c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/color/src/internal/acolor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IDeref } from "@thi.ng/api";
import { EPS } from "@thi.ng/math";
import { eqDelta4, stridedValues } from "@thi.ng/vectors";
import type { Color, ColorMode, IColor } from "../api";
import type { Color, ColorMode, IColor, ReadonlyColor } from "../api";

export abstract class AColor<T extends Color> implements IColor, IDeref<Color> {
buf: Color;
Expand All @@ -25,6 +25,14 @@ export abstract class AColor<T extends Color> implements IColor, IDeref<Color> {
return 4;
}

set(src: ReadonlyColor) {
this[0] = src[0];
this[1] = src[1];
this[2] = src[2];
this[3] = src[3];
return this;
}

/**
* Returns a new array of this color's channel values.
*/
Expand Down

0 comments on commit 7e7a05c

Please sign in to comment.