18#include <gtkmm/gestureclick.h>
34 bool ,
bool const emit)
61 double hue_angle_deg = 0.0;
64 hue_angle_deg += angle_step;
76 auto width = allocation.get_width();
77 auto height = allocation.get_height();
85 return disc_needs_redraw;
100 double saturation = point.
length();
101 if (saturation == 0.0) {
102 return Color(Space::Type::OKLCH, {
_values[
L], 0, 0}).toARGB();
103 }
else if (saturation > 1.0) {
114 unsigned const next_sample = (previous_sample ==
CHROMA_BOUND_SAMPLES - 1) ? 0 : previous_sample + 1;
116 double const angle_delta = hue_radians - previous_sample_angle;
119 double const absolute_chroma = chroma_bound_estimate * saturation;
121 return Color(Space::Type::OKLCH, {
_values[
L], absolute_chroma, Geom::deg_from_rad(hue_radians) / 360}).toARGB();
146 cr->set_antialias(Cairo::ANTIALIAS_SUBPIXEL);
154 cr->set_source(
_disc, 0, 0);
162 cr->arc(where.x(), where.y(),
HALO_RADIUS, 0.0, 2.0 * M_PI);
173 cr->set_source_rgba(gray, gray, gray, alpha);
185 double const radius = 0.5 *
size;
186 double const inverse_radius = 1.0 / radius;
189 _disc = Cairo::ImageSurface::create(Cairo::Surface::Format::RGB24,
size,
size);
193 uint32_t *pos =
reinterpret_cast<uint32_t *
>(
_disc->get_data());
196 for (
int y = 0; y <
size; y++) {
199 double const normalized_y = inverse_radius * (radius - y);
200 for (
int x = 0; x <
size; x++) {
201 *pos++ =
_discColor({inverse_radius * (x - radius), normalized_y});
255 int ,
double const x,
double const y)
257 if (click.get_current_button() == 1) {
261 return Gtk::EventSequenceState::CLAIMED;
265 return Gtk::EventSequenceState::NONE;
272 return Gtk::EventSequenceState::CLAIMED;
void ink_cairo_set_source_color(Cairo::RefPtr< Cairo::Context > &ctx, Colors::Color const &color, bool to_srgb)
Set the source color of the Cairo context.
Cairo integration helpers.
Wrapper for angular values.
static Angle from_degrees(Coord d)
Create an angle from its measure in degrees.
Coord radians0() const
Get the angle as positive radians.
Two-dimensional point that doubles as a vector.
Coord length() const
Compute the distance from origin.
bool set(unsigned int index, double value)
Set a specific channel in the color.
void normalize()
Make sure the values for this color are within acceptable ranges.
static double max_chroma(double l, double h)
constexpr Coord lerp(Coord t, Coord a, Coord b)
Numerically stable linear interpolation.
void sincos(double angle, double &sin_, double &cos_)
Simultaneously compute a sine and a cosine of the same angle.
double atan2(Point const &p)
A set of useful color modifying functions which do not fit as generic methods on the color class itse...
std::pair< double, double > get_contrasting_color(double l)