Inkscape
Vector Graphics Editor
|
A set of useful color modifying functions which do not fit as generic methods on the color class itself but which are used in various places. More...
Namespaces | |
namespace | CMS |
namespace | Space |
Classes | |
class | Color |
class | ColorError |
class | ColorSet |
class | CssColorPrinter |
class | CssFuncPrinter |
class | CssLegacyPrinter |
class | CssParser |
class | CssPrinter |
class | DocumentCMS |
class | HexParser |
class | HueParser |
class | IccColorPrinter |
class | LegacyParser |
class | Manager |
struct | NoColor |
class | Parser |
class | Parsers |
Typedefs | |
using | IdColors = std::vector< std::pair< std::string, Color > > |
using | Paint = std::variant< NoColor, Color > |
Enumerations | |
enum class | RenderingIntent { UNKNOWN = 0 , AUTO = 1 , PERCEPTUAL = 2 , RELATIVE_COLORIMETRIC = 3 , SATURATION = 4 , ABSOLUTE_COLORIMETRIC = 5 , RELATIVE_COLORIMETRIC_NOBPC = 6 } |
Functions | |
std::vector< char > | getMIMEData (Paint const &paint, char const *mime_type) |
Convert a paint into a draggable object. | |
Paint | fromMIMEData (std::span< char const > data, char const *mime_type) |
Convert a dropped object into a color, if possible. | |
Color | to_gamut_css (const Color &origin, const std::shared_ptr< Space::AnySpace > &space) |
Given a color origin , returns a new color that is in gamut using the CSS Gamut Mapping Algorithm. | |
bool | out_of_gamut (const Color &color, const std::shared_ptr< Space::AnySpace > &space, double eps) |
uint32_t | hex_to_rgba (std::string const &value) |
Parse a color directly without any CSS or CMS support. | |
std::vector< double > | rgba_to_values (uint32_t rgba, bool opacity) |
Convert a 32bit unsigned int into a set of 3 or 4 double values for rgba. | |
std::string | rgba_to_hex (uint32_t value, bool alpha) |
Output the RGBA value as a #RRGGBB hex color, if alpha is true then the output will be #RRGGBBAA instead. | |
std::string | color_to_id (std::optional< Color > const &color) |
Create a somewhat unique id for the given color used for palette identification. | |
std::string | desc_to_id (std::string const &desc) |
Transform a color name or description into an id used for palette identification. | |
Color | make_contrasted_color (Color const &orig, double amount) |
Make a darker or lighter version of the color, useful for making checkerboards. | |
Color | make_theme_color (Color const &orig, bool dark) |
Make a themed dark or light color based on a previous shade, returns RGB color. | |
double | perceptual_lightness (double l) |
double | get_perceptual_lightness (Color const &color) |
Return a value for how the light the color appears to be using HSLUV. | |
std::pair< double, double > | get_contrasting_color (double l) |
double | lightness (Color color) |
std::string | paint_to_xml_string (Paint const &paint) |
Turn a color into a color xml document, used for drag and drop. | |
Paint | xml_string_to_paint (std::string const &xmls, SPDocument *doc) |
Parse an xml document into a color. | |
XML::Document * | paint_to_xml (Paint const &paint) |
Paint | xml_to_paint (XML::Document const *xml, SPDocument *doc) |
std::size_t | hash_value (Color const &b) |
Variables | |
constexpr auto | mimeOSWB_COLOR = "application/x-oswb-color" |
constexpr auto | mimeX_COLOR = "application/x-color" |
constexpr auto | mimeTEXT = "text/plain" |
static std::map< RenderingIntent, std::string > | intentIds |
const auto | oklab_space = Manager::get().find(Space::Type::OKLAB) |
const auto | oklch_space = Manager::get().find(Space::Type::OKLCH) |
const Color | COLORS_WHITE = Color(0xffffffff, false) |
const Color | COLORS_BLACK = Color(0x000000ff, false) |
A set of useful color modifying functions which do not fit as generic methods on the color class itself but which are used in various places.
using Inkscape::Colors::IdColors = typedef std::vector<std::pair<std::string, Color> > |
Definition at line 27 of file color-set.h.
using Inkscape::Colors::Paint = typedef std::variant<NoColor, Color> |
Definition at line 32 of file xml-color.h.
|
strong |
std::string Inkscape::Colors::color_to_id | ( | std::optional< Color > const & | color | ) |
Create a somewhat unique id for the given color used for palette identification.
Definition at line 81 of file utils.cpp.
References desc_to_id(), and name.
Referenced by Inkscape::UI::Dialog::ColorItem::ColorItem().
std::string Inkscape::Colors::desc_to_id | ( | std::string const & | desc | ) |
Transform a color name or description into an id used for palette identification.
Definition at line 115 of file utils.cpp.
References name.
Referenced by color_to_id().
Paint Inkscape::Colors::fromMIMEData | ( | std::span< char const > | data, |
char const * | mime_type | ||
) |
Convert a dropped object into a color, if possible.
Definition at line 59 of file dragndrop.cpp.
References data, mimeOSWB_COLOR, mimeTEXT, mimeX_COLOR, Inkscape::Colors::Color::size(), SP_RGBA32_U_COMPOSE(), and xml_string_to_paint().
std::pair< double, double > Inkscape::Colors::get_contrasting_color | ( | double | l | ) |
Definition at line 179 of file utils.cpp.
Referenced by Inkscape::UI::Dialog::ColorItem::draw_func(), Inkscape::UI::Widget::ColorWheelHSLuv::on_drawing_area_draw(), and Inkscape::UI::Widget::OKWheel::on_drawing_area_draw().
double Inkscape::Colors::get_perceptual_lightness | ( | Color const & | color | ) |
Return a value for how the light the color appears to be using HSLUV.
Definition at line 174 of file utils.cpp.
References Inkscape::Colors::Color::converted(), Inkscape::Colors::Space::HSLUV, and perceptual_lightness().
Referenced by Inkscape::CanvasPage::_updateTextItem(), Inkscape::UI::Dialog::ColorItem::draw_func(), and Inkscape::BooleanBuilder::redraw_items().
std::vector< char > Inkscape::Colors::getMIMEData | ( | Paint const & | paint, |
char const * | mime_type | ||
) |
Convert a paint into a draggable object.
Definition at line 24 of file dragndrop.cpp.
References mimeOSWB_COLOR, mimeTEXT, mimeX_COLOR, paint_to_xml_string(), rgb, SP_RGBA32_A_U(), SP_RGBA32_B_U(), SP_RGBA32_G_U(), and SP_RGBA32_R_U().
std::size_t Inkscape::Colors::hash_value | ( | Color const & | b | ) |
Definition at line 41 of file swatches.cpp.
References Inkscape::Colors::Color::toRGBA().
uint32_t Inkscape::Colors::hex_to_rgba | ( | std::string const & | value | ) |
Parse a color directly without any CSS or CMS support.
This function is ONLY intended to parse values stored in inkscape specific screen-attributes and preferences.
DO NOT use this as a common color parser, it does not support any other format other than RRGGBBAA and anything else will cause an error.
Definition at line 32 of file utils.cpp.
Referenced by css_color_to_gdk().
double Inkscape::Colors::lightness | ( | Color | color | ) |
Make a darker or lighter version of the color, useful for making checkerboards.
Definition at line 134 of file utils.cpp.
References Inkscape::Colors::Space::HSL, lightness(), orig, and Inkscape::Colors::Color::set().
Referenced by Inkscape::UI::Widget::checkerboard_darken(), and ink_cairo_pattern_create_checkerboard().
Make a themed dark or light color based on a previous shade, returns RGB color.
Definition at line 148 of file utils.cpp.
References Inkscape::Colors::Space::HSLUV, orig, and Inkscape::Colors::Space::RGB.
bool Inkscape::Colors::out_of_gamut | ( | const Color & | color, |
const std::shared_ptr< Space::AnySpace > & | space, | ||
double | eps | ||
) |
Definition at line 142 of file gamut.cpp.
References Inkscape::Colors::Color::converted(), Inkscape::Colors::Color::getSpace(), and Inkscape::Colors::Color::getValues().
Referenced by Inkscape::Colors::Space::AnySpace::isOutOfGamut(), and to_gamut_css().
XML::Document * Inkscape::Colors::paint_to_xml | ( | Paint const & | paint | ) |
Definition at line 56 of file xml-color.cpp.
References Inkscape::XML::Node::appendChild(), node, Inkscape::GC::release(), root, Inkscape::XML::Node::setAttribute(), Inkscape::XML::Node::setAttributeCssDouble(), Inkscape::XML::Node::setAttributeOrRemoveIfEmpty(), and Inkscape::XML::Node::setAttributeSvgDouble().
Referenced by paint_to_xml_string().
std::string Inkscape::Colors::paint_to_xml_string | ( | Paint const & | paint | ) |
Turn a color into a color xml document, used for drag and drop.
Definition at line 34 of file xml-color.cpp.
References paint_to_xml(), Inkscape::GC::release(), and sp_repr_save_buf().
Referenced by getMIMEData().
double Inkscape::Colors::perceptual_lightness | ( | double | l | ) |
Definition at line 166 of file utils.cpp.
Referenced by get_perceptual_lightness(), and Inkscape::UI::Widget::ColorWheelHSLuv::on_drawing_area_draw().
std::string Inkscape::Colors::rgba_to_hex | ( | uint32_t | value, |
bool | alpha | ||
) |
Output the RGBA value as a #RRGGBB hex color, if alpha is true then the output will be #RRGGBBAA instead.
Definition at line 70 of file utils.cpp.
Referenced by Inkscape::UI::Tools::fit_item(), gdk_to_css_color(), Inkscape::UI::ThemeContext::get_symbolic_colors(), Inkscape::UI::Tools::MeasureTool::setLabelText(), Inkscape::UI::Tools::MeasureTool::setMeasureItem(), Inkscape::Colors::Space::CMS::toString(), Inkscape::Colors::Space::RGB::toString(), and Inkscape::Trace::Depixelize::DepixelizeTracingEngine::trace().
std::vector< double > Inkscape::Colors::rgba_to_values | ( | uint32_t | rgba, |
bool | opacity | ||
) |
Convert a 32bit unsigned int into a set of 3 or 4 double values for rgba.
Definition at line 54 of file utils.cpp.
References SP_RGBA32_A_F(), SP_RGBA32_B_F(), SP_RGBA32_G_F(), and SP_RGBA32_R_F().
Referenced by Inkscape::Colors::Color::set().
Color Inkscape::Colors::to_gamut_css | ( | const Color & | origin, |
const std::shared_ptr< Space::AnySpace > & | space | ||
) |
Given a color origin
, returns a new color that is in gamut using the CSS Gamut Mapping Algorithm.
If space
is specified, it will be in gamut in space
, and returned in space
. Otherwise, it will be in gamut and returned in the color space of origin
.
{ColorTypes} | origin |
{{ | space?: string | ColorSpace | undefined }} param1 |
Definition at line 66 of file gamut.cpp.
References clip(), COLORS_BLACK, COLORS_WHITE, Inkscape::Colors::Color::converted(), current, oklch_space, origin, and out_of_gamut().
Referenced by Inkscape::Colors::Space::AnySpace::toGamut().
Paint Inkscape::Colors::xml_string_to_paint | ( | std::string const & | xmls, |
SPDocument * | doc | ||
) |
Parse an xml document into a color.
Usually from a drag and drop.
Definition at line 48 of file xml-color.cpp.
References Inkscape::GC::release(), sp_repr_read_buf(), and xml_to_paint().
Referenced by fromMIMEData().
Paint Inkscape::Colors::xml_to_paint | ( | XML::Document const * | xml, |
SPDocument * | doc | ||
) |
Definition at line 102 of file xml-color.cpp.
References AUTO, Inkscape::Colors::Manager::find(), Inkscape::XML::Node::firstChild(), Inkscape::Colors::CMS::System::get(), Inkscape::Colors::Manager::get(), SPDocument::getDocumentCMS(), Inkscape::Colors::DocumentCMS::getSpace(), name, and node.
Referenced by xml_string_to_paint().
Definition at line 16 of file gamut.cpp.
Referenced by to_gamut_css().
Definition at line 15 of file gamut.cpp.
Referenced by to_gamut_css().
|
static |
Definition at line 34 of file enum.h.
Referenced by Inkscape::Colors::DocumentCMS::checkProfileName(), Inkscape::ColorProfile::createFromProfile(), Inkscape::Colors::Space::AnySpace::profileToProfile(), Inkscape::ColorProfile::set(), Inkscape::ColorProfile::setRenderingIntent(), and Inkscape::ColorProfile::write().
|
inlineconstexpr |
Definition at line 22 of file dragndrop.h.
Referenced by fromMIMEData(), and getMIMEData().
|
inlineconstexpr |
Definition at line 24 of file dragndrop.h.
Referenced by fromMIMEData(), and getMIMEData().
|
inlineconstexpr |
Definition at line 23 of file dragndrop.h.
Referenced by fromMIMEData(), and getMIMEData().
const auto Inkscape::Colors::oklab_space = Manager::get().find(Space::Type::OKLAB) |
const auto Inkscape::Colors::oklch_space = Manager::get().find(Space::Type::OKLCH) |
Definition at line 14 of file gamut.cpp.
Referenced by to_gamut_css().