static void gimp_foreground_select_tool_draw (GimpDrawTool *draw_tool) { GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (draw_tool); GimpTool *tool = GIMP_TOOL (draw_tool); GimpForegroundSelectOptions *options; options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (tool); if (fg_select->stroke) { gimp_draw_tool_add_pen (draw_tool, (const GimpVector2 *) fg_select->stroke->data, fg_select->stroke->len, GIMP_CONTEXT (options), (options->background ? GIMP_ACTIVE_COLOR_BACKGROUND : GIMP_ACTIVE_COLOR_FOREGROUND), options->stroke_width); } if (fg_select->mask) { GimpDisplayShell *shell = gimp_display_get_shell (draw_tool->display); gint x = fg_select->last_coords.x; gint y = fg_select->last_coords.y; gdouble radius; radius = (options->stroke_width / shell->scale_y) / 2; /* warn if the user is drawing outside of the working area */ if (FALSE) { gint x1, y1; gint x2, y2; gimp_foreground_select_tool_get_area (fg_select->mask, &x1, &y1, &x2, &y2); if (x < x1 + radius || x > x2 - radius || y < y1 + radius || y > y2 - radius) { gimp_draw_tool_add_rectangle (draw_tool, FALSE, x1, y1, x2 - x1, y2 - y1); } } gimp_draw_tool_add_arc (draw_tool, FALSE, x - radius, y - radius, 2 * radius, 2 * radius, 0.0, 2.0 * G_PI); } else { GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool); } }
static void gimp_warp_tool_draw (GimpDrawTool *draw_tool) { GimpWarpTool *wt = GIMP_WARP_TOOL (draw_tool); GimpWarpOptions *options = GIMP_WARP_TOOL_GET_OPTIONS (wt); gimp_draw_tool_add_arc (draw_tool, FALSE, wt->cursor_x - options->effect_size * 0.5, wt->cursor_y - options->effect_size * 0.5, options->effect_size, options->effect_size, 0.0, 2.0 * G_PI); }
static void gimp_rectangle_select_tool_draw (GimpDrawTool *draw_tool) { GimpRectangleSelectTool *rect_sel_tool; GimpRectangleSelectToolPrivate *priv; GimpCanvasGroup *stroke_group = NULL; rect_sel_tool = GIMP_RECTANGLE_SELECT_TOOL (draw_tool); priv = GIMP_RECTANGLE_SELECT_TOOL_GET_PRIVATE (rect_sel_tool); if (priv->round_corners) { GimpCanvasItem *item; gint x1, y1, x2, y2; gdouble radius; gint square_size; g_object_get (rect_sel_tool, "x1", &x1, "y1", &y1, "x2", &x2, "y2", &y2, NULL); radius = MIN (priv->corner_radius, MIN ((x2 - x1) / 2.0, (y2 - y1) / 2.0)); square_size = (int) (radius * 2); stroke_group = GIMP_CANVAS_GROUP (gimp_draw_tool_add_stroke_group (draw_tool)); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x1, y1, square_size, square_size, G_PI / 2.0, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x2 - square_size, y1, square_size, square_size, 0.0, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x2 - square_size, y2 - square_size, square_size, square_size, G_PI * 1.5, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x1, y2 - square_size, square_size, square_size, G_PI, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); } gimp_rectangle_tool_draw (draw_tool, stroke_group); }
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool) { if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool))) { GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (draw_tool); GimpPaintCore *core = paint_tool->core; GimpImage *image = gimp_display_get_image (draw_tool->display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpCanvasItem *outline = NULL; gboolean line_drawn = FALSE; gdouble last_x, last_y; gdouble cur_x, cur_y; gint off_x, off_y; gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); last_x = core->last_coords.x + off_x; last_y = core->last_coords.y + off_y; cur_x = core->cur_coords.x + off_x; cur_y = core->cur_coords.y + off_y; if (paint_tool->draw_line && ! gimp_tool_control_is_active (GIMP_TOOL (draw_tool)->control)) { GimpCanvasGroup *group; group = gimp_draw_tool_add_stroke_group (draw_tool); gimp_draw_tool_push_group (draw_tool, group); gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CIRCLE, last_x, last_y, GIMP_TOOL_HANDLE_SIZE_CIRCLE, GIMP_TOOL_HANDLE_SIZE_CIRCLE, GIMP_HANDLE_ANCHOR_CENTER); gimp_draw_tool_add_line (draw_tool, last_x, last_y, cur_x, cur_y); gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CIRCLE, cur_x, cur_y, GIMP_TOOL_HANDLE_SIZE_CIRCLE, GIMP_TOOL_HANDLE_SIZE_CIRCLE, GIMP_HANDLE_ANCHOR_CENTER); gimp_draw_tool_pop_group (draw_tool); line_drawn = TRUE; } gimp_paint_tool_set_draw_fallback (paint_tool, FALSE, 0.0); if (paint_tool->draw_brush) outline = gimp_paint_tool_get_outline (paint_tool, draw_tool->display, cur_x, cur_y); if (outline) { gimp_draw_tool_add_item (draw_tool, outline); g_object_unref (outline); } else if (paint_tool->draw_fallback) { /* Lets make a sensible fallback cursor * * Sensible cursor is * * crossed to indicate draw point * * reactive to options alterations * * not a full circle that would be in the way */ gint size = (gint) paint_tool->fallback_size; #define TICKMARK_ANGLE 48 #define ROTATION_ANGLE G_PI / 4 /* marks for indicating full size */ gimp_draw_tool_add_arc (draw_tool, FALSE, cur_x - (size / 2.0), cur_y - (size / 2.0), size, size, ROTATION_ANGLE - (2.0 * G_PI) / (TICKMARK_ANGLE * 2), (2.0 * G_PI) / TICKMARK_ANGLE); gimp_draw_tool_add_arc (draw_tool, FALSE, cur_x - (size / 2.0), cur_y - (size / 2.0), size, size, ROTATION_ANGLE + G_PI / 2 - (2.0 * G_PI) / (TICKMARK_ANGLE * 2), (2.0 * G_PI) / TICKMARK_ANGLE); gimp_draw_tool_add_arc (draw_tool, FALSE, cur_x - (size / 2.0), cur_y - (size / 2.0), size, size, ROTATION_ANGLE + G_PI - (2.0 * G_PI) / (TICKMARK_ANGLE * 2), (2.0 * G_PI) / TICKMARK_ANGLE); gimp_draw_tool_add_arc (draw_tool, FALSE, cur_x - (size / 2.0), cur_y - (size / 2.0), size, size, ROTATION_ANGLE + 3 * G_PI / 2 - (2.0 * G_PI) / (TICKMARK_ANGLE * 2), (2.0 * G_PI) / TICKMARK_ANGLE); } else if (paint_tool->draw_circle) { gint size = (gint) paint_tool->circle_size; /* draw an indicatory circle */ gimp_draw_tool_add_arc (draw_tool, FALSE, cur_x - (size / 2.0), cur_y - (size / 2.0), size, size, 0.0, (2.0 * G_PI)); } if (! outline && ! line_drawn && ! paint_tool->show_cursor && ! paint_tool->draw_circle) { /* don't leave the user without any indication and draw * a fallback crosshair */ gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CROSSHAIR, cur_x, cur_y, GIMP_TOOL_HANDLE_SIZE_CROSSHAIR, GIMP_TOOL_HANDLE_SIZE_CROSSHAIR, GIMP_HANDLE_ANCHOR_CENTER); } } GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool); }