1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Alx Sa
5928898a48 Add pressure gain control 2023-08-04 10:43:44 -04:00
Alx Sa
e696a4d109 paint: Add support for MyPaint Brushes v2 2023-07-29 12:48:28 -04:00
12 changed files with 1088 additions and 216 deletions

View File

@@ -84,7 +84,7 @@ gimp_mybrush_load (GimpContext *context,
return NULL;
}
mypaint_brush = mypaint_brush_new ();
mypaint_brush = mypaint_brush_new_with_buckets (64);
mypaint_brush_from_defaults (mypaint_brush);
if (! mypaint_brush_from_string (mypaint_brush, (const gchar *) buffer))
@@ -147,6 +147,25 @@ gimp_mybrush_load (GimpContext *context,
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_OFFSET_BY_RANDOM);
brush->priv->gain =
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_PRESSURE_GAIN_LOG);
/* Version 2 MyPaint Brush options */
brush->priv->pigment =
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_PAINT_MODE);
if (brush->priv->pigment == 1.0f)
brush->priv->pigment = 0.0f;
brush->priv->posterize =
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_POSTERIZE);
brush->priv->posterize_num =
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_POSTERIZE_NUM);
mypaint_brush_unref (mypaint_brush);
return g_list_prepend (NULL, brush);

View File

@@ -27,6 +27,10 @@ struct _GimpMybrushPrivate
gdouble radius;
gdouble opaque;
gdouble hardness;
gdouble gain;
gdouble pigment;
gdouble posterize;
gdouble posterize_num;
gdouble offset_by_random;
gboolean eraser;
};

View File

