IEditSurface<TPixel>¶
Namespace Nfty.Core.Editing in assembly Nfty.Core.
A fixed-size, randomly-addressable raster the edit commands paint on, generic over the pixel it stores: ValueMap supplies GrayPixel, ColorMap supplies Rgba32. The commands hold geometry only — every "what does this pixel become" decision travels as a TPixel, so one implementation of disc stamping, shape rasterising, region scanning and the undo snapshot serves both surfaces.
Type parameters
TPixel- The pixel this surface stores.
Remarks¶
IEditSurface<TPixel>.AlphaOf() and IEditSurface<TPixel>.WithAlpha() are here rather than on the pixel because Rgba32 is ImageSharp's type and cannot be made to implement an interface of ours. They carry format knowledge only — where this surface's pixel keeps its alpha — never policy: the opacity lock's rule lives once in RegionEditCommand<TPixel>, so the two surfaces have nothing to keep in step and nothing to drift apart on.
Properties¶
Height¶
Height in pixels.
Width¶
Width in pixels.
Methods¶
AlphaOf(TPixel)¶
The alpha channel of a pixel in this surface's format.
Parameters
pixel(TPixel) - The pixel to read.
Returns. Alpha, 0-255.
Get(int, int)¶
Reads one pixel. The coordinate must be in bounds.
Parameters
x(int) - Column.y(int) - Row.
Returns. The stored pixel.
InBounds(int, int)¶
Whether a coordinate is inside the surface.
Parameters
x(int) - Column.y(int) - Row.
Returns. True when the pixel exists.
Set(int, int, TPixel)¶
Writes one pixel. Out-of-bounds coordinates are ignored, so a brush may run off the edge without the caller clipping first.
Parameters
x(int) - Column.y(int) - Row.pixel(TPixel) - The pixel to store.
WithAlpha(TPixel, byte)¶
The same pixel with its alpha replaced and every other channel untouched.
Parameters
pixel(TPixel) - The pixel to rewrite.alpha(byte) - The alpha it should carry.
Returns. A pixel identical to pixel apart from its alpha.