mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 18:57:28 -07:00
Added a sensibility property so the Freehand drawing can also be used with a pen. This is for the reported bug [#1454]
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2461 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
f605be6dc3
commit
3cd141eb77
3 changed files with 12 additions and 6 deletions
|
@ -31,6 +31,8 @@ using Greenshot.Plugin;
|
|||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Memento;
|
||||
using System.Drawing.Drawing2D;
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.IniFile;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -42,7 +44,7 @@ namespace Greenshot.Drawing {
|
|||
[Serializable()]
|
||||
public abstract class DrawableContainer : AbstractFieldHolderWithChildren, INotifyPropertyChanged, IDrawableContainer {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DrawableContainer));
|
||||
|
||||
protected static readonly EditorConfiguration editorConfig = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
private bool isMadeUndoable = false;
|
||||
|
||||
[NonSerialized]
|
||||
|
|
|
@ -118,11 +118,11 @@ namespace Greenshot.Drawing {
|
|||
/// <returns>true if the surface doesn't need to handle the event</returns>
|
||||
public override bool HandleMouseMove(int mouseX, int mouseY) {
|
||||
Point previousPoint = capturePoints[capturePoints.Count-1];
|
||||
|
||||
if (GeometryHelper.Distance2D(previousPoint.X, previousPoint.Y, mouseX, mouseY ) > 5) {
|
||||
|
||||
if (GeometryHelper.Distance2D(previousPoint.X, previousPoint.Y, mouseX, mouseY) >= (2*editorConfig.FreehandSensitivity)) {
|
||||
capturePoints.Add(new Point(mouseX, mouseY));
|
||||
}
|
||||
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) > 2 ) {
|
||||
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) >= editorConfig.FreehandSensitivity) {
|
||||
//path.AddCurve(new Point[]{lastMouse, new Point(mouseX, mouseY)});
|
||||
freehandPath.AddLine(lastMouse, new Point(mouseX, mouseY));
|
||||
lastMouse = new Point(mouseX, mouseY);
|
||||
|
@ -138,7 +138,7 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
public override void HandleMouseUp(int mouseX, int mouseY) {
|
||||
// Make sure we don't loose the ending point
|
||||
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) > 2) {
|
||||
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) >= editorConfig.FreehandSensitivity) {
|
||||
capturePoints.Add(new Point(mouseX, mouseY));
|
||||
}
|
||||
RecalculatePath();
|
||||
|
@ -156,13 +156,15 @@ namespace Greenshot.Drawing {
|
|||
freehandPath = new GraphicsPath();
|
||||
|
||||
// Here we can put some cleanup... like losing all the uninteresting points.
|
||||
if (capturePoints.Count > 3) {
|
||||
if (capturePoints.Count >= 3) {
|
||||
int index = 0;
|
||||
while ((capturePoints.Count - 1) % 3 != 0) {
|
||||
// duplicate points, first at 50% than 25% than 75%
|
||||
capturePoints.Insert((int)(capturePoints.Count*POINT_OFFSET[index]), capturePoints[(int)(capturePoints.Count*POINT_OFFSET[index++])]);
|
||||
}
|
||||
freehandPath.AddBeziers(capturePoints.ToArray());
|
||||
} else if (capturePoints.Count == 2) {
|
||||
freehandPath.AddLine(capturePoints[0], capturePoints[1]);
|
||||
}
|
||||
|
||||
// Recalculate the bounds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue