Skip to content

Commit

Permalink
Eliminated unsupported transform ops; added fill
Browse files Browse the repository at this point in the history
  • Loading branch information
defano committed Feb 7, 2018
1 parent 912cb1f commit 1c7ed61
Show file tree
Hide file tree
Showing 264 changed files with 7,083 additions and 1,469 deletions.
108 changes: 56 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,70 @@ An easy-to-use toolkit for incorporating paint tools similar to [MacPaint](https
## Features

* Standard suite of paint tools providing common modifier-key constraints (e.g., hold shift to snap lines to nearest 15-degree angle).
* Canvas supports undo and redo operations on all paint tool changes, plus cut, copy and paste integration with the system clipboard.
* Paint canvas supports undo and redo operations on all tool changes; plus cut, copy and paste integration with the system clipboard.
* Includes a variety of image transform tools like scale, rotate, shear, perspective and projection, plus the ability to adjust color depth, transparency and brightness.
* Painted images are zoomable via the Magnifier tool (displayed within a scrollable pane), and tools can be snapped to a grid.
* Lightweight toolkit integrates easily into Swing and JavaFX applications and utilizes [ReactiveX](https://github.com/ReactiveX/RxJava) for observables.
* All operations are backed by a standard Java `BufferedImage` making it easy to import and export graphics.
* Images are backed by a standard Java `BufferedImage` object making it easy to import and export graphics.

## Paint Tools

JMonet provides the following suite of paint tools:

Icon | Tool | Description
-----|-----------------|--------------
![Arrow](icons/arrow.png) | Arrow | A no-op tool that does not modify the canvas in any way.
![Magnifier](icons/magnifier.png) | Magnifier | Zoom in (scale the canvas) at the location clicked; hold `shift` to zoom out or `ctrl` to restore normal zoom.
![Airbrush](icons/spraypaint.png) | Airbrush | Paints translucent color or texture onto the canvas.
![Curve](icons/curve.png) | Curve | Draws quadratic (Bezier) curves by clicking to specify points on the curve.
![Eraser](icons/eraser.png) | Eraser | Removes paint from the canvas by restoring affected pixels to their fully-transparent state.
![Fill](icons/fill.png) | Fill | Shades an enclosed area with paint using a [flood-fill](https://en.wikipedia.org/wiki/Flood_fill) algorithm.
![Lasso](icons/lasso.png) | Lasso | Define a free-form selection boundary ([marching ants](https://en.wikipedia.org/wiki/Marching_ants)) for clearing or moving paint.
![Line](icons/line.png) | Line | Draws straight lines; hold `shift` to restrict lines to 15-degree angles.
![Oval](icons/oval.png) | Oval | Draws filled or outlined oval shapes; hold `shift` to constrain boundary to circle.
![Paintbrush](icons/paintbrush.png) | Paintbrush | Draws paint on the canvas (using configurable stroke and color/texture).
![Pencil](icons/pencil.png) | Pencil | Draws a free-form, narrow black path on the canvas.
![Polygon](icons/polygon.png) | Polygon | Draws filled or outlined irregular polygons by clicking to specify points. Double-click to complete the polygon; press `esc` to keep only the lines visible; hold `shift` to restrict line angles to 15 degree multiples.
![Freeform](icons/freeform.png) | Freeform | Draws a closed, free-form shape on the canvas. Click and drag to draw a path; release the mouse to draw a straight line connecting the final point on the path to the initial point.
![Rectangle](icons/rectangle.png) | Rectangle | Draws filled or outlined rectangles on the canvas; hold `shift` to constrain boundary to a square.
![Round Rect](icons/roundrect.png) | Round Rect | Draws filled or outlined round-rectangles on the canvas.
![Selection](icons/selection.png) | Selection | Define a selection rectangle ([marching ants](https://en.wikipedia.org/wiki/Marching_ants)) whose underlying graphic can be moved or cleared (press `delete`)
![Shape](icons/shape.png) | Shape | Draws filled or outlined regular polygons (i.e., shapes--triangles, squares, polygons, hexagons, etc.)
![Text](icons/text.png) | Text | Draws rasterized text (of a configurable font, size and style) on the canvas. Text remains editable until user clicks away.

## Transform tools

Icon | Tool | Description
-----|----------| -------------
![Rotate](icons/rotate.png) | Rotate | Define a selection, then use the drag handle to free-rotate the selected graphic around its center. Hold shift to restrict rotation angle to 15-degree increments.
![Slant](icons/slant.png) | Slant | Define a selection, then use the drag handles to apply an affine shear transform to the selected graphic.
![Scale](icons/scale.png) | Scale | Define a selection, then expand or shrink the selected image by dragging a handle. Hold shift to maintain selection's original aspect ratio.
![Projection](icons/distort.png) | Projection | Define a selection, then use the drag handles to project the image onto the geometry of an arbitrary quadrilateral.
![Perspective](icons/perspective.png) | Perspective | Define a selection, then use the drag handles to warp the image onto an isosceles trapezoid, providing the effect of the left or right side of the image appearing nearer or farther from the viewer.
![Rubber Sheet](icons/distort.png) | Rubber Sheet | Similar to the projection transform, but utilizes a "rubber sheet" algorithm that preserves relative position over linearity.

#### Static transforms

Selections can be flipped horizontally, vertically or rotated 90 degrees via any of the selection or transform tools. Adjustments to brightness, transparency and color are also available.

Once a selection has been made, invoke one of the following methods on the selection tool object to transform it:

```
void rotateLeft();
void rotateRight();
void flipHorizontal();
void flipVertical();
void adjustBrightness(int delta);
void adjustTransparency(int delta);
void invert();
void reduceColor(int colorDepth);
void reduceGreyscale(int grayDepth);
```
Icon | Tool | Description
--------------------------------------|--------------|--------------
![Arrow](icons/arrow.png) | Arrow | A no-op tool (does not modify the canvas).
![Magnifier](icons/magnifier.png) | Magnifier | Zoom in (scale the canvas) at the location clicked; hold `shift` to zoom out or `ctrl` to restore normal zoom.
![Airbrush](icons/spraypaint.png) | Airbrush | Paints translucent color or texture onto the canvas.
![Curve](icons/curve.png) | Curve | Draws quadratic (Bezier) curves by clicking to specify points on the curve.
![Eraser](icons/eraser.png) | Eraser | Removes paint from the canvas by restoring affected pixels to their fully-transparent state.
![Fill](icons/fill.png) | Fill | Shades an enclosed area with paint using a [flood-fill](https://en.wikipedia.org/wiki/Flood_fill) algorithm.
![Line](icons/line.png) | Line | Draws straight lines; hold `shift` to restrict lines to 15-degree angles.
![Oval](icons/oval.png) | Oval | Draws filled or outlined oval shapes; hold `shift` to constrain boundary to circle.
![Paintbrush](icons/paintbrush.png) | Paintbrush | Draws paint on the canvas (using configurable stroke and color/texture).
![Pencil](icons/pencil.png) | Pencil | Draws a free-form, narrow black path on the canvas.
![Polygon](icons/polygon.png) | Polygon | Draws filled or outlined irregular polygons by clicking to specify points. Double-click to close the polygon; press `esc` to keep only the lines visible; hold `shift` to restrict line angles to 15 degree multiples.
![Freeform](icons/freeform.png) | Freeform | Draws a closed, free-form shape on the canvas. Click and drag to draw a path; release the mouse to close the shape.
![Rectangle](icons/rectangle.png) | Rectangle | Draws filled or stroked rectangles on the canvas; hold `shift` to constrain boundary to a square.
![Round Rect](icons/roundrect.png) | Round Rect | Draws filled or stroked round-rectangles on the canvas.
![Shape](icons/shape.png) | Shape | Draws filled or stroked regular polygons (i.e., shapes--triangles, squares, polygons, hexagons, etc.)
![Text](icons/text.png) | Text | Draws rasterized text of configurable font, size and style on the canvas. Text remains editable until user clicks away.

### Selection tools

Icon | Tool | Description
--------------------------------------|--------------| -------------------------
![Lasso](icons/lasso.png) | Lasso | Define a free-form selection boundary ([marching ants](https://en.wikipedia.org/wiki/Marching_ants)) for clearing or moving paint.
![Selection](icons/selection.png) | Selection | Define a selection rectangle ([marching ants](https://en.wikipedia.org/wiki/Marching_ants)) whose underlying graphic can be moved or cleared (press `delete`)

### Transform tools

Icon | Tool | Description
--------------------------------------|--------------| -------------------------
![Rotate](icons/rotate.png) | Rotate | Define a selection, then use the drag handle to free-rotate the selected graphic around its center. Hold shift to restrict rotation angle to 15-degree increments.
![Slant](icons/slant.png) | Slant | Define a selection, then use the drag handles to apply an affine shear transform to the selected graphic.
![Scale](icons/scale.png) | Scale | Define a selection, then expand or shrink the selected image by dragging a handle. Hold shift to maintain selection's original aspect ratio.
![Projection](icons/distort.png) | Projection | Define a selection, then use the drag handles to project the image onto the geometry of an arbitrary quadrilateral.
![Perspective](icons/perspective.png) | Perspective | Define a selection, then use the drag handles to warp the image onto an isosceles trapezoid, providing the effect of the left or right side of the image appearing nearer or farther from the viewer.
![Rubber Sheet](icons/distort.png) | Rubber Sheet | Similar to the projection transform, but utilizes a "rubber sheet" algorithm that preserves relative position over linearity.

### Image transforms

Once a selection has been made, invoke one of the following methods on the `PaintTool` object to transform its selection:

Transform | Tool Availability | Description
------------------------|-------------------------------|-------------------------
`adjustBrightness` | Selection and transform tools | Changes the brightness/luminosity of all pixels in the selected image by adding `delta` to each red, green and blue color channel value (a value between 0..255, where 0 is completely dark, 255 is completely light).
`adjustTransparency` | Selection and transform tools | Changes the opacity of each pixel in the selected image by adding `delta` the alpha channel (a value between 0..255 where 0 is fully transparent and 255 is fully opaque).
`applyTransform` | Selection tools | Applies an `AffineTransform` to the selection.
`flipHorizontal` | Selection tools | Flips the selection about a vertical axis drawn through the center of the image.
`flipVertical` | Selection tools | Flips the selection about a horizontal axis drawn through the center of the image.
`invert` | Selection and transform tools | Inverts the color
`pickupSelection` | Selection tools | "Picks up" the pixels on the canvas that are currently within the bounds of the selection and adds them to the selection. Useful when moving a selection over another region of the canvas.
`reduceColor` | Selection and transform tools | Performs a color quantization and dithers the result using a specified dithering algorithm. See the `com.defano.algo.dither` package for available dithering implementations (or implement your own).
`reduceGreyscale` | Selection and transform tools | Performs a luminosity quantization and dithers the result using a specified dithering algorithm.
`rotateLeft` | Selection tools | Rotates the selection 90 degrees counter-clockwise.
`rotateRight` | Selection tools | Rotates the selection 90 degrees clockwise.

## Getting started

Expand Down
13 changes: 9 additions & 4 deletions javadoc/allclasses-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_131) on Mon Feb 05 20:25:51 CST 2018 -->
<!-- Generated by javadoc (1.8.0_131) on Tue Feb 06 21:03:55 CST 2018 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>All Classes (JMonet 0.2.0 API)</title>
<meta name="date" content="2018-02-05">
<meta name="date" content="2018-02-06">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
Expand Down Expand Up @@ -38,6 +38,8 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="com/defano/jmonet/algo/dither/quant/ColorReductionQuantizer.html" title="class in com.defano.jmonet.algo.dither.quant" target="classFrame">ColorReductionQuantizer</a></li>
<li><a href="com/defano/jmonet/canvas/surface/CompositeSurface.html" title="interface in com.defano.jmonet.canvas.surface" target="classFrame"><span class="interfaceName">CompositeSurface</span></a></li>
<li><a href="com/defano/jmonet/tools/CurveTool.html" title="class in com.defano.jmonet.tools" target="classFrame">CurveTool</a></li>
<li><a href="com/defano/jmonet/algo/DefaultBoundaryFunction.html" title="class in com.defano.jmonet.algo" target="classFrame">DefaultBoundaryFunction</a></li>
<li><a href="com/defano/jmonet/algo/DefaultFillFunction.html" title="class in com.defano.jmonet.algo" target="classFrame">DefaultFillFunction</a></li>
<li><a href="com/defano/jmonet/algo/dither/Ditherer.html" title="interface in com.defano.jmonet.algo.dither" target="classFrame"><span class="interfaceName">Ditherer</span></a></li>
<li><a href="com/defano/jmonet/tools/EraserTool.html" title="class in com.defano.jmonet.tools" target="classFrame">EraserTool</a></li>
<li><a href="com/defano/jmonet/algo/FillFunction.html" title="interface in com.defano.jmonet.algo" target="classFrame"><span class="interfaceName">FillFunction</span></a></li>
Expand All @@ -57,7 +59,7 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="com/defano/jmonet/tools/util/MarchingAnts.html" title="class in com.defano.jmonet.tools.util" target="classFrame">MarchingAnts</a></li>
<li><a href="com/defano/jmonet/tools/util/MarchingAntsObserver.html" title="interface in com.defano.jmonet.tools.util" target="classFrame"><span class="interfaceName">MarchingAntsObserver</span></a></li>
<li><a href="com/defano/jmonet/algo/dither/quant/MonochromaticQuantizer.html" title="class in com.defano.jmonet.algo.dither.quant" target="classFrame">MonochromaticQuantizer</a></li>
<li><a href="com/defano/jmonet/tools/base/MutableSelection.html" title="interface in com.defano.jmonet.tools.base" target="classFrame"><span class="interfaceName">MutableSelection</span></a></li>
<li><a href="com/defano/jmonet/tools/selection/MutableSelection.html" title="interface in com.defano.jmonet.tools.selection" target="classFrame"><span class="interfaceName">MutableSelection</span></a></li>
<li><a href="com/defano/jmonet/algo/dither/NullDitherer.html" title="class in com.defano.jmonet.algo.dither" target="classFrame">NullDitherer</a></li>
<li><a href="com/defano/jmonet/canvas/observable/ObservableSurface.html" title="interface in com.defano.jmonet.canvas.observable" target="classFrame"><span class="interfaceName">ObservableSurface</span></a></li>
<li><a href="com/defano/jmonet/tools/OvalTool.html" title="class in com.defano.jmonet.tools" target="classFrame">OvalTool</a></li>
Expand All @@ -81,6 +83,7 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="com/defano/jmonet/canvas/surface/ScalableLayeredPainting.html" title="interface in com.defano.jmonet.canvas.surface" target="classFrame"><span class="interfaceName">ScalableLayeredPainting</span></a></li>
<li><a href="com/defano/jmonet/tools/ScaleTool.html" title="class in com.defano.jmonet.tools" target="classFrame">ScaleTool</a></li>
<li><a href="com/defano/jmonet/canvas/surface/Scrollable.html" title="interface in com.defano.jmonet.canvas.surface" target="classFrame"><span class="interfaceName">Scrollable</span></a></li>
<li><a href="com/defano/jmonet/tools/selection/Selection.html" title="interface in com.defano.jmonet.tools.selection" target="classFrame"><span class="interfaceName">Selection</span></a></li>
<li><a href="com/defano/jmonet/tools/SelectionTool.html" title="class in com.defano.jmonet.tools" target="classFrame">SelectionTool</a></li>
<li><a href="com/defano/jmonet/tools/ShapeTool.html" title="class in com.defano.jmonet.tools" target="classFrame">ShapeTool</a></li>
<li><a href="com/defano/jmonet/algo/dither/SierraDitherer.html" title="class in com.defano.jmonet.algo.dither" target="classFrame">SierraDitherer</a></li>
Expand All @@ -91,7 +94,9 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="com/defano/jmonet/canvas/observable/SurfaceInteractionObserver.html" title="interface in com.defano.jmonet.canvas.observable" target="classFrame"><span class="interfaceName">SurfaceInteractionObserver</span></a></li>
<li><a href="com/defano/jmonet/tools/TextTool.html" title="class in com.defano.jmonet.tools" target="classFrame">TextTool</a></li>
<li><a href="com/defano/jmonet/algo/Transform.html" title="class in com.defano.jmonet.algo" target="classFrame">Transform</a></li>
<li><a href="com/defano/jmonet/tools/base/TransformableSelection.html" title="interface in com.defano.jmonet.tools.base" target="classFrame"><span class="interfaceName">TransformableSelection</span></a></li>
<li><a href="com/defano/jmonet/tools/selection/TransformableCanvasSelection.html" title="interface in com.defano.jmonet.tools.selection" target="classFrame"><span class="interfaceName">TransformableCanvasSelection</span></a></li>
<li><a href="com/defano/jmonet/tools/selection/TransformableImageSelection.html" title="interface in com.defano.jmonet.tools.selection" target="classFrame"><span class="interfaceName">TransformableImageSelection</span></a></li>
<li><a href="com/defano/jmonet/tools/selection/TransformableSelection.html" title="interface in com.defano.jmonet.tools.selection" target="classFrame"><span class="interfaceName">TransformableSelection</span></a></li>
</ul>
</div>
</body>
Expand Down
Loading

0 comments on commit 1c7ed61

Please sign in to comment.