Skip to content

Commit

Permalink
Update stroke_to call to account for linear sRGB
Browse files Browse the repository at this point in the history
Fixes the incorrect colors in issue #1069
Bumps libmypaint requirement to >= 1.6
  • Loading branch information
jplloyd committed Apr 29, 2020
1 parent ac20232 commit f15f4a8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/brush.hpp
Expand Up @@ -69,6 +69,12 @@ class Brush {
return mypaint_brush_stroke_to_2(c_brush, c_surface, x, y, pressure, xtilt, ytilt, dtime, viewzoom, viewrotation, barrel_rotation);
}

bool stroke_to_linear (Surface * surface, float x, float y, float pressure, float xtilt, float ytilt, double dtime, float viewzoom, float viewrotation, float barrel_rotation)
{
MyPaintSurface2 *c_surface = surface->get_surface2_interface();
return mypaint_brush_stroke_to_2_linearsRGB(c_brush, c_surface, x, y, pressure, xtilt, ytilt, dtime, viewzoom, viewrotation, barrel_rotation);
}

double get_total_stroke_painting_time()
{
return mypaint_brush_get_total_stroke_painting_time(c_brush);
Expand Down
11 changes: 11 additions & 0 deletions lib/brush.py
Expand Up @@ -638,6 +638,17 @@ def __init__(self, brushinfo):
brushinfo.observers.append(self._update_from_brushinfo)
self._update_from_brushinfo(ALL_SETTINGS)

def stroke_to(self, *args):
""" Delegates to mypaintlib with information about color space
Checks whether color transforms should be done in linear sRGB
so that HSV/HSL adjustments can be handled correctly.
"""
if eotf() == 1.0:
return super(Brush, self).stroke_to(*args)
else:
return super(Brush, self).stroke_to_linear(*args)

def _update_from_brushinfo(self, settings):
"""Updates changed low-level settings from the BrushInfo"""

Expand Down
9 changes: 9 additions & 0 deletions lib/python_brush.hpp
Expand Up @@ -56,4 +56,13 @@ class PythonBrush : public Brush {
return res;
}

bool stroke_to_linear (Surface * surface, float x, float y, float pressure, float xtilt, float ytilt, double dtime, float viewzoom, float viewrotation, float barrel_rotation)
{
bool res = Brush::stroke_to_linear (surface, x, y, pressure, xtilt, ytilt, dtime, viewzoom, viewrotation, barrel_rotation);
if (PyErr_Occurred()) {
res = false;
}
return res;
}

};

0 comments on commit f15f4a8

Please sign in to comment.