Freehand and polygonal lasso¶
Freehand lasso¶
| Fact | Value |
|---|---|
| Status | Implemented and tested |
| Group | Lasso |
| Engine | Browser |
| Code | web/src/core/mask/raster.ts, polygonMask |
Polygonal lasso¶
| Fact | Value |
|---|---|
| Status | Implemented and tested |
| Group | Lasso |
| Engine | Browser |
| Code | web/src/core/mask/raster.ts, polygonMask |
Overview¶
The lasso tools select the area inside an outline that you draw. The freehand lasso (L) follows the pointer. The polygonal lasso (Shift+L) draws straight sides between the corners you click.
How to use them¶
Freehand lasso:
- Drag around the area.
- Let go. A straight line closes the outline back to the start.
Polygonal lasso:
- Click to place each corner. A line follows the pointer to the next corner.
- Backspace removes the last corner. Escape cancels.
- Close the shape on the first corner, with a double-click or with Enter.
For both, Shift at the start adds to the selection, Alt subtracts and both intersect.
How it works¶
Freehand lasso:
- Record the pointer positions while you drag.
- On release, close the path back to the first point.
- Fill the polygon with the nonzero winding rule, with anti-aliasing from 4 rows of samples per pixel.
- Feather the shape when the feather setting is above 0.
- Combine it with the current selection by the mode.
Polygonal lasso:
- Add a corner at each click. A line follows the pointer to show the next side.
- Close the polygon on the first corner, with a double-click or with Enter.
- Fill the polygon with the nonzero winding rule, with anti-aliasing.
- Feather the shape when the feather setting is above 0.
- Combine it with the current selection by the mode.
Mathematical foundation¶
The outline is a polygon. A point is inside when the winding number of the outline around it is not 0. The winding number counts how many times the outline turns around the point, with the direction as the sign. This is the nonzero rule. So both loops of a figure eight are inside, and a loop drawn twice does not cancel itself.
The fill works row by row. On each of 4 sample rows per pixel, the crossings of the outline give the spans inside. Each pixel gets the part of the spans that covers it, averaged over its 4 rows. Without anti-aliasing, a pixel is inside when its center is.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Feather feather |
0 | 0 to 250 px | Softens the edge of the new selection. |
Anti-alias antiAlias |
on | On or off | Gives edge pixels a value for the part of them that the shape covers. |
The polygonal lasso has the same settings.
Limitations¶
- The closing line of the freehand lasso is straight.
- The polygonal lasso closes on clicks within 6 screen pixels of the first corner.