diff options
author | Karl Berry <karl@freefriends.org> | 2023-01-20 01:55:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-01-20 01:55:04 +0000 |
commit | 2c99129a39be3be6622c7efa6826222141d4de1e (patch) | |
tree | 95f4cdda555eef7f4e9a98994ce081e2364a8a4a /Build/source/texk/dvisvgm/dvisvgm-src/src/Opacity.cpp | |
parent | 5817f54a04657ab24f46489d2ddb97d47c3bef79 (diff) |
dvisvgm-3.0.1 + patches linked from https://github.com/TeX-Live/texlive-source/pull/59#issuecomment-1397666966
git-svn-id: svn://tug.org/texlive/trunk@65593 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/Opacity.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/src/Opacity.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Opacity.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Opacity.cpp index 058f794a863..027992028ba 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Opacity.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Opacity.cpp @@ -2,7 +2,7 @@ ** Opacity.cpp ** ** ** ** This file is part of dvisvgm -- a fast DVI to SVG converter ** -** Copyright (C) 2005-2022 Martin Gieseking <martin.gieseking@uos.de> ** +** Copyright (C) 2005-2023 Martin Gieseking <martin.gieseking@uos.de> ** ** ** ** This program is free software; you can redistribute it and/or ** ** modify it under the terms of the GNU General Public License as ** @@ -45,6 +45,50 @@ string Opacity::cssBlendMode (BlendMode bm) { } +static string to_lower_drop_nonalpha (const string &str) { + string ret; + if (!str.empty()) { + ret.reserve(str.length()); + for (char c : str) { + if (isalpha(c)) + ret += char(tolower(c)); + } + } + return ret; +} + + +Opacity::BlendMode Opacity::blendMode (const std::string &name) { + struct { + const char *name; + BlendMode mode; + } modes[] = { + {"normal", BM_NORMAL }, + {"multiply", BM_MULTIPLY }, + {"screen", BM_SCREEN }, + {"overlay", BM_OVERLAY }, + {"softlight", BM_SOFTLIGHT }, + {"hardlight", BM_HARDLIGHT }, + {"colordodge", BM_COLORDODGE}, + {"colorburn", BM_COLORBURN }, + {"darken", BM_DARKEN }, + {"lighten", BM_LIGHTEN }, + {"difference", BM_DIFFERENCE}, + {"exclusion", BM_EXCLUSION }, + {"hue", BM_HUE }, + {"saturation", BM_SATURATION}, + {"color", BM_COLOR }, + {"luminosity", BM_LUMINOSITY} + }; + string compname = to_lower_drop_nonalpha(name); + for (const auto &m : modes) { + if (compname == m.name) + return m.mode; + } + return BM_NORMAL; +} + + bool Opacity::operator == (const Opacity &opacity) const { return opacity._fillalpha == _fillalpha && opacity._strokealpha == _strokealpha @@ -56,4 +100,4 @@ bool Opacity::operator != (const Opacity &opacity) const { return opacity._fillalpha != _fillalpha || opacity._strokealpha != _strokealpha || opacity._blendMode != _blendMode; -}
\ No newline at end of file +} |