Rectangular and elliptical marquee¶
Rectangular marquee¶
| Fact | Value |
|---|---|
| Status | Implemented and tested |
| Group | Marquee |
| Engine | Browser |
| Code | web/src/core/mask/raster.ts, rectMask |
Elliptical marquee¶
| Fact | Value |
|---|---|
| Status | Implemented and tested |
| Group | Marquee |
| Engine | Browser |
| Code | web/src/core/mask/raster.ts, ellipseMask |
Overview¶
The marquee tools select a rectangle or an ellipse that you drag. Press M for the rectangle and Shift+M for the ellipse.
How to use them¶
- Press where one corner should be and drag to the opposite corner.
- Hold Shift while you drag for a square or circle. Hold Alt to draw from the center.
- To add to the selection, hold Shift when you start the drag. Alt at the start subtracts, both intersect.
- A click without a drag removes the selection.
The options bar sets the style. Fixed ratio keeps the width and height in a ratio. Fixed size places a box of an exact size where you click.
How it works¶
The rectangle:
- Snap the two corners of the drag to whole pixels.
- With Shift, make the sides equal. With Alt, use the start point as the center.
- With a fixed ratio or size, set the width and height from the settings.
- Fill the rectangle with 255 in a new mask. Pixels outside stay 0.
- Feather the shape when the feather setting is above 0.
- Combine it with the current selection by the mode.
The ellipse:
- Snap the two corners of the drag to whole pixels. They bound the ellipse.
- With Shift, make a circle. With Alt, use the start point as the center.
- Give each pixel the part of it that lies inside the ellipse, 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.
Mathematical foundation¶
The corners snap to whole pixel edges, so the rectangle covers whole pixels. Its mask is 255 inside and 0 outside.
The ellipse with center \((c_x, c_y)\) and half-axes \(a\) and \(b\) is the set of points with
where \(x\) and \(y\) are positions in pixels. This is a mathematical definition. With anti-aliasing, each pixel gets the part of its area inside the ellipse. PixelNexus measures that part on 4 rows of samples per pixel, with the exact horizontal coverage on each row. So the value of an edge pixel is right to within 1/4 of a pixel row.
Parameters¶
Rectangular marquee:
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Style style |
Normal | Normal, Fixed ratio, Fixed size | How dragging sets the shape. |
Ratio width ratioWidth |
1 | 0.01 to 1000 | Width part of the fixed ratio. |
Ratio height ratioHeight |
1 | 0.01 to 1000 | Height part of the fixed ratio. |
Width sizeWidth |
64 | 1 to 16384 px | Width of the fixed size. |
Height sizeHeight |
64 | 1 to 16384 px | Height of the fixed size. |
Feather feather |
0 | 0 to 250 px | Softens the edge of the new selection. |
Elliptical marquee:
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Style style |
Normal | Normal, Fixed ratio, Fixed size | How dragging sets the shape. |
Ratio width ratioWidth |
1 | 0.01 to 1000 | Width part of the fixed ratio. |
Ratio height ratioHeight |
1 | 0.01 to 1000 | Height part of the fixed ratio. |
Width sizeWidth |
64 | 1 to 16384 px | Width of the fixed size. |
Height sizeHeight |
64 | 1 to 16384 px | Height of the fixed size. |
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. |
Limitations¶
- The rectangle always has whole-pixel edges. Feather it to soften them.
- Fixed size uses image pixels, so the box looks smaller on screen when you zoom out.