-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding a fix for mix * added changeset * fix for alpha in mix * fixes * github-actions[bot] Regenerated snapshots --------- Co-authored-by: lukasoppermann <lukasoppermann@users.noreply.github.com>
- Loading branch information
1 parent
01aae86
commit 5394816
Showing
32 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/primitives': patch | ||
--- | ||
|
||
Fioxed RGBAfloatconversion |
Binary file modified
BIN
+15.4 KB
(110%)
...torybook-color-functional-all--all-all-themes-dark-colorblind-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+13.4 KB
(100%)
...ybook-color-functional-all--all-all-themes-dark-high-contrast-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+15.4 KB
(110%)
...snapshots/storybook-color-functional-all--all-all-themes-dark-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+15.4 KB
(110%)
...torybook-color-functional-all--all-all-themes-dark-tritanopia-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+22.7 KB
(110%)
...orybook-color-functional-all--all-all-themes-light-colorblind-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+21.5 KB
(110%)
...book-color-functional-all--all-all-themes-light-high-contrast-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+22.6 KB
(110%)
...napshots/storybook-color-functional-all--all-all-themes-light-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+22.7 KB
(110%)
...orybook-color-functional-all--all-all-themes-light-tritanopia-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+13.7 KB
(150%)
...-color-functional-shadows--shadows-all-themes-dark-colorblind-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.8 KB
(130%)
...lor-functional-shadows--shadows-all-themes-dark-high-contrast-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+13.7 KB
(150%)
...s/storybook-color-functional-shadows--shadows-all-themes-dark-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+13.7 KB
(150%)
...-color-functional-shadows--shadows-all-themes-dark-tritanopia-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.6 KB
(170%)
...color-functional-shadows--shadows-all-themes-light-colorblind-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+17.8 KB
(150%)
...or-functional-shadows--shadows-all-themes-light-high-contrast-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.6 KB
(170%)
.../storybook-color-functional-shadows--shadows-all-themes-light-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.6 KB
(170%)
...color-functional-shadows--shadows-all-themes-light-tritanopia-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+27.2 KB
(110%)
...torybook-migration-tables--shadows-all-themes-dark-colorblind-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+28.3 KB
(110%)
...ybook-migration-tables--shadows-all-themes-dark-high-contrast-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+27.2 KB
(110%)
...snapshots/storybook-migration-tables--shadows-all-themes-dark-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+27.2 KB
(110%)
...torybook-migration-tables--shadows-all-themes-dark-tritanopia-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.9 KB
(110%)
...orybook-migration-tables--shadows-all-themes-light-colorblind-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.3 KB
(110%)
...book-migration-tables--shadows-all-themes-light-high-contrast-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.8 KB
(110%)
...napshots/storybook-migration-tables--shadows-all-themes-light-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.8 KB
(110%)
...orybook-migration-tables--shadows-all-themes-light-tritanopia-theme-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {rgba, parseToRgba} from 'color2k' | ||
|
||
/** | ||
* Mixes two colors together. Taken from sass's implementation. | ||
*/ | ||
function mix(color1: string, color2: string, weight: number): string { | ||
const normalize = (n: number, index: number) => | ||
// 3rd index is alpha channel which is already normalized | ||
index === 3 ? n : n / 255 | ||
|
||
const [r1, g1, b1, a1] = parseToRgba(color1).map(normalize) | ||
const [r2, g2, b2, a2] = parseToRgba(color2).map(normalize) | ||
|
||
// The formula is copied from the original Sass implementation: | ||
// http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method | ||
const normalizedWeight = 2 * weight - 1 | ||
const alphaDelta = a1 - a2 | ||
|
||
const combinedWeight = | ||
normalizedWeight * alphaDelta === -1 | ||
? normalizedWeight | ||
: (normalizedWeight + alphaDelta) / (1 + normalizedWeight * alphaDelta) | ||
|
||
const weight2 = (combinedWeight + 1) / 2 | ||
const weight1 = 1 - weight2 | ||
const r = Math.round((r1 * weight1 + r2 * weight2) * 255) | ||
const g = Math.round((g1 * weight1 + g2 * weight2) * 255) | ||
const b = Math.round((b1 * weight1 + b2 * weight2) * 255) | ||
const a = a2 * weight + a1 * (1 - weight) | ||
return rgba(r, g, b, a) | ||
} | ||
|
||
export default mix | ||
// Number* weight = ARGR("$weight", Number, 0, 100); | ||
// double p = weight->value()/100; | ||
// double w = 2*p - 1; | ||
// double a = color1->a() - color2->a(); | ||
// double nW = ((w * a == -1) ? w : (w + a)/(1 + w*a)) | ||
// double w1 = (nW + 1)/2.0; | ||
// double w2 = 1 - w1; | ||
|
||
// return new (ctx.mem) Color(pstate, | ||
// std::round(w1*color1->r() + w2*color2->r()), | ||
// std::round(w1*color1->g() + w2*color2->g()), | ||
// std::round(w1*color1->b() + w2*color2->b()), | ||
// color1->a()*p + color2->a()*(1-p)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const rgbaFloatToHex = ({r, g, b, a}: {r: number; g: number; b: number; a?: number}, alpha = true): string => { | ||
const values = [r, g, b, alpha === true && a ? a : undefined].filter(Boolean) as number[] | ||
const values = [r, g, b, alpha === true && a && a < 1 ? a : undefined].filter(item => item !== undefined) as number[] | ||
|
||
return `#${values.map(v => `${(v * 255).toString(16)}`.padEnd(2, '0')).join('')}` | ||
return `#${values.map(v => `${(v * 255).toString(16)}`.padStart(2, '0')).join('')}` | ||
} |