@excalidraw/common 0.18.0-c141960 → 0.18.0-c158187
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/dist/dev/index.js +1070 -10
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/bounds.d.ts +10 -0
- package/dist/types/common/src/colors.d.ts +5 -2
- package/dist/types/common/src/constants.d.ts +14 -12
- package/dist/types/common/src/font-metadata.d.ts +1 -3
- package/dist/types/common/src/index.d.ts +1 -0
- package/dist/types/common/src/keys.d.ts +1 -1
- package/dist/types/common/src/utility-types.d.ts +0 -1
- package/dist/types/common/src/utils.d.ts +44 -34
- package/dist/types/common/src/visualdebug.d.ts +1 -1
- package/dist/types/element/src/Scene.d.ts +4 -4
- package/dist/types/element/src/binding.d.ts +6 -4
- package/dist/types/element/src/bounds.d.ts +2 -10
- package/dist/types/element/src/collision.d.ts +2 -2
- package/dist/types/element/src/comparisons.d.ts +7 -7
- package/dist/types/element/src/dragElements.d.ts +3 -3
- package/dist/types/element/src/duplicate.d.ts +3 -3
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +7 -3
- package/dist/types/element/src/heading.d.ts +2 -1
- package/dist/types/element/src/image.d.ts +1 -11
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/linearElementEditor.d.ts +1 -2
- package/dist/types/element/src/mutateElement.d.ts +3 -1
- package/dist/types/element/src/newElement.d.ts +6 -6
- package/dist/types/element/src/renderElement.d.ts +0 -6
- package/dist/types/element/src/resizeElements.d.ts +10 -10
- package/dist/types/element/src/resizeTest.d.ts +1 -1
- package/dist/types/element/src/selection.d.ts +3 -7
- package/dist/types/element/src/shape.d.ts +8 -7
- package/dist/types/element/src/textMeasurements.d.ts +1 -3
- package/dist/types/{excalidraw/data → element/src}/transform.d.ts +3 -3
- package/dist/types/element/src/transformHandles.d.ts +3 -23
- package/dist/types/element/src/typeChecks.d.ts +2 -4
- package/dist/types/element/src/utils.d.ts +3 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +114 -178
- package/dist/types/excalidraw/actions/actionAlign.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +44 -87
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +263 -510
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +85 -128
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +21 -43
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +74 -142
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +41 -63
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +45 -88
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +41 -63
- package/dist/types/excalidraw/actions/actionExport.d.ts +85 -170
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionFlip.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionFrame.d.ts +208 -329
- package/dist/types/excalidraw/actions/actionGroup.d.ts +48 -99
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +149 -207
- package/dist/types/excalidraw/actions/actionLink.d.ts +43 -65
- package/dist/types/excalidraw/actions/actionMenu.d.ts +35 -57
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionProperties.d.ts +59 -102
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +24 -50
- package/dist/types/excalidraw/actions/actionStyles.d.ts +20 -42
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +41 -63
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +41 -63
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +35 -57
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +40 -62
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +41 -63
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +41 -63
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
- package/dist/types/excalidraw/actions/manager.d.ts +1 -1
- package/dist/types/excalidraw/actions/register.d.ts +2 -2
- package/dist/types/excalidraw/appState.d.ts +12 -12
- package/dist/types/excalidraw/clipboard.d.ts +7 -31
- package/dist/types/excalidraw/components/Actions.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +32 -40
- package/dist/types/excalidraw/components/Card.d.ts +0 -1
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +7 -4
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +0 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +0 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
- package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
- package/dist/types/excalidraw/components/DefaultSidebar.d.ts +9 -13
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/Ellipsify.d.ts +1 -2
- package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -1
- package/dist/types/excalidraw/components/EyeDropper.d.ts +0 -1
- package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +0 -1
- package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/InlineIcon.d.ts +2 -2
- package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -3
- package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -1
- package/dist/types/excalidraw/components/Modal.d.ts +0 -1
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +1 -1
- package/dist/types/excalidraw/components/RadioGroup.d.ts +0 -1
- package/dist/types/excalidraw/components/RadioSelection.d.ts +4 -4
- package/dist/types/excalidraw/components/ScrollableList.d.ts +0 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +15 -21
- package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -2
- package/dist/types/excalidraw/components/Spinner.d.ts +4 -4
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/index.d.ts +7 -8
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +0 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +2 -3
- package/dist/types/excalidraw/components/Toast.d.ts +3 -3
- package/dist/types/excalidraw/components/Trans.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +28 -32
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +5 -5
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +10 -18
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +3 -3
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +0 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +1 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +1 -1
- package/dist/types/excalidraw/components/icons.d.ts +11 -11
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +2 -13
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -2
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +26 -28
- package/dist/types/excalidraw/components/shapes.d.ts +1 -1
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +6 -6
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +15 -16
- package/dist/types/excalidraw/data/blob.d.ts +321 -3
- package/dist/types/excalidraw/data/encode.d.ts +4 -4
- package/dist/types/excalidraw/data/encryption.d.ts +5 -5
- package/dist/types/excalidraw/data/filesystem.d.ts +2 -2
- package/dist/types/excalidraw/data/index.d.ts +3 -3
- package/dist/types/excalidraw/data/json.d.ts +159 -2
- package/dist/types/excalidraw/data/library.d.ts +24 -9
- package/dist/types/excalidraw/data/restore.d.ts +25 -10
- package/dist/types/excalidraw/editor-jotai.d.ts +11 -11
- package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +1 -2
- package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
- package/dist/types/excalidraw/i18n.d.ts +2 -2
- package/dist/types/excalidraw/index.d.ts +2 -4
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -4
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +8 -6
- package/dist/types/excalidraw/scene/Renderer.d.ts +5 -2
- package/dist/types/excalidraw/scene/export.d.ts +2 -2
- package/dist/types/excalidraw/scene/scroll.d.ts +1 -6
- package/dist/types/excalidraw/scene/types.d.ts +7 -2
- package/dist/types/excalidraw/snapping.d.ts +5 -5
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +1 -1
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +1 -1
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +1 -1
- package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +2 -2
- package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +1 -1
- package/dist/types/excalidraw/types.d.ts +1 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -2
- package/dist/types/math/src/polygon.d.ts +2 -2
- package/dist/types/math/src/range.d.ts +1 -3
- package/dist/types/math/src/segment.d.ts +3 -3
- package/dist/types/utils/src/bbox.d.ts +1 -1
- package/dist/types/utils/src/export.d.ts +5 -5
- package/dist/types/utils/src/shape.d.ts +6 -6
- package/dist/types/utils/src/withinBounds.d.ts +2 -2
- package/package.json +7 -1
package/dist/dev/index.js
CHANGED
|
@@ -363,6 +363,10 @@ var BinaryHeap = class {
|
|
|
363
363
|
}
|
|
364
364
|
};
|
|
365
365
|
|
|
366
|
+
// src/bounds.ts
|
|
367
|
+
init_define_import_meta_env();
|
|
368
|
+
var isBounds = (box) => Array.isArray(box) && box.length === 4 && typeof box[0] === "number" && typeof box[1] === "number" && typeof box[2] === "number" && typeof box[3] === "number";
|
|
369
|
+
|
|
366
370
|
// src/colors.ts
|
|
367
371
|
init_define_import_meta_env();
|
|
368
372
|
|
|
@@ -528,7 +532,1051 @@ var open_color_default = {
|
|
|
528
532
|
]
|
|
529
533
|
};
|
|
530
534
|
|
|
535
|
+
// ../../node_modules/tinycolor2/esm/tinycolor.js
|
|
536
|
+
init_define_import_meta_env();
|
|
537
|
+
function _typeof(obj) {
|
|
538
|
+
"@babel/helpers - typeof";
|
|
539
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
540
|
+
return typeof obj2;
|
|
541
|
+
} : function(obj2) {
|
|
542
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
543
|
+
}, _typeof(obj);
|
|
544
|
+
}
|
|
545
|
+
var trimLeft = /^\s+/;
|
|
546
|
+
var trimRight = /\s+$/;
|
|
547
|
+
function tinycolor(color, opts) {
|
|
548
|
+
color = color ? color : "";
|
|
549
|
+
opts = opts || {};
|
|
550
|
+
if (color instanceof tinycolor) {
|
|
551
|
+
return color;
|
|
552
|
+
}
|
|
553
|
+
if (!(this instanceof tinycolor)) {
|
|
554
|
+
return new tinycolor(color, opts);
|
|
555
|
+
}
|
|
556
|
+
var rgb = inputToRGB(color);
|
|
557
|
+
this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
|
|
558
|
+
this._gradientType = opts.gradientType;
|
|
559
|
+
if (this._r < 1)
|
|
560
|
+
this._r = Math.round(this._r);
|
|
561
|
+
if (this._g < 1)
|
|
562
|
+
this._g = Math.round(this._g);
|
|
563
|
+
if (this._b < 1)
|
|
564
|
+
this._b = Math.round(this._b);
|
|
565
|
+
this._ok = rgb.ok;
|
|
566
|
+
}
|
|
567
|
+
tinycolor.prototype = {
|
|
568
|
+
isDark: function isDark() {
|
|
569
|
+
return this.getBrightness() < 128;
|
|
570
|
+
},
|
|
571
|
+
isLight: function isLight() {
|
|
572
|
+
return !this.isDark();
|
|
573
|
+
},
|
|
574
|
+
isValid: function isValid() {
|
|
575
|
+
return this._ok;
|
|
576
|
+
},
|
|
577
|
+
getOriginalInput: function getOriginalInput() {
|
|
578
|
+
return this._originalInput;
|
|
579
|
+
},
|
|
580
|
+
getFormat: function getFormat() {
|
|
581
|
+
return this._format;
|
|
582
|
+
},
|
|
583
|
+
getAlpha: function getAlpha() {
|
|
584
|
+
return this._a;
|
|
585
|
+
},
|
|
586
|
+
getBrightness: function getBrightness() {
|
|
587
|
+
var rgb = this.toRgb();
|
|
588
|
+
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
|
|
589
|
+
},
|
|
590
|
+
getLuminance: function getLuminance() {
|
|
591
|
+
var rgb = this.toRgb();
|
|
592
|
+
var RsRGB, GsRGB, BsRGB, R, G, B;
|
|
593
|
+
RsRGB = rgb.r / 255;
|
|
594
|
+
GsRGB = rgb.g / 255;
|
|
595
|
+
BsRGB = rgb.b / 255;
|
|
596
|
+
if (RsRGB <= 0.03928)
|
|
597
|
+
R = RsRGB / 12.92;
|
|
598
|
+
else
|
|
599
|
+
R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
|
|
600
|
+
if (GsRGB <= 0.03928)
|
|
601
|
+
G = GsRGB / 12.92;
|
|
602
|
+
else
|
|
603
|
+
G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
|
|
604
|
+
if (BsRGB <= 0.03928)
|
|
605
|
+
B = BsRGB / 12.92;
|
|
606
|
+
else
|
|
607
|
+
B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
|
|
608
|
+
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
609
|
+
},
|
|
610
|
+
setAlpha: function setAlpha(value) {
|
|
611
|
+
this._a = boundAlpha(value);
|
|
612
|
+
this._roundA = Math.round(100 * this._a) / 100;
|
|
613
|
+
return this;
|
|
614
|
+
},
|
|
615
|
+
toHsv: function toHsv() {
|
|
616
|
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
|
617
|
+
return {
|
|
618
|
+
h: hsv.h * 360,
|
|
619
|
+
s: hsv.s,
|
|
620
|
+
v: hsv.v,
|
|
621
|
+
a: this._a
|
|
622
|
+
};
|
|
623
|
+
},
|
|
624
|
+
toHsvString: function toHsvString() {
|
|
625
|
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
|
626
|
+
var h = Math.round(hsv.h * 360), s = Math.round(hsv.s * 100), v = Math.round(hsv.v * 100);
|
|
627
|
+
return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
|
|
628
|
+
},
|
|
629
|
+
toHsl: function toHsl() {
|
|
630
|
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
|
631
|
+
return {
|
|
632
|
+
h: hsl.h * 360,
|
|
633
|
+
s: hsl.s,
|
|
634
|
+
l: hsl.l,
|
|
635
|
+
a: this._a
|
|
636
|
+
};
|
|
637
|
+
},
|
|
638
|
+
toHslString: function toHslString() {
|
|
639
|
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
|
640
|
+
var h = Math.round(hsl.h * 360), s = Math.round(hsl.s * 100), l = Math.round(hsl.l * 100);
|
|
641
|
+
return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
|
|
642
|
+
},
|
|
643
|
+
toHex: function toHex(allow3Char) {
|
|
644
|
+
return rgbToHex(this._r, this._g, this._b, allow3Char);
|
|
645
|
+
},
|
|
646
|
+
toHexString: function toHexString(allow3Char) {
|
|
647
|
+
return "#" + this.toHex(allow3Char);
|
|
648
|
+
},
|
|
649
|
+
toHex8: function toHex8(allow4Char) {
|
|
650
|
+
return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
|
|
651
|
+
},
|
|
652
|
+
toHex8String: function toHex8String(allow4Char) {
|
|
653
|
+
return "#" + this.toHex8(allow4Char);
|
|
654
|
+
},
|
|
655
|
+
toRgb: function toRgb() {
|
|
656
|
+
return {
|
|
657
|
+
r: Math.round(this._r),
|
|
658
|
+
g: Math.round(this._g),
|
|
659
|
+
b: Math.round(this._b),
|
|
660
|
+
a: this._a
|
|
661
|
+
};
|
|
662
|
+
},
|
|
663
|
+
toRgbString: function toRgbString() {
|
|
664
|
+
return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
|
|
665
|
+
},
|
|
666
|
+
toPercentageRgb: function toPercentageRgb() {
|
|
667
|
+
return {
|
|
668
|
+
r: Math.round(bound01(this._r, 255) * 100) + "%",
|
|
669
|
+
g: Math.round(bound01(this._g, 255) * 100) + "%",
|
|
670
|
+
b: Math.round(bound01(this._b, 255) * 100) + "%",
|
|
671
|
+
a: this._a
|
|
672
|
+
};
|
|
673
|
+
},
|
|
674
|
+
toPercentageRgbString: function toPercentageRgbString() {
|
|
675
|
+
return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
|
|
676
|
+
},
|
|
677
|
+
toName: function toName() {
|
|
678
|
+
if (this._a === 0) {
|
|
679
|
+
return "transparent";
|
|
680
|
+
}
|
|
681
|
+
if (this._a < 1) {
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
|
|
685
|
+
},
|
|
686
|
+
toFilter: function toFilter(secondColor) {
|
|
687
|
+
var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
|
|
688
|
+
var secondHex8String = hex8String;
|
|
689
|
+
var gradientType = this._gradientType ? "GradientType = 1, " : "";
|
|
690
|
+
if (secondColor) {
|
|
691
|
+
var s = tinycolor(secondColor);
|
|
692
|
+
secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
|
|
693
|
+
}
|
|
694
|
+
return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
|
|
695
|
+
},
|
|
696
|
+
toString: function toString(format) {
|
|
697
|
+
var formatSet = !!format;
|
|
698
|
+
format = format || this._format;
|
|
699
|
+
var formattedString = false;
|
|
700
|
+
var hasAlpha = this._a < 1 && this._a >= 0;
|
|
701
|
+
var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
|
|
702
|
+
if (needsAlphaFormat) {
|
|
703
|
+
if (format === "name" && this._a === 0) {
|
|
704
|
+
return this.toName();
|
|
705
|
+
}
|
|
706
|
+
return this.toRgbString();
|
|
707
|
+
}
|
|
708
|
+
if (format === "rgb") {
|
|
709
|
+
formattedString = this.toRgbString();
|
|
710
|
+
}
|
|
711
|
+
if (format === "prgb") {
|
|
712
|
+
formattedString = this.toPercentageRgbString();
|
|
713
|
+
}
|
|
714
|
+
if (format === "hex" || format === "hex6") {
|
|
715
|
+
formattedString = this.toHexString();
|
|
716
|
+
}
|
|
717
|
+
if (format === "hex3") {
|
|
718
|
+
formattedString = this.toHexString(true);
|
|
719
|
+
}
|
|
720
|
+
if (format === "hex4") {
|
|
721
|
+
formattedString = this.toHex8String(true);
|
|
722
|
+
}
|
|
723
|
+
if (format === "hex8") {
|
|
724
|
+
formattedString = this.toHex8String();
|
|
725
|
+
}
|
|
726
|
+
if (format === "name") {
|
|
727
|
+
formattedString = this.toName();
|
|
728
|
+
}
|
|
729
|
+
if (format === "hsl") {
|
|
730
|
+
formattedString = this.toHslString();
|
|
731
|
+
}
|
|
732
|
+
if (format === "hsv") {
|
|
733
|
+
formattedString = this.toHsvString();
|
|
734
|
+
}
|
|
735
|
+
return formattedString || this.toHexString();
|
|
736
|
+
},
|
|
737
|
+
clone: function clone() {
|
|
738
|
+
return tinycolor(this.toString());
|
|
739
|
+
},
|
|
740
|
+
_applyModification: function _applyModification(fn, args) {
|
|
741
|
+
var color = fn.apply(null, [this].concat([].slice.call(args)));
|
|
742
|
+
this._r = color._r;
|
|
743
|
+
this._g = color._g;
|
|
744
|
+
this._b = color._b;
|
|
745
|
+
this.setAlpha(color._a);
|
|
746
|
+
return this;
|
|
747
|
+
},
|
|
748
|
+
lighten: function lighten() {
|
|
749
|
+
return this._applyModification(_lighten, arguments);
|
|
750
|
+
},
|
|
751
|
+
brighten: function brighten() {
|
|
752
|
+
return this._applyModification(_brighten, arguments);
|
|
753
|
+
},
|
|
754
|
+
darken: function darken() {
|
|
755
|
+
return this._applyModification(_darken, arguments);
|
|
756
|
+
},
|
|
757
|
+
desaturate: function desaturate() {
|
|
758
|
+
return this._applyModification(_desaturate, arguments);
|
|
759
|
+
},
|
|
760
|
+
saturate: function saturate() {
|
|
761
|
+
return this._applyModification(_saturate, arguments);
|
|
762
|
+
},
|
|
763
|
+
greyscale: function greyscale() {
|
|
764
|
+
return this._applyModification(_greyscale, arguments);
|
|
765
|
+
},
|
|
766
|
+
spin: function spin() {
|
|
767
|
+
return this._applyModification(_spin, arguments);
|
|
768
|
+
},
|
|
769
|
+
_applyCombination: function _applyCombination(fn, args) {
|
|
770
|
+
return fn.apply(null, [this].concat([].slice.call(args)));
|
|
771
|
+
},
|
|
772
|
+
analogous: function analogous() {
|
|
773
|
+
return this._applyCombination(_analogous, arguments);
|
|
774
|
+
},
|
|
775
|
+
complement: function complement() {
|
|
776
|
+
return this._applyCombination(_complement, arguments);
|
|
777
|
+
},
|
|
778
|
+
monochromatic: function monochromatic() {
|
|
779
|
+
return this._applyCombination(_monochromatic, arguments);
|
|
780
|
+
},
|
|
781
|
+
splitcomplement: function splitcomplement() {
|
|
782
|
+
return this._applyCombination(_splitcomplement, arguments);
|
|
783
|
+
},
|
|
784
|
+
// Disabled until https://github.com/bgrins/TinyColor/issues/254
|
|
785
|
+
// polyad: function (number) {
|
|
786
|
+
// return this._applyCombination(polyad, [number]);
|
|
787
|
+
// },
|
|
788
|
+
triad: function triad() {
|
|
789
|
+
return this._applyCombination(polyad, [3]);
|
|
790
|
+
},
|
|
791
|
+
tetrad: function tetrad() {
|
|
792
|
+
return this._applyCombination(polyad, [4]);
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
tinycolor.fromRatio = function(color, opts) {
|
|
796
|
+
if (_typeof(color) == "object") {
|
|
797
|
+
var newColor = {};
|
|
798
|
+
for (var i in color) {
|
|
799
|
+
if (color.hasOwnProperty(i)) {
|
|
800
|
+
if (i === "a") {
|
|
801
|
+
newColor[i] = color[i];
|
|
802
|
+
} else {
|
|
803
|
+
newColor[i] = convertToPercentage(color[i]);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
color = newColor;
|
|
808
|
+
}
|
|
809
|
+
return tinycolor(color, opts);
|
|
810
|
+
};
|
|
811
|
+
function inputToRGB(color) {
|
|
812
|
+
var rgb = {
|
|
813
|
+
r: 0,
|
|
814
|
+
g: 0,
|
|
815
|
+
b: 0
|
|
816
|
+
};
|
|
817
|
+
var a = 1;
|
|
818
|
+
var s = null;
|
|
819
|
+
var v = null;
|
|
820
|
+
var l = null;
|
|
821
|
+
var ok = false;
|
|
822
|
+
var format = false;
|
|
823
|
+
if (typeof color == "string") {
|
|
824
|
+
color = stringInputToObject(color);
|
|
825
|
+
}
|
|
826
|
+
if (_typeof(color) == "object") {
|
|
827
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
828
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
829
|
+
ok = true;
|
|
830
|
+
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
|
|
831
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
832
|
+
s = convertToPercentage(color.s);
|
|
833
|
+
v = convertToPercentage(color.v);
|
|
834
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
835
|
+
ok = true;
|
|
836
|
+
format = "hsv";
|
|
837
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
838
|
+
s = convertToPercentage(color.s);
|
|
839
|
+
l = convertToPercentage(color.l);
|
|
840
|
+
rgb = hslToRgb(color.h, s, l);
|
|
841
|
+
ok = true;
|
|
842
|
+
format = "hsl";
|
|
843
|
+
}
|
|
844
|
+
if (color.hasOwnProperty("a")) {
|
|
845
|
+
a = color.a;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
a = boundAlpha(a);
|
|
849
|
+
return {
|
|
850
|
+
ok,
|
|
851
|
+
format: color.format || format,
|
|
852
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
853
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
854
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
855
|
+
a
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
function rgbToRgb(r, g, b) {
|
|
859
|
+
return {
|
|
860
|
+
r: bound01(r, 255) * 255,
|
|
861
|
+
g: bound01(g, 255) * 255,
|
|
862
|
+
b: bound01(b, 255) * 255
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
function rgbToHsl(r, g, b) {
|
|
866
|
+
r = bound01(r, 255);
|
|
867
|
+
g = bound01(g, 255);
|
|
868
|
+
b = bound01(b, 255);
|
|
869
|
+
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
870
|
+
var h, s, l = (max + min) / 2;
|
|
871
|
+
if (max == min) {
|
|
872
|
+
h = s = 0;
|
|
873
|
+
} else {
|
|
874
|
+
var d = max - min;
|
|
875
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
876
|
+
switch (max) {
|
|
877
|
+
case r:
|
|
878
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
879
|
+
break;
|
|
880
|
+
case g:
|
|
881
|
+
h = (b - r) / d + 2;
|
|
882
|
+
break;
|
|
883
|
+
case b:
|
|
884
|
+
h = (r - g) / d + 4;
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
h /= 6;
|
|
888
|
+
}
|
|
889
|
+
return {
|
|
890
|
+
h,
|
|
891
|
+
s,
|
|
892
|
+
l
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function hslToRgb(h, s, l) {
|
|
896
|
+
var r, g, b;
|
|
897
|
+
h = bound01(h, 360);
|
|
898
|
+
s = bound01(s, 100);
|
|
899
|
+
l = bound01(l, 100);
|
|
900
|
+
function hue2rgb(p2, q2, t) {
|
|
901
|
+
if (t < 0)
|
|
902
|
+
t += 1;
|
|
903
|
+
if (t > 1)
|
|
904
|
+
t -= 1;
|
|
905
|
+
if (t < 1 / 6)
|
|
906
|
+
return p2 + (q2 - p2) * 6 * t;
|
|
907
|
+
if (t < 1 / 2)
|
|
908
|
+
return q2;
|
|
909
|
+
if (t < 2 / 3)
|
|
910
|
+
return p2 + (q2 - p2) * (2 / 3 - t) * 6;
|
|
911
|
+
return p2;
|
|
912
|
+
}
|
|
913
|
+
if (s === 0) {
|
|
914
|
+
r = g = b = l;
|
|
915
|
+
} else {
|
|
916
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
917
|
+
var p = 2 * l - q;
|
|
918
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
919
|
+
g = hue2rgb(p, q, h);
|
|
920
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
921
|
+
}
|
|
922
|
+
return {
|
|
923
|
+
r: r * 255,
|
|
924
|
+
g: g * 255,
|
|
925
|
+
b: b * 255
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function rgbToHsv(r, g, b) {
|
|
929
|
+
r = bound01(r, 255);
|
|
930
|
+
g = bound01(g, 255);
|
|
931
|
+
b = bound01(b, 255);
|
|
932
|
+
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
933
|
+
var h, s, v = max;
|
|
934
|
+
var d = max - min;
|
|
935
|
+
s = max === 0 ? 0 : d / max;
|
|
936
|
+
if (max == min) {
|
|
937
|
+
h = 0;
|
|
938
|
+
} else {
|
|
939
|
+
switch (max) {
|
|
940
|
+
case r:
|
|
941
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
942
|
+
break;
|
|
943
|
+
case g:
|
|
944
|
+
h = (b - r) / d + 2;
|
|
945
|
+
break;
|
|
946
|
+
case b:
|
|
947
|
+
h = (r - g) / d + 4;
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
h /= 6;
|
|
951
|
+
}
|
|
952
|
+
return {
|
|
953
|
+
h,
|
|
954
|
+
s,
|
|
955
|
+
v
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function hsvToRgb(h, s, v) {
|
|
959
|
+
h = bound01(h, 360) * 6;
|
|
960
|
+
s = bound01(s, 100);
|
|
961
|
+
v = bound01(v, 100);
|
|
962
|
+
var i = Math.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), mod = i % 6, r = [v, q, p, p, t, v][mod], g = [t, v, v, q, p, p][mod], b = [p, p, t, v, v, q][mod];
|
|
963
|
+
return {
|
|
964
|
+
r: r * 255,
|
|
965
|
+
g: g * 255,
|
|
966
|
+
b: b * 255
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
970
|
+
var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
|
|
971
|
+
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
|
|
972
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
973
|
+
}
|
|
974
|
+
return hex.join("");
|
|
975
|
+
}
|
|
976
|
+
function rgbaToHex(r, g, b, a, allow4Char) {
|
|
977
|
+
var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
|
|
978
|
+
if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
|
|
979
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
980
|
+
}
|
|
981
|
+
return hex.join("");
|
|
982
|
+
}
|
|
983
|
+
function rgbaToArgbHex(r, g, b, a) {
|
|
984
|
+
var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
|
|
985
|
+
return hex.join("");
|
|
986
|
+
}
|
|
987
|
+
tinycolor.equals = function(color1, color2) {
|
|
988
|
+
if (!color1 || !color2)
|
|
989
|
+
return false;
|
|
990
|
+
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
|
|
991
|
+
};
|
|
992
|
+
tinycolor.random = function() {
|
|
993
|
+
return tinycolor.fromRatio({
|
|
994
|
+
r: Math.random(),
|
|
995
|
+
g: Math.random(),
|
|
996
|
+
b: Math.random()
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
function _desaturate(color, amount) {
|
|
1000
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
1001
|
+
var hsl = tinycolor(color).toHsl();
|
|
1002
|
+
hsl.s -= amount / 100;
|
|
1003
|
+
hsl.s = clamp01(hsl.s);
|
|
1004
|
+
return tinycolor(hsl);
|
|
1005
|
+
}
|
|
1006
|
+
function _saturate(color, amount) {
|
|
1007
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
1008
|
+
var hsl = tinycolor(color).toHsl();
|
|
1009
|
+
hsl.s += amount / 100;
|
|
1010
|
+
hsl.s = clamp01(hsl.s);
|
|
1011
|
+
return tinycolor(hsl);
|
|
1012
|
+
}
|
|
1013
|
+
function _greyscale(color) {
|
|
1014
|
+
return tinycolor(color).desaturate(100);
|
|
1015
|
+
}
|
|
1016
|
+
function _lighten(color, amount) {
|
|
1017
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
1018
|
+
var hsl = tinycolor(color).toHsl();
|
|
1019
|
+
hsl.l += amount / 100;
|
|
1020
|
+
hsl.l = clamp01(hsl.l);
|
|
1021
|
+
return tinycolor(hsl);
|
|
1022
|
+
}
|
|
1023
|
+
function _brighten(color, amount) {
|
|
1024
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
1025
|
+
var rgb = tinycolor(color).toRgb();
|
|
1026
|
+
rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
|
|
1027
|
+
rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
|
|
1028
|
+
rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
|
|
1029
|
+
return tinycolor(rgb);
|
|
1030
|
+
}
|
|
1031
|
+
function _darken(color, amount) {
|
|
1032
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
1033
|
+
var hsl = tinycolor(color).toHsl();
|
|
1034
|
+
hsl.l -= amount / 100;
|
|
1035
|
+
hsl.l = clamp01(hsl.l);
|
|
1036
|
+
return tinycolor(hsl);
|
|
1037
|
+
}
|
|
1038
|
+
function _spin(color, amount) {
|
|
1039
|
+
var hsl = tinycolor(color).toHsl();
|
|
1040
|
+
var hue = (hsl.h + amount) % 360;
|
|
1041
|
+
hsl.h = hue < 0 ? 360 + hue : hue;
|
|
1042
|
+
return tinycolor(hsl);
|
|
1043
|
+
}
|
|
1044
|
+
function _complement(color) {
|
|
1045
|
+
var hsl = tinycolor(color).toHsl();
|
|
1046
|
+
hsl.h = (hsl.h + 180) % 360;
|
|
1047
|
+
return tinycolor(hsl);
|
|
1048
|
+
}
|
|
1049
|
+
function polyad(color, number) {
|
|
1050
|
+
if (isNaN(number) || number <= 0) {
|
|
1051
|
+
throw new Error("Argument to polyad must be a positive number");
|
|
1052
|
+
}
|
|
1053
|
+
var hsl = tinycolor(color).toHsl();
|
|
1054
|
+
var result = [tinycolor(color)];
|
|
1055
|
+
var step = 360 / number;
|
|
1056
|
+
for (var i = 1; i < number; i++) {
|
|
1057
|
+
result.push(tinycolor({
|
|
1058
|
+
h: (hsl.h + i * step) % 360,
|
|
1059
|
+
s: hsl.s,
|
|
1060
|
+
l: hsl.l
|
|
1061
|
+
}));
|
|
1062
|
+
}
|
|
1063
|
+
return result;
|
|
1064
|
+
}
|
|
1065
|
+
function _splitcomplement(color) {
|
|
1066
|
+
var hsl = tinycolor(color).toHsl();
|
|
1067
|
+
var h = hsl.h;
|
|
1068
|
+
return [tinycolor(color), tinycolor({
|
|
1069
|
+
h: (h + 72) % 360,
|
|
1070
|
+
s: hsl.s,
|
|
1071
|
+
l: hsl.l
|
|
1072
|
+
}), tinycolor({
|
|
1073
|
+
h: (h + 216) % 360,
|
|
1074
|
+
s: hsl.s,
|
|
1075
|
+
l: hsl.l
|
|
1076
|
+
})];
|
|
1077
|
+
}
|
|
1078
|
+
function _analogous(color, results, slices) {
|
|
1079
|
+
results = results || 6;
|
|
1080
|
+
slices = slices || 30;
|
|
1081
|
+
var hsl = tinycolor(color).toHsl();
|
|
1082
|
+
var part = 360 / slices;
|
|
1083
|
+
var ret = [tinycolor(color)];
|
|
1084
|
+
for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
|
|
1085
|
+
hsl.h = (hsl.h + part) % 360;
|
|
1086
|
+
ret.push(tinycolor(hsl));
|
|
1087
|
+
}
|
|
1088
|
+
return ret;
|
|
1089
|
+
}
|
|
1090
|
+
function _monochromatic(color, results) {
|
|
1091
|
+
results = results || 6;
|
|
1092
|
+
var hsv = tinycolor(color).toHsv();
|
|
1093
|
+
var h = hsv.h, s = hsv.s, v = hsv.v;
|
|
1094
|
+
var ret = [];
|
|
1095
|
+
var modification = 1 / results;
|
|
1096
|
+
while (results--) {
|
|
1097
|
+
ret.push(tinycolor({
|
|
1098
|
+
h,
|
|
1099
|
+
s,
|
|
1100
|
+
v
|
|
1101
|
+
}));
|
|
1102
|
+
v = (v + modification) % 1;
|
|
1103
|
+
}
|
|
1104
|
+
return ret;
|
|
1105
|
+
}
|
|
1106
|
+
tinycolor.mix = function(color1, color2, amount) {
|
|
1107
|
+
amount = amount === 0 ? 0 : amount || 50;
|
|
1108
|
+
var rgb1 = tinycolor(color1).toRgb();
|
|
1109
|
+
var rgb2 = tinycolor(color2).toRgb();
|
|
1110
|
+
var p = amount / 100;
|
|
1111
|
+
var rgba = {
|
|
1112
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
1113
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
1114
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b,
|
|
1115
|
+
a: (rgb2.a - rgb1.a) * p + rgb1.a
|
|
1116
|
+
};
|
|
1117
|
+
return tinycolor(rgba);
|
|
1118
|
+
};
|
|
1119
|
+
tinycolor.readability = function(color1, color2) {
|
|
1120
|
+
var c1 = tinycolor(color1);
|
|
1121
|
+
var c2 = tinycolor(color2);
|
|
1122
|
+
return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
|
|
1123
|
+
};
|
|
1124
|
+
tinycolor.isReadable = function(color1, color2, wcag2) {
|
|
1125
|
+
var readability = tinycolor.readability(color1, color2);
|
|
1126
|
+
var wcag2Parms, out;
|
|
1127
|
+
out = false;
|
|
1128
|
+
wcag2Parms = validateWCAG2Parms(wcag2);
|
|
1129
|
+
switch (wcag2Parms.level + wcag2Parms.size) {
|
|
1130
|
+
case "AAsmall":
|
|
1131
|
+
case "AAAlarge":
|
|
1132
|
+
out = readability >= 4.5;
|
|
1133
|
+
break;
|
|
1134
|
+
case "AAlarge":
|
|
1135
|
+
out = readability >= 3;
|
|
1136
|
+
break;
|
|
1137
|
+
case "AAAsmall":
|
|
1138
|
+
out = readability >= 7;
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
return out;
|
|
1142
|
+
};
|
|
1143
|
+
tinycolor.mostReadable = function(baseColor, colorList, args) {
|
|
1144
|
+
var bestColor = null;
|
|
1145
|
+
var bestScore = 0;
|
|
1146
|
+
var readability;
|
|
1147
|
+
var includeFallbackColors, level, size;
|
|
1148
|
+
args = args || {};
|
|
1149
|
+
includeFallbackColors = args.includeFallbackColors;
|
|
1150
|
+
level = args.level;
|
|
1151
|
+
size = args.size;
|
|
1152
|
+
for (var i = 0; i < colorList.length; i++) {
|
|
1153
|
+
readability = tinycolor.readability(baseColor, colorList[i]);
|
|
1154
|
+
if (readability > bestScore) {
|
|
1155
|
+
bestScore = readability;
|
|
1156
|
+
bestColor = tinycolor(colorList[i]);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
if (tinycolor.isReadable(baseColor, bestColor, {
|
|
1160
|
+
level,
|
|
1161
|
+
size
|
|
1162
|
+
}) || !includeFallbackColors) {
|
|
1163
|
+
return bestColor;
|
|
1164
|
+
} else {
|
|
1165
|
+
args.includeFallbackColors = false;
|
|
1166
|
+
return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
var names = tinycolor.names = {
|
|
1170
|
+
aliceblue: "f0f8ff",
|
|
1171
|
+
antiquewhite: "faebd7",
|
|
1172
|
+
aqua: "0ff",
|
|
1173
|
+
aquamarine: "7fffd4",
|
|
1174
|
+
azure: "f0ffff",
|
|
1175
|
+
beige: "f5f5dc",
|
|
1176
|
+
bisque: "ffe4c4",
|
|
1177
|
+
black: "000",
|
|
1178
|
+
blanchedalmond: "ffebcd",
|
|
1179
|
+
blue: "00f",
|
|
1180
|
+
blueviolet: "8a2be2",
|
|
1181
|
+
brown: "a52a2a",
|
|
1182
|
+
burlywood: "deb887",
|
|
1183
|
+
burntsienna: "ea7e5d",
|
|
1184
|
+
cadetblue: "5f9ea0",
|
|
1185
|
+
chartreuse: "7fff00",
|
|
1186
|
+
chocolate: "d2691e",
|
|
1187
|
+
coral: "ff7f50",
|
|
1188
|
+
cornflowerblue: "6495ed",
|
|
1189
|
+
cornsilk: "fff8dc",
|
|
1190
|
+
crimson: "dc143c",
|
|
1191
|
+
cyan: "0ff",
|
|
1192
|
+
darkblue: "00008b",
|
|
1193
|
+
darkcyan: "008b8b",
|
|
1194
|
+
darkgoldenrod: "b8860b",
|
|
1195
|
+
darkgray: "a9a9a9",
|
|
1196
|
+
darkgreen: "006400",
|
|
1197
|
+
darkgrey: "a9a9a9",
|
|
1198
|
+
darkkhaki: "bdb76b",
|
|
1199
|
+
darkmagenta: "8b008b",
|
|
1200
|
+
darkolivegreen: "556b2f",
|
|
1201
|
+
darkorange: "ff8c00",
|
|
1202
|
+
darkorchid: "9932cc",
|
|
1203
|
+
darkred: "8b0000",
|
|
1204
|
+
darksalmon: "e9967a",
|
|
1205
|
+
darkseagreen: "8fbc8f",
|
|
1206
|
+
darkslateblue: "483d8b",
|
|
1207
|
+
darkslategray: "2f4f4f",
|
|
1208
|
+
darkslategrey: "2f4f4f",
|
|
1209
|
+
darkturquoise: "00ced1",
|
|
1210
|
+
darkviolet: "9400d3",
|
|
1211
|
+
deeppink: "ff1493",
|
|
1212
|
+
deepskyblue: "00bfff",
|
|
1213
|
+
dimgray: "696969",
|
|
1214
|
+
dimgrey: "696969",
|
|
1215
|
+
dodgerblue: "1e90ff",
|
|
1216
|
+
firebrick: "b22222",
|
|
1217
|
+
floralwhite: "fffaf0",
|
|
1218
|
+
forestgreen: "228b22",
|
|
1219
|
+
fuchsia: "f0f",
|
|
1220
|
+
gainsboro: "dcdcdc",
|
|
1221
|
+
ghostwhite: "f8f8ff",
|
|
1222
|
+
gold: "ffd700",
|
|
1223
|
+
goldenrod: "daa520",
|
|
1224
|
+
gray: "808080",
|
|
1225
|
+
green: "008000",
|
|
1226
|
+
greenyellow: "adff2f",
|
|
1227
|
+
grey: "808080",
|
|
1228
|
+
honeydew: "f0fff0",
|
|
1229
|
+
hotpink: "ff69b4",
|
|
1230
|
+
indianred: "cd5c5c",
|
|
1231
|
+
indigo: "4b0082",
|
|
1232
|
+
ivory: "fffff0",
|
|
1233
|
+
khaki: "f0e68c",
|
|
1234
|
+
lavender: "e6e6fa",
|
|
1235
|
+
lavenderblush: "fff0f5",
|
|
1236
|
+
lawngreen: "7cfc00",
|
|
1237
|
+
lemonchiffon: "fffacd",
|
|
1238
|
+
lightblue: "add8e6",
|
|
1239
|
+
lightcoral: "f08080",
|
|
1240
|
+
lightcyan: "e0ffff",
|
|
1241
|
+
lightgoldenrodyellow: "fafad2",
|
|
1242
|
+
lightgray: "d3d3d3",
|
|
1243
|
+
lightgreen: "90ee90",
|
|
1244
|
+
lightgrey: "d3d3d3",
|
|
1245
|
+
lightpink: "ffb6c1",
|
|
1246
|
+
lightsalmon: "ffa07a",
|
|
1247
|
+
lightseagreen: "20b2aa",
|
|
1248
|
+
lightskyblue: "87cefa",
|
|
1249
|
+
lightslategray: "789",
|
|
1250
|
+
lightslategrey: "789",
|
|
1251
|
+
lightsteelblue: "b0c4de",
|
|
1252
|
+
lightyellow: "ffffe0",
|
|
1253
|
+
lime: "0f0",
|
|
1254
|
+
limegreen: "32cd32",
|
|
1255
|
+
linen: "faf0e6",
|
|
1256
|
+
magenta: "f0f",
|
|
1257
|
+
maroon: "800000",
|
|
1258
|
+
mediumaquamarine: "66cdaa",
|
|
1259
|
+
mediumblue: "0000cd",
|
|
1260
|
+
mediumorchid: "ba55d3",
|
|
1261
|
+
mediumpurple: "9370db",
|
|
1262
|
+
mediumseagreen: "3cb371",
|
|
1263
|
+
mediumslateblue: "7b68ee",
|
|
1264
|
+
mediumspringgreen: "00fa9a",
|
|
1265
|
+
mediumturquoise: "48d1cc",
|
|
1266
|
+
mediumvioletred: "c71585",
|
|
1267
|
+
midnightblue: "191970",
|
|
1268
|
+
mintcream: "f5fffa",
|
|
1269
|
+
mistyrose: "ffe4e1",
|
|
1270
|
+
moccasin: "ffe4b5",
|
|
1271
|
+
navajowhite: "ffdead",
|
|
1272
|
+
navy: "000080",
|
|
1273
|
+
oldlace: "fdf5e6",
|
|
1274
|
+
olive: "808000",
|
|
1275
|
+
olivedrab: "6b8e23",
|
|
1276
|
+
orange: "ffa500",
|
|
1277
|
+
orangered: "ff4500",
|
|
1278
|
+
orchid: "da70d6",
|
|
1279
|
+
palegoldenrod: "eee8aa",
|
|
1280
|
+
palegreen: "98fb98",
|
|
1281
|
+
paleturquoise: "afeeee",
|
|
1282
|
+
palevioletred: "db7093",
|
|
1283
|
+
papayawhip: "ffefd5",
|
|
1284
|
+
peachpuff: "ffdab9",
|
|
1285
|
+
peru: "cd853f",
|
|
1286
|
+
pink: "ffc0cb",
|
|
1287
|
+
plum: "dda0dd",
|
|
1288
|
+
powderblue: "b0e0e6",
|
|
1289
|
+
purple: "800080",
|
|
1290
|
+
rebeccapurple: "663399",
|
|
1291
|
+
red: "f00",
|
|
1292
|
+
rosybrown: "bc8f8f",
|
|
1293
|
+
royalblue: "4169e1",
|
|
1294
|
+
saddlebrown: "8b4513",
|
|
1295
|
+
salmon: "fa8072",
|
|
1296
|
+
sandybrown: "f4a460",
|
|
1297
|
+
seagreen: "2e8b57",
|
|
1298
|
+
seashell: "fff5ee",
|
|
1299
|
+
sienna: "a0522d",
|
|
1300
|
+
silver: "c0c0c0",
|
|
1301
|
+
skyblue: "87ceeb",
|
|
1302
|
+
slateblue: "6a5acd",
|
|
1303
|
+
slategray: "708090",
|
|
1304
|
+
slategrey: "708090",
|
|
1305
|
+
snow: "fffafa",
|
|
1306
|
+
springgreen: "00ff7f",
|
|
1307
|
+
steelblue: "4682b4",
|
|
1308
|
+
tan: "d2b48c",
|
|
1309
|
+
teal: "008080",
|
|
1310
|
+
thistle: "d8bfd8",
|
|
1311
|
+
tomato: "ff6347",
|
|
1312
|
+
turquoise: "40e0d0",
|
|
1313
|
+
violet: "ee82ee",
|
|
1314
|
+
wheat: "f5deb3",
|
|
1315
|
+
white: "fff",
|
|
1316
|
+
whitesmoke: "f5f5f5",
|
|
1317
|
+
yellow: "ff0",
|
|
1318
|
+
yellowgreen: "9acd32"
|
|
1319
|
+
};
|
|
1320
|
+
var hexNames = tinycolor.hexNames = flip(names);
|
|
1321
|
+
function flip(o) {
|
|
1322
|
+
var flipped = {};
|
|
1323
|
+
for (var i in o) {
|
|
1324
|
+
if (o.hasOwnProperty(i)) {
|
|
1325
|
+
flipped[o[i]] = i;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
return flipped;
|
|
1329
|
+
}
|
|
1330
|
+
function boundAlpha(a) {
|
|
1331
|
+
a = parseFloat(a);
|
|
1332
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
1333
|
+
a = 1;
|
|
1334
|
+
}
|
|
1335
|
+
return a;
|
|
1336
|
+
}
|
|
1337
|
+
function bound01(n, max) {
|
|
1338
|
+
if (isOnePointZero(n))
|
|
1339
|
+
n = "100%";
|
|
1340
|
+
var processPercent = isPercentage(n);
|
|
1341
|
+
n = Math.min(max, Math.max(0, parseFloat(n)));
|
|
1342
|
+
if (processPercent) {
|
|
1343
|
+
n = parseInt(n * max, 10) / 100;
|
|
1344
|
+
}
|
|
1345
|
+
if (Math.abs(n - max) < 1e-6) {
|
|
1346
|
+
return 1;
|
|
1347
|
+
}
|
|
1348
|
+
return n % max / parseFloat(max);
|
|
1349
|
+
}
|
|
1350
|
+
function clamp01(val) {
|
|
1351
|
+
return Math.min(1, Math.max(0, val));
|
|
1352
|
+
}
|
|
1353
|
+
function parseIntFromHex(val) {
|
|
1354
|
+
return parseInt(val, 16);
|
|
1355
|
+
}
|
|
1356
|
+
function isOnePointZero(n) {
|
|
1357
|
+
return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
|
|
1358
|
+
}
|
|
1359
|
+
function isPercentage(n) {
|
|
1360
|
+
return typeof n === "string" && n.indexOf("%") != -1;
|
|
1361
|
+
}
|
|
1362
|
+
function pad2(c) {
|
|
1363
|
+
return c.length == 1 ? "0" + c : "" + c;
|
|
1364
|
+
}
|
|
1365
|
+
function convertToPercentage(n) {
|
|
1366
|
+
if (n <= 1) {
|
|
1367
|
+
n = n * 100 + "%";
|
|
1368
|
+
}
|
|
1369
|
+
return n;
|
|
1370
|
+
}
|
|
1371
|
+
function convertDecimalToHex(d) {
|
|
1372
|
+
return Math.round(parseFloat(d) * 255).toString(16);
|
|
1373
|
+
}
|
|
1374
|
+
function convertHexToDecimal(h) {
|
|
1375
|
+
return parseIntFromHex(h) / 255;
|
|
1376
|
+
}
|
|
1377
|
+
var matchers = function() {
|
|
1378
|
+
var CSS_INTEGER = "[-\\+]?\\d+%?";
|
|
1379
|
+
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
|
|
1380
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
1381
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
1382
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
1383
|
+
return {
|
|
1384
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
1385
|
+
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
|
|
1386
|
+
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
|
|
1387
|
+
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
|
1388
|
+
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
|
1389
|
+
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
|
1390
|
+
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
|
1391
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
1392
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
1393
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
1394
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
1395
|
+
};
|
|
1396
|
+
}();
|
|
1397
|
+
function isValidCSSUnit(color) {
|
|
1398
|
+
return !!matchers.CSS_UNIT.exec(color);
|
|
1399
|
+
}
|
|
1400
|
+
function stringInputToObject(color) {
|
|
1401
|
+
color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
|
|
1402
|
+
var named = false;
|
|
1403
|
+
if (names[color]) {
|
|
1404
|
+
color = names[color];
|
|
1405
|
+
named = true;
|
|
1406
|
+
} else if (color == "transparent") {
|
|
1407
|
+
return {
|
|
1408
|
+
r: 0,
|
|
1409
|
+
g: 0,
|
|
1410
|
+
b: 0,
|
|
1411
|
+
a: 0,
|
|
1412
|
+
format: "name"
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
var match;
|
|
1416
|
+
if (match = matchers.rgb.exec(color)) {
|
|
1417
|
+
return {
|
|
1418
|
+
r: match[1],
|
|
1419
|
+
g: match[2],
|
|
1420
|
+
b: match[3]
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
if (match = matchers.rgba.exec(color)) {
|
|
1424
|
+
return {
|
|
1425
|
+
r: match[1],
|
|
1426
|
+
g: match[2],
|
|
1427
|
+
b: match[3],
|
|
1428
|
+
a: match[4]
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
if (match = matchers.hsl.exec(color)) {
|
|
1432
|
+
return {
|
|
1433
|
+
h: match[1],
|
|
1434
|
+
s: match[2],
|
|
1435
|
+
l: match[3]
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
if (match = matchers.hsla.exec(color)) {
|
|
1439
|
+
return {
|
|
1440
|
+
h: match[1],
|
|
1441
|
+
s: match[2],
|
|
1442
|
+
l: match[3],
|
|
1443
|
+
a: match[4]
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
if (match = matchers.hsv.exec(color)) {
|
|
1447
|
+
return {
|
|
1448
|
+
h: match[1],
|
|
1449
|
+
s: match[2],
|
|
1450
|
+
v: match[3]
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
if (match = matchers.hsva.exec(color)) {
|
|
1454
|
+
return {
|
|
1455
|
+
h: match[1],
|
|
1456
|
+
s: match[2],
|
|
1457
|
+
v: match[3],
|
|
1458
|
+
a: match[4]
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
if (match = matchers.hex8.exec(color)) {
|
|
1462
|
+
return {
|
|
1463
|
+
r: parseIntFromHex(match[1]),
|
|
1464
|
+
g: parseIntFromHex(match[2]),
|
|
1465
|
+
b: parseIntFromHex(match[3]),
|
|
1466
|
+
a: convertHexToDecimal(match[4]),
|
|
1467
|
+
format: named ? "name" : "hex8"
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
if (match = matchers.hex6.exec(color)) {
|
|
1471
|
+
return {
|
|
1472
|
+
r: parseIntFromHex(match[1]),
|
|
1473
|
+
g: parseIntFromHex(match[2]),
|
|
1474
|
+
b: parseIntFromHex(match[3]),
|
|
1475
|
+
format: named ? "name" : "hex"
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
if (match = matchers.hex4.exec(color)) {
|
|
1479
|
+
return {
|
|
1480
|
+
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
1481
|
+
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
1482
|
+
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
1483
|
+
a: convertHexToDecimal(match[4] + "" + match[4]),
|
|
1484
|
+
format: named ? "name" : "hex8"
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
if (match = matchers.hex3.exec(color)) {
|
|
1488
|
+
return {
|
|
1489
|
+
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
1490
|
+
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
1491
|
+
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
1492
|
+
format: named ? "name" : "hex"
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
return false;
|
|
1496
|
+
}
|
|
1497
|
+
function validateWCAG2Parms(parms) {
|
|
1498
|
+
var level, size;
|
|
1499
|
+
parms = parms || {
|
|
1500
|
+
level: "AA",
|
|
1501
|
+
size: "small"
|
|
1502
|
+
};
|
|
1503
|
+
level = (parms.level || "AA").toUpperCase();
|
|
1504
|
+
size = (parms.size || "small").toLowerCase();
|
|
1505
|
+
if (level !== "AA" && level !== "AAA") {
|
|
1506
|
+
level = "AA";
|
|
1507
|
+
}
|
|
1508
|
+
if (size !== "small" && size !== "large") {
|
|
1509
|
+
size = "small";
|
|
1510
|
+
}
|
|
1511
|
+
return {
|
|
1512
|
+
level,
|
|
1513
|
+
size
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
|
|
531
1517
|
// src/colors.ts
|
|
1518
|
+
import { clamp } from "@excalidraw/math";
|
|
1519
|
+
import { degreesToRadians } from "@excalidraw/math";
|
|
1520
|
+
var DARK_MODE_COLORS_CACHE = typeof window !== "undefined" ? /* @__PURE__ */ new Map() : null;
|
|
1521
|
+
function cssHueRotate(red, green, blue, degrees) {
|
|
1522
|
+
const r = red / 255;
|
|
1523
|
+
const g = green / 255;
|
|
1524
|
+
const b = blue / 255;
|
|
1525
|
+
const a = degreesToRadians(degrees);
|
|
1526
|
+
const c = Math.cos(a);
|
|
1527
|
+
const s = Math.sin(a);
|
|
1528
|
+
const matrix = [
|
|
1529
|
+
0.213 + c * 0.787 - s * 0.213,
|
|
1530
|
+
0.715 - c * 0.715 - s * 0.715,
|
|
1531
|
+
0.072 - c * 0.072 + s * 0.928,
|
|
1532
|
+
0.213 - c * 0.213 + s * 0.143,
|
|
1533
|
+
0.715 + c * 0.285 + s * 0.14,
|
|
1534
|
+
0.072 - c * 0.072 - s * 0.283,
|
|
1535
|
+
0.213 - c * 0.213 - s * 0.787,
|
|
1536
|
+
0.715 - c * 0.715 + s * 0.715,
|
|
1537
|
+
0.072 + c * 0.928 + s * 0.072
|
|
1538
|
+
];
|
|
1539
|
+
const newR = r * matrix[0] + g * matrix[1] + b * matrix[2];
|
|
1540
|
+
const newG = r * matrix[3] + g * matrix[4] + b * matrix[5];
|
|
1541
|
+
const newB = r * matrix[6] + g * matrix[7] + b * matrix[8];
|
|
1542
|
+
return {
|
|
1543
|
+
r: Math.round(Math.max(0, Math.min(1, newR)) * 255),
|
|
1544
|
+
g: Math.round(Math.max(0, Math.min(1, newG)) * 255),
|
|
1545
|
+
b: Math.round(Math.max(0, Math.min(1, newB)) * 255)
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
var cssInvert = (r, g, b, percent) => {
|
|
1549
|
+
const p = clamp(percent, 0, 100) / 100;
|
|
1550
|
+
const invertComponent = (color) => {
|
|
1551
|
+
const inverted = color * (1 - p) + (255 - color) * p;
|
|
1552
|
+
return Math.round(clamp(inverted, 0, 255));
|
|
1553
|
+
};
|
|
1554
|
+
const invertedR = invertComponent(r);
|
|
1555
|
+
const invertedG = invertComponent(g);
|
|
1556
|
+
const invertedB = invertComponent(b);
|
|
1557
|
+
return { r: invertedR, g: invertedG, b: invertedB };
|
|
1558
|
+
};
|
|
1559
|
+
var applyDarkModeFilter = (color) => {
|
|
1560
|
+
const cached = DARK_MODE_COLORS_CACHE?.get(color);
|
|
1561
|
+
if (cached) {
|
|
1562
|
+
return cached;
|
|
1563
|
+
}
|
|
1564
|
+
const tc = tinycolor(color);
|
|
1565
|
+
const alpha = tc.getAlpha();
|
|
1566
|
+
const rgb = tc.toRgb();
|
|
1567
|
+
const inverted = cssInvert(rgb.r, rgb.g, rgb.b, 93);
|
|
1568
|
+
const rotated = cssHueRotate(
|
|
1569
|
+
inverted.r,
|
|
1570
|
+
inverted.g,
|
|
1571
|
+
inverted.b,
|
|
1572
|
+
180
|
|
1573
|
+
);
|
|
1574
|
+
const result = rgbToHex2(rotated.r, rotated.g, rotated.b, alpha);
|
|
1575
|
+
if (DARK_MODE_COLORS_CACHE) {
|
|
1576
|
+
DARK_MODE_COLORS_CACHE.set(color, result);
|
|
1577
|
+
}
|
|
1578
|
+
return result;
|
|
1579
|
+
};
|
|
532
1580
|
var COLOR_OUTLINE_CONTRAST_THRESHOLD = 240;
|
|
533
1581
|
var pick = (source, keys) => {
|
|
534
1582
|
return keys.reduce((acc, key) => {
|
|
@@ -636,7 +1684,14 @@ var getAllColorsSpecificShade = (index) => [
|
|
|
636
1684
|
COLOR_PALETTE.orange[index],
|
|
637
1685
|
COLOR_PALETTE.red[index]
|
|
638
1686
|
];
|
|
639
|
-
var
|
|
1687
|
+
var rgbToHex2 = (r, g, b, a) => {
|
|
1688
|
+
const hex6 = `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
|
|
1689
|
+
if (a !== void 0 && a < 1) {
|
|
1690
|
+
const alphaHex = Math.round(a * 255).toString(16).padStart(2, "0");
|
|
1691
|
+
return `${hex6}${alphaHex}`;
|
|
1692
|
+
}
|
|
1693
|
+
return hex6;
|
|
1694
|
+
};
|
|
640
1695
|
|
|
641
1696
|
// src/constants.ts
|
|
642
1697
|
init_define_import_meta_env();
|
|
@@ -729,6 +1784,12 @@ var CLASSES = {
|
|
|
729
1784
|
SHAPE_ACTIONS_THEME_SCOPE: "shape-actions-theme-scope",
|
|
730
1785
|
FRAME_NAME: "frame-name"
|
|
731
1786
|
};
|
|
1787
|
+
var FONT_SIZES = {
|
|
1788
|
+
sm: 16,
|
|
1789
|
+
md: 20,
|
|
1790
|
+
lg: 28,
|
|
1791
|
+
xl: 36
|
|
1792
|
+
};
|
|
732
1793
|
var CJK_HAND_DRAWN_FALLBACK_FONT = "Xiaolai";
|
|
733
1794
|
var WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
734
1795
|
var FONT_FAMILY = {
|
|
@@ -872,7 +1933,6 @@ var MAX_ZOOM = 30;
|
|
|
872
1933
|
var HYPERLINK_TOOLTIP_DELAY = 300;
|
|
873
1934
|
var IDLE_THRESHOLD = 6e4;
|
|
874
1935
|
var ACTIVE_THRESHOLD = 3e3;
|
|
875
|
-
var THEME_FILTER = "invert(93%) hue-rotate(180deg)";
|
|
876
1936
|
var URL_QUERY_KEYS = {
|
|
877
1937
|
addLibrary: "addLibrary"
|
|
878
1938
|
};
|
|
@@ -1826,9 +2886,7 @@ var mapFind = (collection, iteratee) => {
|
|
|
1826
2886
|
return void 0;
|
|
1827
2887
|
};
|
|
1828
2888
|
var isTransparent = (color) => {
|
|
1829
|
-
|
|
1830
|
-
const isRRGGBBTransparent = color.length === 9 && color.substr(7, 2) === "00";
|
|
1831
|
-
return isRGBTransparent || isRRGGBBTransparent || color === COLOR_PALETTE.transparent;
|
|
2889
|
+
return tinycolor(color).getAlpha() === 0;
|
|
1832
2890
|
};
|
|
1833
2891
|
var resolvablePromise = () => {
|
|
1834
2892
|
let resolve;
|
|
@@ -2150,9 +3208,9 @@ function getSvgPathFromStroke(points, closed = true) {
|
|
|
2150
3208
|
var normalizeEOL = (str) => {
|
|
2151
3209
|
return str.replace(/\r?\n|\r/g, "\n");
|
|
2152
3210
|
};
|
|
2153
|
-
|
|
3211
|
+
function toBrandedType(value) {
|
|
2154
3212
|
return value;
|
|
2155
|
-
}
|
|
3213
|
+
}
|
|
2156
3214
|
var promiseTry = async (fn, ...args) => {
|
|
2157
3215
|
return new Promise((resolve) => {
|
|
2158
3216
|
resolve(fn(...args));
|
|
@@ -2305,7 +3363,6 @@ import {
|
|
|
2305
3363
|
lineSegment,
|
|
2306
3364
|
pointFrom
|
|
2307
3365
|
} from "@excalidraw/math";
|
|
2308
|
-
import { isBounds } from "@excalidraw/element";
|
|
2309
3366
|
var debugDrawCubicBezier = (c, opts) => {
|
|
2310
3367
|
addToCurrentFrame({
|
|
2311
3368
|
color: opts?.color ?? "purple",
|
|
@@ -2468,6 +3525,7 @@ export {
|
|
|
2468
3525
|
FONT_FAMILY_FALLBACKS,
|
|
2469
3526
|
FONT_FAMILY_GENERIC_FALLBACKS,
|
|
2470
3527
|
FONT_METADATA,
|
|
3528
|
+
FONT_SIZES,
|
|
2471
3529
|
FRAME_STYLE,
|
|
2472
3530
|
GOOGLE_FONTS_RANGES,
|
|
2473
3531
|
HYPERLINK_TOOLTIP_DELAY,
|
|
@@ -2520,7 +3578,6 @@ export {
|
|
|
2520
3578
|
TEXT_AUTOWRAP_THRESHOLD,
|
|
2521
3579
|
TEXT_TO_CENTER_SNAP_THRESHOLD,
|
|
2522
3580
|
THEME,
|
|
2523
|
-
THEME_FILTER,
|
|
2524
3581
|
TITLE_TIMEOUT,
|
|
2525
3582
|
TOOL_TYPE,
|
|
2526
3583
|
TOUCH_CTX_MENU_TIMEOUT,
|
|
@@ -2535,6 +3592,7 @@ export {
|
|
|
2535
3592
|
ZOOM_STEP,
|
|
2536
3593
|
addEventListener,
|
|
2537
3594
|
allowFullScreen,
|
|
3595
|
+
applyDarkModeFilter,
|
|
2538
3596
|
arrayToList,
|
|
2539
3597
|
arrayToMap,
|
|
2540
3598
|
arrayToMapWithIndex,
|
|
@@ -2588,6 +3646,7 @@ export {
|
|
|
2588
3646
|
isAndroid,
|
|
2589
3647
|
isAnyTrue,
|
|
2590
3648
|
isArrowKey,
|
|
3649
|
+
isBounds,
|
|
2591
3650
|
isBrave,
|
|
2592
3651
|
isChrome,
|
|
2593
3652
|
isDarwin,
|
|
@@ -2636,7 +3695,7 @@ export {
|
|
|
2636
3695
|
rescalePoints,
|
|
2637
3696
|
reseed,
|
|
2638
3697
|
resolvablePromise,
|
|
2639
|
-
rgbToHex,
|
|
3698
|
+
rgbToHex2 as rgbToHex,
|
|
2640
3699
|
safelyParseJSON,
|
|
2641
3700
|
sceneCoordsToViewportCoords,
|
|
2642
3701
|
selectNode,
|
|
@@ -2650,6 +3709,7 @@ export {
|
|
|
2650
3709
|
supportsEmoji,
|
|
2651
3710
|
supportsResizeObserver,
|
|
2652
3711
|
throttleRAF,
|
|
3712
|
+
tinycolor,
|
|
2653
3713
|
toArray,
|
|
2654
3714
|
toBrandedType,
|
|
2655
3715
|
toIterable,
|