Skip to content

Commit

Permalink
Fix incorrect color when drawing a single pixel with the Pencil tool.
Browse files Browse the repository at this point in the history
The color was being set after the special case for drawing a single pixel.

Fixes: #1897245
  • Loading branch information
cameronwhite committed Sep 27, 2020
1 parent 0088ab5 commit a1c423e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Thanks to the following contributors who worked on this release:
- Fixed inconsistent behavior when switching between tools that share the same shortcut, such as the selection tools (#144, [#1558767](https://bugs.launchpad.net/pinta/+bug/1558767))

### Fixed
- Fixed a bug where drawing a single pixel with the Pencil tool used black instead of the palette color ([#1897245](https://bugs.launchpad.net/pinta/+bug/1897245)).
- Fixed issues with the zoom controls when using a French locale ([#1464855](https://bugs.launchpad.net/pinta/+bug/1464855))
- Fixed invalid URLs in `pinta.appdata.xml` (#140, #145)
- Added missing release notes to `pinta.appdata.xml` (#142)
Expand Down
21 changes: 10 additions & 11 deletions Pinta.Tools/Tools/PencilTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,15 @@ private void Draw (DrawingArea drawingarea1, Color tool_color, Cairo.PointD poin

g.Antialias = Antialias.None;

if (first_pixel) {
g.SetSourceColor(tool_color);
if (UseAlphaBlending)
g.SetBlendMode(BlendMode.Normal);
else
g.Operator = Operator.Source;
g.LineWidth = 1;
g.LineCap = LineCap.Square;

if (first_pixel) {
// Cairo does not support a single-pixel-long single-pixel-wide line
g.Rectangle (x, y, 1.0, 1.0);
g.Fill ();
Expand All @@ -140,17 +148,8 @@ private void Draw (DrawingArea drawingarea1, Color tool_color, Cairo.PointD poin
// See https://bugs.launchpad.net/bugs/672232
g.MoveTo (last_point.X + 0.5, last_point.Y + 0.5);
g.LineTo (x + 0.5, y + 0.5);
g.Stroke();
}

g.SetSourceColor (tool_color);
if (UseAlphaBlending)
g.SetBlendMode(BlendMode.Normal);
else
g.Operator = Operator.Source;
g.LineWidth = 1;
g.LineCap = LineCap.Square;

g.Stroke ();
}

Gdk.Rectangle r = GetRectangleFromPoints (last_point, new Point (x, y));
Expand Down

0 comments on commit a1c423e

Please sign in to comment.