app: mypaint: Include offset_by_random in the cursor calculation

This commit is contained in:
Daniel Sabo 2015-12-29 09:54:48 -08:00
parent b48ac23690
commit ea66a7a974
5 changed files with 27 additions and 10 deletions

View File

@ -142,6 +142,10 @@ gimp_mybrush_load (GimpContext *context,
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_ERASER) > 0.5f;
brush->priv->offset_by_random =
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_OFFSET_BY_RANDOM);
mypaint_brush_unref (mypaint_brush);
return g_list_prepend (NULL, brush);

View File

@ -27,6 +27,7 @@ struct _GimpMybrushPrivate
gdouble radius;
gdouble opaque;
gdouble hardness;
gdouble offset_by_random;
gboolean eraser;
};

View File

@ -261,6 +261,14 @@ gimp_mybrush_get_hardness (GimpMybrush *brush)
return brush->priv->hardness;
}
gdouble
gimp_mybrush_get_offset_by_random (GimpMybrush *brush)
{
g_return_val_if_fail (GIMP_IS_MYBRUSH (brush), 1.0);
return brush->priv->offset_by_random;
}
gboolean
gimp_mybrush_get_is_eraser (GimpMybrush *brush)
{

View File

@ -48,18 +48,19 @@ struct _GimpMybrushClass
};
GType gimp_mybrush_get_type (void) G_GNUC_CONST;
GType gimp_mybrush_get_type (void) G_GNUC_CONST;
GimpData * gimp_mybrush_new (GimpContext *context,
const gchar *name);
GimpData * gimp_mybrush_get_standard (GimpContext *context);
GimpData * gimp_mybrush_new (GimpContext *context,
const gchar *name);
GimpData * gimp_mybrush_get_standard (GimpContext *context);
const gchar * gimp_mybrush_get_brush_json (GimpMybrush *brush);
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_hardness (GimpMybrush *brush);
gboolean gimp_mybrush_get_is_eraser (GimpMybrush *brush);
gdouble gimp_mybrush_get_radius (GimpMybrush *brush);
gdouble gimp_mybrush_get_opaque (GimpMybrush *brush);
gdouble gimp_mybrush_get_hardness (GimpMybrush *brush);
gdouble gimp_mybrush_get_offset_by_random (GimpMybrush *brush);
gboolean gimp_mybrush_get_is_eraser (GimpMybrush *brush);
#endif /* __GIMP_MYBRUSH_H__ */

View File

@ -38,6 +38,7 @@
#include "gimpmybrushoptions-gui.h"
#include "gimpmybrushtool.h"
#include "gimptoolcontrol.h"
#include "core/gimpmybrush.h"
#include "gimp-intl.h"
@ -122,10 +123,12 @@ gimp_mybrush_tool_get_outline (GimpPaintTool *paint_tool,
gdouble y)
{
GimpMybrushOptions *options = GIMP_MYBRUSH_TOOL_GET_OPTIONS (paint_tool);
GimpMybrush *brush = gimp_context_get_mybrush (GIMP_CONTEXT (options));
GimpCanvasItem *item = NULL;
GimpDisplayShell *shell = gimp_display_get_shell (display);
gdouble radius = MAX (MAX (4 / shell->scale_x, 4 / shell->scale_y), exp (options->radius) + options->radius * 2);
gdouble radius = exp (options->radius) + 2 * options->radius * gimp_mybrush_get_offset_by_random (brush);
radius = MAX (MAX (4 / shell->scale_x, 4 / shell->scale_y), radius);
item = gimp_mybrush_tool_create_cursor (paint_tool, display, x, y, radius);