protected override void OnMouseMove(Document document, ToolMouseEventArgs e) { if (mouse_button == MouseButton.Left) { stroke_color = Palette.PrimaryColor; } else if (mouse_button == MouseButton.Right) { stroke_color = Palette.SecondaryColor; } else { last_point = point_empty; return; } // TODO: also multiply by pressure stroke_color = new Color(stroke_color.R, stroke_color.G, stroke_color.B, stroke_color.A * active_brush.StrokeAlphaMultiplier); var x = e.Point.X; var y = e.Point.Y; if (last_point.Equals(point_empty)) { last_point = e.Point; } if (document.Workspace.PointInCanvas(e.PointDouble)) { surface_modified = true; } var surf = document.Layers.CurrentUserLayer.Surface; var invalidate_rect = Gdk.Rectangle.Zero; var brush_width = BrushWidth; using (var g = document.CreateClippedContext()) { g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None; g.LineWidth = brush_width; g.LineJoin = LineJoin.Round; g.LineCap = BrushWidth == 1 ? LineCap.Butt : LineCap.Round; g.SetSourceColor(stroke_color); invalidate_rect = active_brush.DoMouseMove(g, stroke_color, surf, x, y, last_point.X, last_point.Y); } // If we draw partially offscreen, Cairo gives us a bogus // dirty rectangle, so redraw everything. if (document.Workspace.IsPartiallyOffscreen(invalidate_rect)) { document.Workspace.Invalidate(); } else { document.Workspace.Invalidate(document.ClampToImageSize(invalidate_rect)); } last_point = e.Point; }
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point) { Document doc = PintaCore.Workspace.ActiveDocument; if (mouse_button == 1) { stroke_color = PintaCore.Palette.PrimaryColor; } else if (mouse_button == 3) { stroke_color = PintaCore.Palette.SecondaryColor; } else { last_point = point_empty; return; } // TODO: also multiply by pressure stroke_color = new Color(stroke_color.R, stroke_color.G, stroke_color.B, stroke_color.A * active_brush.StrokeAlphaMultiplier); int x = (int)point.X; int y = (int)point.Y; if (last_point.Equals(point_empty)) { last_point = new Point(x, y); } if (doc.Workspace.PointInCanvas(point)) { surface_modified = true; } var surf = doc.CurrentUserLayer.Surface; var invalidate_rect = Gdk.Rectangle.Zero; var brush_width = BrushWidth;//nlook width change of brush + x/10; using (var g = new Context(surf)) { g.AppendPath(doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; g.Clip(); g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None; g.LineWidth = brush_width; g.LineJoin = LineJoin.Round; g.LineCap = BrushWidth == 1 ? LineCap.Butt : LineCap.Round; g.SetSourceColor(stroke_color); invalidate_rect = active_brush.DoMouseMove(g, stroke_color, surf, x, y, last_point.X, last_point.Y); } // If we draw partially offscreen, Cairo gives us a bogus // dirty rectangle, so redraw everything. if (doc.Workspace.IsPartiallyOffscreen(invalidate_rect)) { doc.Workspace.Invalidate(); } else { doc.Workspace.Invalidate(doc.ClampToImageSize(invalidate_rect)); } last_point = new Point(x, y); }