-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
204 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2018 Laszlo Balazs-Csiki and Contributors | ||
* | ||
* This file is part of Pixelitor. Pixelitor is free software: you | ||
* can redistribute it and/or modify it under the terms of the GNU | ||
* General Public License, version 3 as published by the Free | ||
* Software Foundation. | ||
* | ||
* Pixelitor is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Pixelitor. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package pixelitor.tools.pen; | ||
|
||
import pixelitor.Composition; | ||
import pixelitor.gui.ImageComponents; | ||
import pixelitor.layers.Drawable; | ||
import pixelitor.menus.MenuAction; | ||
import pixelitor.tools.AbstractBrushTool; | ||
import pixelitor.utils.Messages; | ||
|
||
import java.awt.Shape; | ||
|
||
/** | ||
* Strokes a shape with an {@link AbstractBrushTool} | ||
*/ | ||
public class TraceAction extends MenuAction { | ||
private final AbstractBrushTool brushTool; | ||
|
||
public TraceAction(String name, AbstractBrushTool brushTool) { | ||
super(name); | ||
this.brushTool = brushTool; | ||
} | ||
|
||
@Override | ||
public void onClick() { | ||
ImageComponents.onActiveComp(this::trace); | ||
} | ||
|
||
private void trace(Composition comp) { | ||
if (!comp.activeIsDrawable()) { | ||
Messages.showNotDrawableError(); | ||
return; | ||
} | ||
|
||
Path path = comp.getActivePath(); | ||
if (path == null) { | ||
Messages.showInfo("No path", | ||
"There is no path in the composition"); | ||
return; | ||
} | ||
|
||
Shape shape = path.toImageSpaceShape(); | ||
if (shape != null) { | ||
Drawable dr = comp.getActiveDrawableOrThrow(); | ||
brushTool.trace(dr, shape); | ||
} | ||
} | ||
} |
Oops, something went wrong.