mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
smooth the motion of large brushes
This commit is contained in:
parent
6e27d133a8
commit
69666f3b8a
2 changed files with 4 additions and 4 deletions
|
@ -17,7 +17,7 @@ const broadBrushHelper = function (tool) {
|
|||
let finalPath;
|
||||
|
||||
tool.onBroadMouseDown = function (event) {
|
||||
tool.minDistance = this.options.brushSize / 4;
|
||||
tool.minDistance = 1;
|
||||
tool.maxDistance = this.options.brushSize;
|
||||
if (event.event.button > 0) return; // only first mouse button
|
||||
|
||||
|
@ -54,7 +54,7 @@ const broadBrushHelper = function (tool) {
|
|||
if (finalPath.segments.length === 5) {
|
||||
// Flatten is necessary to prevent smooth from getting rid of the effect
|
||||
// of the handles on the first point.
|
||||
finalPath.flatten(this.options.brushSize / 5);
|
||||
finalPath.flatten(Math.min(5, this.options.brushSize / 5));
|
||||
}
|
||||
finalPath.smooth();
|
||||
lastPoint = event.point;
|
||||
|
|
|
@ -20,7 +20,7 @@ const segmentBrushHelper = function (tool) {
|
|||
tool.onSegmentMouseDown = function (event) {
|
||||
if (event.event.button > 0) return; // only first mouse button
|
||||
|
||||
tool.minDistance = this.options.brushSize / 4;
|
||||
tool.minDistance = 1;
|
||||
tool.maxDistance = this.options.brushSize;
|
||||
|
||||
finalPath = new paper.Path.Circle({
|
||||
|
@ -60,7 +60,7 @@ const segmentBrushHelper = function (tool) {
|
|||
path.closed = true;
|
||||
// The unite function on curved paths does not always work (sometimes deletes half the path)
|
||||
// so we have to flatten.
|
||||
path.flatten(this.options.brushSize / 5);
|
||||
path.flatten(Math.min(5, this.options.brushSize / 5));
|
||||
|
||||
lastPoint = event.point;
|
||||
const newPath = finalPath.unite(path);
|
||||
|
|
Loading…
Reference in a new issue