예제 #1
0
파일: PlainBrush.cs 프로젝트: msiyer/Pinta
		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			// Cairo does not support a single-pixel-long single-pixel-wide line
			if (x == lastX && y == lastY && g.LineWidth == 1 &&
			    PintaCore.Workspace.ActiveWorkspace.PointInCanvas (new PointD(x,y))) {
				surface.Flush ();

				ColorBgra source = surface.GetColorBgraUnchecked (x, y);
				source = UserBlendOps.NormalBlendOp.ApplyStatic (source, strokeColor.ToColorBgra ());
				surface.SetColorBgra (source, x, y);
				surface.MarkDirty ();

				return new Gdk.Rectangle (x - 1, y - 1, 3, 3);
			}

			g.MoveTo (lastX + 0.5, lastY + 0.5);
			g.LineTo (x + 0.5, y + 0.5);
			g.StrokePreserve ();

			Gdk.Rectangle dirty = g.FixedStrokeExtents ().ToGdkRectangle ();

			// For some reason (?!) we need to inflate the dirty
			// rectangle for small brush widths in zoomed images
			dirty.Inflate (1, 1);

			return dirty;
		}