@@ -98,10 +98,13 @@ gimp_mybrush_init (GimpMybrush *brush)
{
brush->priv = gimp_mybrush_get_instance_private (brush);
brush->priv->radius = 1.0;
brush->priv->opaque = 1.0;
brush->priv->hardness = 1.0;
brush->priv->eraser = FALSE;
brush->priv->radius = 1.0;
brush->priv->opaque = 1.0;
brush->priv->hardness = 1.0;
brush->priv->pigment = 0.0;
brush->priv->posterize = 0.0;
brush->priv->posterize_num = 1.0;
brush->priv->eraser = FALSE;
}
static void
@@ -254,6 +257,14 @@ gimp_mybrush_get_opaque (GimpMybrush *brush)
return brush->priv->opaque;
}
gdouble
gimp_mybrush_get_gain (GimpMybrush *brush)
{
g_return_val_if_fail (GIMP_IS_MYBRUSH (brush), 1.0);
return brush->priv->gain;
}
gdouble
gimp_mybrush_get_hardness (GimpMybrush *brush)
{
@@ -262,6 +273,30 @@ gimp_mybrush_get_hardness (GimpMybrush *brush)
return brush->priv->hardness;
}
gdouble
gimp_mybrush_get_pigment (GimpMybrush *brush)
{
g_return_val_if_fail (GIMP_IS_MYBRUSH (brush), 0.0);
return brush->priv->pigment;
}
gdouble
gimp_mybrush_get_posterize (GimpMybrush *brush)
{
g_return_val_if_fail (GIMP_IS_MYBRUSH (brush), 0.0);
return brush->priv->posterize;
}
gdouble
gimp_mybrush_get_posterize_num (GimpMybrush *brush)
{
g_return_val_if_fail (GIMP_IS_MYBRUSH (brush), 0.05);
return brush->priv->posterize_num;
}
gdouble
gimp_mybrush_get_offset_by_random (GimpMybrush *brush)
{

View File

@@ -58,7 +58,11 @@ const gchar * gimp_mybrush_get_brush_json (GimpMybrush *brush);
gdouble gimp_mybrush_get_radius (GimpMybrush *brush);
gdouble gimp_mybrush_get_opaque (GimpMybrush *brush);
gdouble gimp_mybrush_get_gain (GimpMybrush *brush);
gdouble gimp_mybrush_get_hardness (GimpMybrush *brush);
gdouble gimp_mybrush_get_pigment (GimpMybrush *brush);
gdouble gimp_mybrush_get_posterize (GimpMybrush *brush);
gdouble gimp_mybrush_get_posterize_num (GimpMybrush *brush);
gdouble gimp_mybrush_get_offset_by_random (GimpMybrush *brush);
gboolean gimp_mybrush_get_is_eraser (GimpMybrush *brush);

View File

@@ -80,7 +80,10 @@ static void gimp_mybrush_core_motion (GimpPaintCore *paint_core
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpSymmetry *sym,
guint32 time);
guint32 time,
gfloat view_zoom,
gfloat view_rotation,
gfloat barrel_rotation);
static void gimp_mybrush_core_create_brushes (GimpMybrushCore *mybrush,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
@@ -200,11 +203,12 @@ gimp_mybrush_core_paint (GimpPaintCore *paint_core,
GimpPaintState paint_state,
guint32 time)
{
GimpMybrushCore *mybrush = GIMP_MYBRUSH_CORE (paint_core);
GimpContext *context = GIMP_CONTEXT (paint_options);
gint offset_x;
gint offset_y;
GimpRGB fg;
GimpMybrushCore *mybrush = GIMP_MYBRUSH_CORE (paint_core);
GimpMybrushOptions *mybrush_options = GIMP_MYBRUSH_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
gint offset_x;
gint offset_y;
GimpRGB fg;
g_return_if_fail (g_list_length (drawables) == 1);
@@ -231,12 +235,14 @@ gimp_mybrush_core_paint (GimpPaintCore *paint_core,
case GIMP_PAINT_STATE_MOTION:
gimp_mybrush_core_motion (paint_core, drawables->data, paint_options,
sym, time);
sym, time, mybrush_options->view_zoom,
mybrush_options->view_rotation, 1.0f);
break;
case GIMP_PAINT_STATE_FINISH:
gimp_symmetry_set_stateful (sym, FALSE);
mypaint_surface_unref ((MyPaintSurface *) mybrush->private->surface);
mypaint_surface_unref (mypaint_surface2_to_surface (
(MyPaintSurface2 *) mybrush->private->surface));
mybrush->private->surface = NULL;
g_list_free_full (mybrush->private->brushes,
@@ -251,10 +257,14 @@ gimp_mybrush_core_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpSymmetry *sym,
guint32 time)
guint32 time,
gfloat view_zoom,
gfloat view_rotation,
gfloat barrel_rotation)
{
GimpMybrushCore *mybrush = GIMP_MYBRUSH_CORE (paint_core);
MyPaintRectangle rect;
MyPaintRectangles rects = {1, &rect};
GimpCoords coords;
GList *iter;
gdouble dt = 0.0;
@@ -278,7 +288,8 @@ gimp_mybrush_core_motion (GimpPaintCore *paint_core,
gimp_mybrush_core_create_brushes (mybrush, drawable, paint_options, sym);
}
mypaint_surface_begin_atomic ((MyPaintSurface *) mybrush->private->surface);
mypaint_surface_begin_atomic (mypaint_surface2_to_surface (
(MyPaintSurface2 *) mybrush->private->surface));
if (mybrush->private->last_time < 0)
{
@@ -291,14 +302,17 @@ gimp_mybrush_core_motion (GimpPaintCore *paint_core,
coords = *(gimp_symmetry_get_coords (sym, i));
mypaint_brush_stroke_to (brush,
(MyPaintSurface *) mybrush->private->surface,
coords.x,
coords.y,
0.0f,
coords.xtilt,
coords.ytilt,
1.0f /* Pretend the cursor hasn't moved in a while */);
mypaint_brush_stroke_to_2 (brush,
(MyPaintSurface2 *) mybrush->private->surface,
coords.x,
coords.y,
0.0f,
coords.xtilt,
coords.ytilt,
1.0f, /* Pretend the cursor hasn't moved in a while */
view_zoom,
view_rotation,
barrel_rotation);
}
dt = 0.015;
@@ -323,29 +337,36 @@ gimp_mybrush_core_motion (GimpPaintCore *paint_core,
GimpCoords coords = *(gimp_symmetry_get_coords (sym, i));
gdouble pressure = coords.pressure;
mypaint_brush_stroke_to (brush,
(MyPaintSurface *) mybrush->private->surface,
coords.x,
coords.y,
pressure,
coords.xtilt,
coords.ytilt,
dt);
mypaint_brush_stroke_to_2 (brush,
(MyPaintSurface2 *) mybrush->private->surface,
coords.x,
coords.y,
pressure,
coords.xtilt,
coords.ytilt,
dt,
view_zoom,
view_rotation,
barrel_rotation);
}
mybrush->private->last_time = time;
mypaint_surface_end_atomic ((MyPaintSurface *) mybrush->private->surface,
&rect);
mypaint_surface2_end_atomic ((MyPaintSurface2 *) mybrush->private->surface,
&rects);
if (rect.width > 0 && rect.height > 0)
if (rects.rectangles[0].width > 0 && rects.rectangles[0].height > 0)
{
paint_core->x1 = MIN (paint_core->x1, rect.x);
paint_core->y1 = MIN (paint_core->y1, rect.y);
paint_core->x2 = MAX (paint_core->x2, rect.x + rect.width);
paint_core->y2 = MAX (paint_core->y2, rect.y + rect.height);
paint_core->x1 = MIN (paint_core->x1, rects.rectangles[0].x);
paint_core->y1 = MIN (paint_core->y1, rects.rectangles[0].y);
paint_core->x2 = MAX (paint_core->x2,
rects.rectangles[0].x + rects.rectangles[0].width);
paint_core->y2 = MAX (paint_core->y2,
rects.rectangles[0].y + rects.rectangles[0].height);
gimp_drawable_update (drawable, rect.x, rect.y, rect.width, rect.height);
gimp_drawable_update (drawable, rects.rectangles[0].x,
rects.rectangles[0].y, rects.rectangles[0].width,
rects.rectangles[0].height);
}
}
@@ -382,7 +403,7 @@ gimp_mybrush_core_create_brushes (GimpMybrushCore *mybrush,
for (i = 0; i < n_strokes; i++)
{
MyPaintBrush *brush = mypaint_brush_new ();
MyPaintBrush *brush = mypaint_brush_new_with_buckets (64);
const gchar *brush_data;
mypaint_brush_from_defaults (brush);
@@ -419,6 +440,18 @@ gimp_mybrush_core_create_brushes (GimpMybrushCore *mybrush,
(options->eraser &&
gimp_drawable_has_alpha (drawable)) ?
1.0f : 0.0f);
mypaint_brush_set_base_value (brush,
MYPAINT_BRUSH_SETTING_PRESSURE_GAIN_LOG,
options->gain);
mypaint_brush_set_base_value (brush,
MYPAINT_BRUSH_SETTING_PAINT_MODE,
options->pigment);
mypaint_brush_set_base_value (brush,
MYPAINT_BRUSH_SETTING_POSTERIZE,
options->posterize);
mypaint_brush_set_base_value (brush,
MYPAINT_BRUSH_SETTING_POSTERIZE_NUM,
options->posterize_num);
mypaint_brush_new_stroke (brush);

View File

@@ -38,9 +38,15 @@
enum
{
PROP_0,
PROP_VIEW_ZOOM,
PROP_VIEW_ROTATION,
PROP_RADIUS,
PROP_OPAQUE,
PROP_GAIN,
PROP_HARDNESS,
PROP_PIGMENT,
PROP_POSTERIZE,
PROP_POSTERIZE_NUM,
PROP_ERASER,
PROP_NO_ERASING
};
@@ -82,6 +88,20 @@ gimp_mybrush_options_class_init (GimpMybrushOptionsClass *klass)
context_class->mybrush_changed = gimp_mybrush_options_mybrush_changed;
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_RADIUS,
"viewzoom",
_("View Zoom"),
NULL,
0.0001, G_MAXFLOAT, 1.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_RADIUS,
"viewrotation",
_("View Rotation"),
NULL,
0.0, 360.0, 0.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_RADIUS,
"radius",
_("Radius"),
@@ -103,6 +123,34 @@ gimp_mybrush_options_class_init (GimpMybrushOptionsClass *klass)
0.0, 1.0, 1.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_GAIN,
"gain",
_("Gain"),
_("Pressure gain"),
-1.8, 1.2, 0.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_PIGMENT,
"pigment",
_("Pigment"),
_("Enable spectral blending"),
0.0, 1.0, 0.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_POSTERIZE,
"posterize",
_("Posterize"),
NULL,
0.0, 1.0, 0.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_POSTERIZE_NUM,
"posterizenum",
_("Posterize Number"),
NULL,
0.0, 1.28, 1.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ERASER,
"eraser",
_("Erase with this brush"),
@@ -141,15 +189,34 @@ gimp_mybrush_options_set_property (GObject *object,
switch (property_id)
{
case PROP_VIEW_ZOOM:
options->view_zoom = g_value_get_double (value) > 0.0f ?
g_value_get_double (value) : 0.0001f;
break;
case PROP_VIEW_ROTATION:
options->view_rotation = CLAMP (g_value_get_double (value), 0.0f, 360.0f);
break;
case PROP_RADIUS:
options->radius = g_value_get_double (value);
break;
case PROP_GAIN:
options->gain = g_value_get_double (value);
break;
case PROP_HARDNESS:
options->hardness = g_value_get_double (value);
break;
case PROP_OPAQUE:
options->opaque = g_value_get_double (value);
break;
case PROP_PIGMENT:
options->pigment = g_value_get_double (value);
break;
case PROP_POSTERIZE:
options->posterize = g_value_get_double (value);
break;
case PROP_POSTERIZE_NUM:
options->posterize_num = g_value_get_double (value);
break;
case PROP_ERASER:
options->eraser = g_value_get_boolean (value);
break;
@@ -173,15 +240,33 @@ gimp_mybrush_options_get_property (GObject *object,
switch (property_id)
{
case PROP_VIEW_ZOOM:
g_value_set_double (value, options->view_zoom);
break;
case PROP_VIEW_ROTATION:
g_value_set_double (value, options->view_rotation);
break;
case PROP_RADIUS:
g_value_set_double (value, options->radius);
break;
case PROP_OPAQUE:
g_value_set_double (value, options->opaque);
break;
case PROP_GAIN:
g_value_set_double (value, options->gain);
break;
case PROP_HARDNESS:
g_value_set_double (value, options->hardness);
break;
case PROP_PIGMENT:
g_value_set_double (value, options->pigment);
break;
case PROP_POSTERIZE:
g_value_set_double (value, options->posterize);
break;
case PROP_POSTERIZE_NUM:
g_value_set_double (value, options->posterize_num);
break;
case PROP_ERASER:
g_value_set_boolean (value, options->eraser);
break;
@@ -201,10 +286,16 @@ gimp_mybrush_options_mybrush_changed (GimpContext *context,
{
if (brush)
g_object_set (context,
"radius", gimp_mybrush_get_radius (brush),
"opaque", gimp_mybrush_get_opaque (brush),
"hardness", gimp_mybrush_get_hardness (brush),
"eraser", gimp_mybrush_get_is_eraser (brush),
"viewzoom", 1.0f,
"viewrotation", 0.0f,
"radius", gimp_mybrush_get_radius (brush),
"opaque", gimp_mybrush_get_opaque (brush),
"gain", gimp_mybrush_get_gain (brush),
"hardness", gimp_mybrush_get_hardness (brush),
"pigment", gimp_mybrush_get_pigment (brush),
"posterize", gimp_mybrush_get_posterize (brush),
"posterizenum", gimp_mybrush_get_posterize_num (brush),
"eraser", gimp_mybrush_get_is_eraser (brush),
NULL);
}

View File

@@ -36,9 +36,15 @@ struct _GimpMybrushOptions
{
GimpPaintOptions parent_instance;
gdouble view_zoom;
gdouble view_rotation;
gdouble radius;
gdouble opaque;
gdouble gain;
gdouble hardness;
gdouble pigment;
gdouble posterize;
gdouble posterize_num;
gboolean eraser;
gboolean no_erasing;
};

File diff suppressed because it is too large Load Diff

View File

@@ -78,5 +78,15 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options)
0.1, 1.0, 2);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
/* pressure gain */
scale = gimp_prop_spin_scale_new (config, "gain",
0.1, 0.0, 2);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
/* pigment */
scale = gimp_prop_spin_scale_new (config, "pigment",
0.1, 0.0, 2);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
return vbox;
}

View File

@@ -56,6 +56,10 @@ static GimpCanvasItem * gimp_mybrush_tool_get_outline (GimpPaintTool *paint_tool
gdouble x,
gdouble y);
static void gimp_mybrush_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
void
gimp_mybrush_tool_register (GimpToolRegisterCallback callback,
@@ -84,6 +88,7 @@ gimp_mybrush_tool_class_init (GimpMybrushToolClass *klass)
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpPaintToolClass *paint_tool_class = GIMP_PAINT_TOOL_CLASS (klass);
tool_class->cursor_update = gimp_mybrush_tool_cursor_update;
tool_class->options_notify = gimp_mybrush_tool_options_notify;
paint_tool_class->get_outline = gimp_mybrush_tool_get_outline;
@@ -176,3 +181,19 @@ gimp_mybrush_tool_create_cursor (GimpPaintTool *paint_tool,
return NULL;
}
static void gimp_mybrush_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
{
GimpDisplayShell *shell;
GimpMybrushOptions *options = GIMP_MYBRUSH_TOOL_GET_OPTIONS (tool);
g_return_if_fail (GIMP_IS_DISPLAY (display));
shell = gimp_display_get_shell (display);
options->view_zoom = gimp_zoom_model_get_factor (shell->zoom);
options->view_rotation = shell->rotate_angle;
}

View File

@@ -430,14 +430,14 @@
"sources": [
{
"type": "archive",
"url": "https://github.com/mypaint/mypaint-brushes/releases/download/v1.3.1/mypaint-brushes-1.3.1.tar.xz",
"sha256": "fef66ffc241b7c5cd29e9c518e933c739618cb51c4ed4d745bf648a1afc3fe70",
"url": "https://github.com/mypaint/mypaint-brushes/releases/download/v2.0.2/mypaint-brushes-2.0.2.tar.xz",
"sha256": "7984a74edef94571d872d0629b224abaa956a36f632f5c5516b33d22e49eb566",
"x-checker-data": {
"type": "anitya",
"project-id": 17096,
"stable-only": true,
"versions": {
"<": "2.0.0"
">": "2.0.1"
},
"url-template": "https://github.com/mypaint/mypaint-brushes/releases/download/v$version/mypaint-brushes-$version.tar.xz"
}

View File

@@ -59,7 +59,7 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-libwmf \
mingw-w64-$MSYS2_ARCH-luajit \
mingw-w64-$MSYS2_ARCH-maxflow \
mingw-w64-$MSYS2_ARCH-mypaint-brushes \
mingw-w64-$MSYS2_ARCH-mypaint-brushes2 \
mingw-w64-$MSYS2_ARCH-openexr \
mingw-w64-$MSYS2_ARCH-pango \
mingw-w64-$MSYS2_ARCH-poppler \