diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-02-28 11:06:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-28 10:06:54 +0000 |
| commit | e16d3f5a67a31154797b4d56cdc6ed142ee2a7cf (patch) | |
| tree | 31dcd2243c2b51bac62fe19e7e60efe5f6289281 /crates/typst-pdf/src/oklab.ps | |
| parent | 5036c5acebebe12cbf14338f5413514251d83d1e (diff) | |
Externalize assets (#3515)
Diffstat (limited to 'crates/typst-pdf/src/oklab.ps')
| -rw-r--r-- | crates/typst-pdf/src/oklab.ps | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/crates/typst-pdf/src/oklab.ps b/crates/typst-pdf/src/oklab.ps new file mode 100644 index 00000000..e766bbd8 --- /dev/null +++ b/crates/typst-pdf/src/oklab.ps @@ -0,0 +1,78 @@ +{ + % Starting stack: L, A, B + % /!\ WARNING: The A and B components **MUST** be encoded + % in the range [0, 1] before calling this function. + % This is because the function assumes that the + % A and B components are offset by a factor of 0.5 + % in order to meet the range requirements of the + % PDF specification. + + exch 0.5 sub + exch 0.5 sub + + % Load L a and b into the stack + 2 index + 2 index + 2 index + + % Compute f1 = ((0.3963377774 * a) + (0.2158037573 * b) + L)^3 + 0.2158037573 mul exch + 0.3963377774 mul add add + dup dup mul mul + + % Load L, a, and b into the stack + 3 index + 3 index + 3 index + + % Compute f2 = ((-0.1055613458 * a) + (-0.0638541728 * b) + L)^3 + -0.0638541728 mul exch + -0.1055613458 mul add add + dup dup mul mul + + % Load L, a, and b into the stack + 4 index + 4 index + 4 index + + % Compute f3 = ((-0.0894841775 * a) + (-1.2914855480 * b) + L)^3 + -1.2914855480 mul exch + -0.0894841775 mul add add + dup dup mul mul + + % Discard L, a, and b by rolling the stack and popping + 6 3 roll pop pop pop + + % Load f1, f2, and f3 into the stack + 2 index + 2 index + 2 index + + % Compute R = f1 * 4.0767416621 + f2 * -3.3077115913 + f3 * 0.2309699292 + 0.2309699292 mul exch + -3.3077115913 mul add exch + 4.0767416621 mul add + + % Load f1, f2, and f3 into the stack + 3 index + 3 index + 3 index + + % Compute G = f1 * -1.2684380046 + f2 * 2.6097574011 + f3 * -0.3413193965 + -0.3413193965 mul exch + 2.6097574011 mul add exch + -1.2684380046 mul add + + % Load f1, f2, and f3 into the stack + 4 index + 4 index + 4 index + + % Compute B = f1 * -0.0041960863 + f2 * -0.7034186147 + f3 * 1.7076147010 + 1.7076147010 mul exch + -0.7034186147 mul add exch + -0.0041960863 mul add + + % Discard f1, f2, and f3 by rolling the stack and popping + 6 3 roll pop pop pop +} |
