8#include "helperposixmath.h"
13#include <qnamespace.h>
14#include <qregularexpression.h>
16#include <qstringbuilder.h>
17#include <qstringliteral.h>
18#include <qstringview.h>
36std::optional<QRgb> CssColor::parseHexColor(
const QString &hexColor)
38 if (hexColor.
length() > 9) {
42 QString capturedDigits = regex.match(hexColor).captured(1);
43 switch (capturedDigits.
length()) {
46 capturedDigits = capturedDigits.
at(0) + capturedDigits.
at(0)
47 + capturedDigits.
at(1) + capturedDigits.
at(1)
48 + capturedDigits.
at(2) + capturedDigits.
at(2);
51 capturedDigits = capturedDigits.
at(0) + capturedDigits.
at(0)
52 + capturedDigits.
at(1) + capturedDigits.
at(1)
53 + capturedDigits.
at(2) + capturedDigits.
at(2)
54 + capturedDigits.
at(3) + capturedDigits.
at(3);
57 if (capturedDigits.
length() == 6) {
59 capturedDigits += QStringLiteral(
"ff");
61 if (capturedDigits.
length() == 8) {
63 const auto red = view.mid(0, 2).toInt(
nullptr, 16);
64 const auto green = view.mid(2, 2).toInt(
nullptr, 16);
65 const auto blue = view.mid(4, 2).toInt(
nullptr, 16);
66 const auto alpha = view.mid(6, 2).toInt(
nullptr, 16);
67 return qRgba(red, green, blue, alpha);
80std::optional<QStringList> CssColor::validateArguments(
const QStringList &arguments)
83 for (
const QString &argument : std::as_const(arguments)) {
85 if (simplifiedString.
contains(QStringLiteral(
" "))
86 || simplifiedString.
contains(QStringLiteral(
","))
87 || simplifiedString.
contains(QStringLiteral(
"/"))
88 || simplifiedString.
isEmpty()) {
91 result.
append(simplifiedString);
114std::optional<QStringList> CssColor::parseAllFunctionArguments(
const QString &arguments,
const FunctionSyntax mode,
const int count)
116 if (arguments.
count(QStringLiteral(
",")) > 0) {
118 if (mode == FunctionSyntax::BothSyntaxes || mode == FunctionSyntax::LegacySyntax) {
120 if (arguments.
count(QStringLiteral(
"/")) > 0) {
124 auto result = arguments.
split(QStringLiteral(
","),
126 if (result.
count() == count - 1) {
128 result.
append(QStringLiteral(
"none"));
130 if (result.
count() != count) {
133 return validateArguments(result);
141 if (mode == FunctionSyntax::LegacySyntax) {
145 const auto parts = arguments.
split(QStringLiteral(
"/"),
147 if (parts.count() > 2) {
151 const QString alphaArgument = (parts.count() == 2)
153 : QStringLiteral(
"none");
154 auto result = parts.
value(0).simplified().split(QStringLiteral(
" "));
155 result.
append(alphaArgument);
156 if (result.
count() != count) {
160 return validateArguments(result);
175std::optional<double> CssColor::parseArgumentPercentNumberNone(
const QString &argument,
const double full,
const double none)
179 if (cleanArgument.
contains(QStringLiteral(
" "))
180 || cleanArgument.
contains(QStringLiteral(
","))
181 || cleanArgument.
contains(QStringLiteral(
"/"))
185 std::optional<double> result;
186 if (cleanArgument == QStringLiteral(
"none")) {
188 }
else if (cleanArgument.
endsWith(QStringLiteral(
"%"))) {
190 result = cleanArgument.
toDouble(&okay) / 100. * full;
192 result = cleanArgument.
toDouble(&okay);
211std::optional<double> CssColor::parseArgumentPercentNoneTo1(
const QString &argument)
215 if (cleanArgument.
contains(QStringLiteral(
" "))
216 || cleanArgument.
contains(QStringLiteral(
","))
217 || cleanArgument.
contains(QStringLiteral(
"/"))
221 if (cleanArgument == QStringLiteral(
"none")) {
224 if (!cleanArgument.
endsWith(QStringLiteral(
"%"))) {
228 const auto result = cleanArgument.
toDouble(&okay) / 100.;
246std::optional<double> CssColor::parseArgumentHueNoneTo360(
const QString &argument)
250 if (cleanArgument.
contains(QStringLiteral(
" "))
251 || cleanArgument.
contains(QStringLiteral(
","))
252 || cleanArgument.
contains(QStringLiteral(
"/"))
256 if (cleanArgument == QStringLiteral(
"none")) {
259 double correctionFactor = 1;
261 if (cleanArgument.
endsWith(QStringLiteral(
"deg"))) {
264 if (cleanArgument.
endsWith(QStringLiteral(
"grad"))) {
266 correctionFactor = 360. / 400.;
268 if (cleanArgument.
endsWith(QStringLiteral(
"rad"))) {
270 correctionFactor = 360. / (2 * pi);
272 if (cleanArgument.
endsWith(QStringLiteral(
"turn"))) {
274 correctionFactor = 360.;
277 const auto result = cleanArgument.
toDouble(&okay);
279 return normalizedAngle360(result * correctionFactor);
292CssColor::CssColorValue CssColor::parseAbsoluteColorFunction(
const QString &colorFunction)
295 QStringLiteral(
"^(\\w+)\\s*\\((.*)\\)$"));
298 const QString argumentsString =
match.captured(2).simplified();
299 std::optional<QStringList> maybeArguments;
301 if (ident == QStringLiteral(
"rgb")
302 || ident == QStringLiteral(
"hsl")) {
303 maybeArguments = parseAllFunctionArguments(
305 FunctionSyntax::BothSyntaxes,
308 if (ident == QStringLiteral(
"rgba")
309 || ident == QStringLiteral(
"hsla")) {
310 maybeArguments = parseAllFunctionArguments(
312 FunctionSyntax::LegacySyntax,
315 if (ident == QStringLiteral(
"hwb")
316 || ident == QStringLiteral(
"lch")
317 || ident == QStringLiteral(
"lab")
318 || ident == QStringLiteral(
"oklch")
319 || ident == QStringLiteral(
"oklab")) {
320 maybeArguments = parseAllFunctionArguments(
322 FunctionSyntax::StandardSyntax,
325 if (ident == QStringLiteral(
"color")) {
326 const auto colorArguments = parseAllFunctionArguments(
328 FunctionSyntax::StandardSyntax,
330 if (!colorArguments.has_value()) {
331 return CssColorValue();
333 ident = colorArguments.value().value(0);
334 maybeArguments = colorArguments.value().
mid(1);
336 if (!maybeArguments.has_value()) {
337 return CssColorValue();
339 const auto arguments = maybeArguments.value();
344 CssPredefinedRgbColorSpace rgbColorSpace =
345 CssPredefinedRgbColorSpace::Invalid;
347 using Pair = std::pair<QString, CssPredefinedRgbColorSpace>;
350 Pair(QStringLiteral(
"srgb"), CssPredefinedRgbColorSpace::Srgb),
351 Pair(QStringLiteral(
"srgb-linear"), CssPredefinedRgbColorSpace::SrgbLinear),
352 Pair(QStringLiteral(
"display-p3"), CssPredefinedRgbColorSpace::DisplayP3),
353 Pair(QStringLiteral(
"a98-rgb"), CssPredefinedRgbColorSpace::A98Rgb),
354 Pair(QStringLiteral(
"prophoto-rgb"), CssPredefinedRgbColorSpace::ProphotoRgb),
355 Pair(QStringLiteral(
"rec2020"), CssPredefinedRgbColorSpace::Rec2020)
358 if (ident == QStringLiteral(
"rgb")
359 || ident == QStringLiteral(
"rgba")
360 || hash.contains(ident)) {
362 rgbColorSpace = hash.value(
364 CssPredefinedRgbColorSpace::Srgb);
365 const double full = (hash.contains(ident))
368 for (
int i = 0; i < 3; ++i) {
369 const auto absValue =
370 parseArgumentPercentNumberNone(arguments.value(i), full, 0);
371 if (absValue.has_value()) {
372 list1 += absValue.
value() / full;
377 if (ident == QStringLiteral(
"xyz-d50")
378 || ident == QStringLiteral(
"xyz-d65")
379 || ident == QStringLiteral(
"xyz")) {
380 model = (ident == QStringLiteral(
"xyz-d50"))
383 rgbColorSpace = CssPredefinedRgbColorSpace::Invalid;
384 for (
int i = 0; i < 3; ++i) {
385 const auto absValue =
386 parseArgumentPercentNumberNone(arguments.value(i), 1, 0);
387 if (absValue.has_value()) {
388 list1 += absValue.
value();
393 if (ident == QStringLiteral(
"hsl")
394 || ident == QStringLiteral(
"hsla")
395 || ident == QStringLiteral(
"hwb")) {
396 model = (ident == QStringLiteral(
"hwb"))
399 rgbColorSpace = CssPredefinedRgbColorSpace::Srgb;
400 const auto maybeHue = parseArgumentHueNoneTo360(arguments.value(0));
401 if (maybeHue.has_value()) {
402 list1 += maybeHue.
value();
404 for (
int i = 1; i < 3; ++i) {
405 const auto absValue =
406 parseArgumentPercentNoneTo1(arguments.value(i));
407 if (absValue.has_value()) {
408 list1 += absValue.
value();
413 if (ident == QStringLiteral(
"oklab")
414 || ident == QStringLiteral(
"lab")) {
415 model = (ident == QStringLiteral(
"oklab"))
418 rgbColorSpace = CssPredefinedRgbColorSpace::Invalid;
419 std::array<double, 3> full = (ident == QStringLiteral(
"oklab"))
420 ? std::array<double, 3>{{1, 0.4, 0.4}}
421 : std::array<double, 3>{{100, 125, 125}};
422 for (quint8 i = 0; i < 3; ++i) {
423 const auto absValue = parseArgumentPercentNumberNone(
427 if (absValue.has_value()) {
428 list1 += absValue.
value();
433 if (ident == QStringLiteral(
"oklch")
434 || ident == QStringLiteral(
"lch")) {
435 model = (ident == QStringLiteral(
"oklch"))
438 rgbColorSpace = CssPredefinedRgbColorSpace::Invalid;
439 std::array<double, 2> full = (ident == QStringLiteral(
"oklch"))
440 ? std::array<double, 2>{{1, 0.4}}
441 : std::array<double, 2>{{100, 150}};
442 for (quint8 i = 0; i < 2; ++i) {
443 const auto absValue = parseArgumentPercentNumberNone(
447 if (absValue.has_value()) {
448 list1 += absValue.
value();
451 const auto maybeHue = parseArgumentHueNoneTo360(arguments.value(2));
452 if (maybeHue.has_value()) {
453 list1 += maybeHue.
value();
457 if (list1.
count() != 3) {
459 return CssColorValue();
462 const auto opacity1 =
463 parseArgumentPercentNumberNone(arguments.value(3), 1, 1);
465 if (!opacity1.has_value()) {
466 return CssColorValue();
468 CssColorValue result;
469 result.model = model;
470 result.rgbColorSpace = rgbColorSpace;
471 result.color = GenericColor
473 result.alpha1 = opacity1.value();
497CssColor::CssColorValue CssColor::parse(
const QString &
string)
499 auto myString =
string.simplified();
500 if (myString.endsWith(QStringLiteral(
";"))) {
502 myString = myString.simplified();
505 std::optional<QRgb> srgb = parseNamedColor(myString);
506 if (!srgb.has_value()) {
507 srgb = parseHexColor(myString);
509 if (srgb.has_value()) {
510 const auto srgbValue = srgb.value();
511 CssColorValue result;
513 result.rgbColorSpace = CssPredefinedRgbColorSpace::Srgb;
514 result.color = GenericColor{qRed(srgbValue) / 255.,
515 qGreen(srgbValue) / 255.,
516 qBlue(srgbValue) / 255.};
517 result.alpha1 = qAlpha(srgbValue) / 255.;
521 return parseAbsoluteColorFunction(myString);
538std::optional<QRgb> CssColor::parseNamedColor(
const QString &namedColor)
540 using NamedColor = std::pair<QString, QRgb>;
544 NamedColor(QStringLiteral(
"transparent"), 0x00000000),
546 NamedColor(QStringLiteral(
"aliceblue"), 0xfff0f8ff),
547 NamedColor(QStringLiteral(
"antiquewhite"), 0xfffaebd7),
548 NamedColor(QStringLiteral(
"aqua"), 0xff00ffff),
549 NamedColor(QStringLiteral(
"aquamarine"), 0xff7fffd4),
550 NamedColor(QStringLiteral(
"azure"), 0xfff0ffff),
551 NamedColor(QStringLiteral(
"beige"), 0xfff5f5dc),
552 NamedColor(QStringLiteral(
"bisque"), 0xffffe4c4),
553 NamedColor(QStringLiteral(
"black"), 0xff000000),
554 NamedColor(QStringLiteral(
"blanchedalmond"), 0xffffebcd),
555 NamedColor(QStringLiteral(
"blue"), 0xff0000ff),
556 NamedColor(QStringLiteral(
"blueviolet"), 0xff8a2be2),
557 NamedColor(QStringLiteral(
"brown"), 0xffa52a2a),
558 NamedColor(QStringLiteral(
"burlywood"), 0xffdeb887),
559 NamedColor(QStringLiteral(
"cadetblue"), 0xff5f9ea0),
560 NamedColor(QStringLiteral(
"chartreuse"), 0xff7fff00),
561 NamedColor(QStringLiteral(
"chocolate"), 0xffd2691e),
562 NamedColor(QStringLiteral(
"coral"), 0xffff7f50),
563 NamedColor(QStringLiteral(
"cornflowerblue"), 0xff6495ed),
564 NamedColor(QStringLiteral(
"cornsilk"), 0xfffff8dc),
565 NamedColor(QStringLiteral(
"crimson"), 0xffdc143c),
566 NamedColor(QStringLiteral(
"cyan"), 0xff00ffff),
567 NamedColor(QStringLiteral(
"darkblue"), 0xff00008b),
568 NamedColor(QStringLiteral(
"darkcyan"), 0xff008b8b),
569 NamedColor(QStringLiteral(
"darkgoldenrod"), 0xffb8860b),
570 NamedColor(QStringLiteral(
"darkgray"), 0xffa9a9a9),
571 NamedColor(QStringLiteral(
"darkgreen"), 0xff006400),
572 NamedColor(QStringLiteral(
"darkgrey"), 0xffa9a9a9),
573 NamedColor(QStringLiteral(
"darkkhaki"), 0xffbdb76b),
574 NamedColor(QStringLiteral(
"darkmagenta"), 0xff8b008b),
575 NamedColor(QStringLiteral(
"darkolivegreen"), 0xff556b2f),
576 NamedColor(QStringLiteral(
"darkorange"), 0xffff8c00),
577 NamedColor(QStringLiteral(
"darkorchid"), 0xff9932cc),
578 NamedColor(QStringLiteral(
"darkred"), 0xff8b0000),
579 NamedColor(QStringLiteral(
"darksalmon"), 0xffe9967a),
580 NamedColor(QStringLiteral(
"darkseagreen"), 0xff8fbc8f),
581 NamedColor(QStringLiteral(
"darkslateblue"), 0xff483d8b),
582 NamedColor(QStringLiteral(
"darkslategray"), 0xff2f4f4f),
583 NamedColor(QStringLiteral(
"darkslategrey"), 0xff2f4f4f),
584 NamedColor(QStringLiteral(
"darkturquoise"), 0xff00ced1),
585 NamedColor(QStringLiteral(
"darkviolet"), 0xff9400d3),
586 NamedColor(QStringLiteral(
"deeppink"), 0xffff1493),
587 NamedColor(QStringLiteral(
"deepskyblue"), 0xff00bfff),
588 NamedColor(QStringLiteral(
"dimgray"), 0xff696969),
589 NamedColor(QStringLiteral(
"dimgrey"), 0xff696969),
590 NamedColor(QStringLiteral(
"dodgerblue"), 0xff1e90ff),
591 NamedColor(QStringLiteral(
"firebrick"), 0xffb22222),
592 NamedColor(QStringLiteral(
"floralwhite"), 0xfffffaf0),
593 NamedColor(QStringLiteral(
"forestgreen"), 0xff228b22),
594 NamedColor(QStringLiteral(
"fuchsia"), 0xffff00ff),
595 NamedColor(QStringLiteral(
"gainsboro"), 0xffdcdcdc),
596 NamedColor(QStringLiteral(
"ghostwhite"), 0xfff8f8ff),
597 NamedColor(QStringLiteral(
"gold"), 0xffffd700),
598 NamedColor(QStringLiteral(
"goldenrod"), 0xffdaa520),
599 NamedColor(QStringLiteral(
"gray"), 0xff808080),
600 NamedColor(QStringLiteral(
"green"), 0xff008000),
601 NamedColor(QStringLiteral(
"greenyellow"), 0xffadff2f),
602 NamedColor(QStringLiteral(
"grey"), 0xff808080),
603 NamedColor(QStringLiteral(
"honeydew"), 0xfff0fff0),
604 NamedColor(QStringLiteral(
"hotpink"), 0xffff69b4),
605 NamedColor(QStringLiteral(
"indianred"), 0xffcd5c5c),
606 NamedColor(QStringLiteral(
"indigo"), 0xff4b0082),
607 NamedColor(QStringLiteral(
"ivory"), 0xfffffff0),
608 NamedColor(QStringLiteral(
"khaki"), 0xfff0e68c),
609 NamedColor(QStringLiteral(
"lavender"), 0xffe6e6fa),
610 NamedColor(QStringLiteral(
"lavenderblush"), 0xfffff0f5),
611 NamedColor(QStringLiteral(
"lawngreen"), 0xff7cfc00),
612 NamedColor(QStringLiteral(
"lemonchiffon"), 0xfffffacd),
613 NamedColor(QStringLiteral(
"lightblue"), 0xffadd8e6),
614 NamedColor(QStringLiteral(
"lightcoral"), 0xfff08080),
615 NamedColor(QStringLiteral(
"lightcyan"), 0xffe0ffff),
616 NamedColor(QStringLiteral(
"lightgoldenrodyellow"), 0xfffafad2),
617 NamedColor(QStringLiteral(
"lightgray"), 0xffd3d3d3),
618 NamedColor(QStringLiteral(
"lightgreen"), 0xff90ee90),
619 NamedColor(QStringLiteral(
"lightgrey"), 0xffd3d3d3),
620 NamedColor(QStringLiteral(
"lightpink"), 0xffffb6c1),
621 NamedColor(QStringLiteral(
"lightsalmon"), 0xffffa07a),
622 NamedColor(QStringLiteral(
"lightseagreen"), 0xff20b2aa),
623 NamedColor(QStringLiteral(
"lightskyblue"), 0xff87cefa),
624 NamedColor(QStringLiteral(
"lightslategray"), 0xff778899),
625 NamedColor(QStringLiteral(
"lightslategrey"), 0xff778899),
626 NamedColor(QStringLiteral(
"lightsteelblue"), 0xffb0c4de),
627 NamedColor(QStringLiteral(
"lightyellow"), 0xffffffe0),
628 NamedColor(QStringLiteral(
"lime"), 0xff00ff00),
629 NamedColor(QStringLiteral(
"limegreen"), 0xff32cd32),
630 NamedColor(QStringLiteral(
"linen"), 0xfffaf0e6),
631 NamedColor(QStringLiteral(
"magenta"), 0xffff00ff),
632 NamedColor(QStringLiteral(
"maroon"), 0xff800000),
633 NamedColor(QStringLiteral(
"mediumaquamarine"), 0xff66cdaa),
634 NamedColor(QStringLiteral(
"mediumblue"), 0xff0000cd),
635 NamedColor(QStringLiteral(
"mediumorchid"), 0xffba55d3),
636 NamedColor(QStringLiteral(
"mediumpurple"), 0xff9370db),
637 NamedColor(QStringLiteral(
"mediumseagreen"), 0xff3cb371),
638 NamedColor(QStringLiteral(
"mediumslateblue"), 0xff7b68ee),
639 NamedColor(QStringLiteral(
"mediumspringgreen"), 0xff00fa9a),
640 NamedColor(QStringLiteral(
"mediumturquoise"), 0xff48d1cc),
641 NamedColor(QStringLiteral(
"mediumvioletred"), 0xffc71585),
642 NamedColor(QStringLiteral(
"midnightblue"), 0xff191970),
643 NamedColor(QStringLiteral(
"mintcream"), 0xfff5fffa),
644 NamedColor(QStringLiteral(
"mistyrose"), 0xffffe4e1),
645 NamedColor(QStringLiteral(
"moccasin"), 0xffffe4b5),
646 NamedColor(QStringLiteral(
"navajowhite"), 0xffffdead),
647 NamedColor(QStringLiteral(
"navy"), 0xff000080),
648 NamedColor(QStringLiteral(
"oldlace"), 0xfffdf5e6),
649 NamedColor(QStringLiteral(
"olive"), 0xff808000),
650 NamedColor(QStringLiteral(
"olivedrab"), 0xff6b8e23),
651 NamedColor(QStringLiteral(
"orange"), 0xffffa500),
652 NamedColor(QStringLiteral(
"orangered"), 0xffff4500),
653 NamedColor(QStringLiteral(
"orchid"), 0xffda70d6),
654 NamedColor(QStringLiteral(
"palegoldenrod"), 0xffeee8aa),
655 NamedColor(QStringLiteral(
"palegreen"), 0xff98fb98),
656 NamedColor(QStringLiteral(
"paleturquoise"), 0xffafeeee),
657 NamedColor(QStringLiteral(
"palevioletred"), 0xffdb7093),
658 NamedColor(QStringLiteral(
"papayawhip"), 0xffffefd5),
659 NamedColor(QStringLiteral(
"peachpuff"), 0xffffdab9),
660 NamedColor(QStringLiteral(
"peru"), 0xffcd853f),
661 NamedColor(QStringLiteral(
"pink"), 0xffffc0cb),
662 NamedColor(QStringLiteral(
"plum"), 0xffdda0dd),
663 NamedColor(QStringLiteral(
"powderblue"), 0xffb0e0e6),
664 NamedColor(QStringLiteral(
"purple"), 0xff800080),
665 NamedColor(QStringLiteral(
"rebeccapurple"), 0xff663399),
666 NamedColor(QStringLiteral(
"red"), 0xffff0000),
667 NamedColor(QStringLiteral(
"rosybrown"), 0xffbc8f8f),
668 NamedColor(QStringLiteral(
"royalblue"), 0xff4169e1),
669 NamedColor(QStringLiteral(
"saddlebrown"), 0xff8b4513),
670 NamedColor(QStringLiteral(
"salmon"), 0xfffa8072),
671 NamedColor(QStringLiteral(
"sandybrown"), 0xfff4a460),
672 NamedColor(QStringLiteral(
"seagreen"), 0xff2e8b57),
673 NamedColor(QStringLiteral(
"seashell"), 0xfffff5ee),
674 NamedColor(QStringLiteral(
"sienna"), 0xffa0522d),
675 NamedColor(QStringLiteral(
"silver"), 0xffc0c0c0),
676 NamedColor(QStringLiteral(
"skyblue"), 0xff87ceeb),
677 NamedColor(QStringLiteral(
"slateblue"), 0xff6a5acd),
678 NamedColor(QStringLiteral(
"slategray"), 0xff708090),
679 NamedColor(QStringLiteral(
"slategrey"), 0xff708090),
680 NamedColor(QStringLiteral(
"snow"), 0xfffffafa),
681 NamedColor(QStringLiteral(
"springgreen"), 0xff00ff7f),
682 NamedColor(QStringLiteral(
"steelblue"), 0xff4682b4),
683 NamedColor(QStringLiteral(
"tan"), 0xffd2b48c),
684 NamedColor(QStringLiteral(
"teal"), 0xff008080),
685 NamedColor(QStringLiteral(
"thistle"), 0xffd8bfd8),
686 NamedColor(QStringLiteral(
"tomato"), 0xffff6347),
687 NamedColor(QStringLiteral(
"turquoise"), 0xff40e0d0),
688 NamedColor(QStringLiteral(
"violet"), 0xffee82ee),
689 NamedColor(QStringLiteral(
"wheat"), 0xfff5deb3),
690 NamedColor(QStringLiteral(
"white"), 0xffffffff),
691 NamedColor(QStringLiteral(
"whitesmoke"), 0xfff5f5f5),
692 NamedColor(QStringLiteral(
"yellow"), 0xffffff00),
693 NamedColor(QStringLiteral(
"yellowgreen"), 0xff9acd32)
697 if (colorList.contains(lowerCase)) {
698 return colorList.value(lowerCase);
732 const auto decimals100 =
decimalPlaces(100, significantFigures);
733 const auto decimals255 =
decimalPlaces(255, significantFigures);
734 const auto decimals360 =
decimalPlaces(360, significantFigures);
736 const QString opacity1String = (opacity1 < 1)
737 ? QStringLiteral(
" / %1%").
arg(opacity1 * 100, 0,
'f', decimals100)
742 result.
append(QStringLiteral(
"oklch(%1 %2 %3%4)")
743 .arg(temp.first, 0,
'f', decimals1)
744 .arg(temp.second, 0,
'f', decimals2)
745 .arg(temp.third, 0,
'f', decimals360)
746 .arg(opacity1String));
751 result.
append(QStringLiteral(
"oklab(%1 %2 %3%4)")
752 .arg(temp.first, 0,
'f', decimals1)
753 .arg(temp.second, 0,
'f', decimals2)
754 .arg(temp.third, 0,
'f', decimals2)
755 .arg(opacity1String));
760 result.
append(QStringLiteral(
"lch(%1 %2 %3%4)")
761 .arg(temp.first, 0,
'f', decimals100)
762 .arg(temp.second, 0,
'f', decimals255)
763 .arg(temp.third, 0,
'f', decimals360)
764 .arg(opacity1String));
769 result.
append(QStringLiteral(
"lab(%1 %2 %3%4)")
770 .arg(temp.first, 0,
'f', decimals100)
771 .arg(temp.second, 0,
'f', decimals255)
772 .arg(temp.third, 0,
'f', decimals255)
773 .arg(opacity1String));
778 result.
append(QStringLiteral(
"color (xyz-d50 %1 %2 %3%4)")
779 .arg(temp.first, 0,
'f', decimals1)
780 .arg(temp.second, 0,
'f', decimals1)
781 .arg(temp.third, 0,
'f', decimals1)
782 .arg(opacity1String));
787 result.
append(QStringLiteral(
"color (xyz-d65 %1 %2 %3%4)")
788 .arg(temp.first, 0,
'f', decimals1)
789 .arg(temp.second, 0,
'f', decimals1)
790 .arg(temp.third, 0,
'f', decimals1)
791 .arg(opacity1String));
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
The namespace of this library.
int decimalPlaces(const int rangeMax, const int significantFigures)
Calculates the required number of decimals to achieve the requested number of significant figures wit...
@ OklabD65
The Oklab color space, which by definition always and exclusively uses a D65 illuminant.
@ XyzD50
The Xyz color space using a D50 illuminant.
@ CielabD50
The Cielab color space using a D50 illuminant.
@ OklchD65
The Oklch color space, which by definition always and exclusively uses a D65 illuminant.
@ Hsl360_1_1
Some color space using the HSL color model.
@ Invalid
Represents invalid data.
@ XyzD65
The Xzy color space using a D65 illuminant.
@ Rgb1
Some color space using the Rgb color model.
@ CielchD50
The Cielch color space using a D50 illuminant.
@ Hwb360_1_1
Some color space using the HWB color model.
bool contains(const Key &key) const const
T value(const Key &key) const const
void append(QList< T > &&value)
qsizetype count() const const
void reserve(qsizetype size)
T value(qsizetype i) const const
qsizetype count() const const
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString simplified() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
double toDouble(bool *ok) const const
QString toLower() const const
void truncate(qsizetype position)