Skip to content

Commit

Permalink
Update for the removal of BaseTool.point_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronwhite committed Dec 28, 2024
1 parent 018deeb commit 50d7b9d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions PintaDemoExtension/RandomPencilTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RandomPencilTool : BaseTool
{
private readonly IPaletteService palette;

private PointI last_point = point_empty;
private PointI? last_point = null;

private ImageSurface? undo_surface;
private bool surface_modified;
Expand Down Expand Up @@ -71,7 +71,7 @@ protected override void OnMouseDown (Document document, ToolMouseEventArgs e)
} else if (e.MouseButton == MouseButton.Right) {
tool_color = palette.SecondaryColor;
} else {
last_point = point_empty;
last_point = null;
return;
}

Expand All @@ -85,7 +85,7 @@ protected override void OnMouseMove (Document document, ToolMouseEventArgs e)
if (mouse_button == MouseButton.Left || mouse_button == MouseButton.Right) {
tool_color = RandomColourPicker.PickRandom ();
} else {
last_point = point_empty;
last_point = null;
return;
}

Expand All @@ -108,7 +108,7 @@ private void Draw (Document document, ToolMouseEventArgs e, Color tool_color, bo
var x = e.Point.X;
var y = e.Point.Y;

if (last_point.Equals (point_empty)) {
if (last_point is null) {
last_point = e.Point;

if (!first_pixel)
Expand Down Expand Up @@ -139,12 +139,12 @@ private void Draw (Document document, ToolMouseEventArgs e, Color tool_color, bo
} else {
// Adding 0.5 forces cairo into the correct square:
// See https://bugs.launchpad.net/bugs/672232
g.MoveTo (last_point.X + 0.5, last_point.Y + 0.5);
g.MoveTo (last_point.Value.X + 0.5, last_point.Value.Y + 0.5);
g.LineTo (x + 0.5, y + 0.5);
g.Stroke ();
}

var dirty = CairoExtensions.GetRectangleFromPoints (last_point, new PointI (x, y), 4);
var dirty = CairoExtensions.GetRectangleFromPoints (last_point.Value, new PointI (x, y), 4);

document.Workspace.Invalidate (document.ClampToImageSize (dirty));

Expand Down

0 comments on commit 50d7b9d

Please sign in to comment.