DepthSurface¶
Namespace Nfty.Core.Editing in assembly Nfty.Core.
The surface the depth tools edit: one DepthPixel per art pixel, held beside a copy of the art that says which pixels are solid and which share a color.
Remarks¶
Depth belongs to solid pixels only — a transparent or partially transparent pixel has no body to give thickness to — so DepthSurface.Set() ignores them and a stored map's bytes under them are dropped on load. The alpha members of IEditSurface<TPixel> are inert (ruling 1): a depth pixel has no alpha, so DepthSurface.AlphaOf() is always opaque and DepthSurface.WithAlpha() is the identity, which keeps the opacity lock a no-op here rather than a rule to keep in step.
Constructors¶
DepthSurface(Image<Rgba32>, DepthMap?)¶
Builds the surface for an image and the depth it already carries.
Parameters
art(Image<Rgba32>) - The finished art; copied, so the caller keeps ownership.stored(DepthMap?) - The layer's stored depth, or null for flat paper.
Exceptions
ArgumentException-storedis another size than the art.
Properties¶
Height¶
Height in pixels.
PartialCount¶
Pixels with partial alpha, which cannot be risen into a solid.
SolidCount¶
Pixels that are fully opaque, and so carry depth.
Width¶
Width in pixels.
Methods¶
AlphaOf(DepthPixel)¶
The alpha channel of a pixel in this surface's format.
Parameters
pixel(DepthPixel) - The pixel to read.
Returns. Alpha, 0-255.
ArtAt(int, int)¶
The art pixel at a coordinate, in bounds.
Parameters
x(int) - Column.y(int) - Row.
Returns. The art color.
Get(int, int)¶
Reads one pixel. The coordinate must be in bounds.
Parameters
x(int) - Column.y(int) - Row.
Returns. The stored pixel.
Histogram()¶
Solid pixels counted by total thickness (1 + front + back).
Returns. Buckets ascending by thickness.
InBounds(int, int)¶
Whether a coordinate is inside the surface.
Parameters
x(int) - Column.y(int) - Row.
Returns. True when the pixel exists.
IsSolid(int, int)¶
Whether a pixel is fully opaque. Out of bounds is not solid.
Parameters
x(int) - Column.y(int) - Row.
Returns. True for a solid pixel.
Overwrite(DepthMap?)¶
Replaces the whole depth with a stored map, in place: every solid pixel takes the map's pair, non-solid pixels stay 0. The instance is unchanged, so references to it stay valid.
Parameters
map(DepthMap?) - The depth to take, or null for flat paper (0/0 everywhere).
Exceptions
ArgumentException-mapis another size than the surface.
SameColorRegion(int, int)¶
The 4-connected run of solid pixels with exactly the seed's art color.
Parameters
x(int) - Seed column.y(int) - Seed row.
Returns. The region; empty when the seed is not solid.
SameDepthAs(DepthMap?)¶
Whether this surface's depth equals a stored map, absent counting as all zero.
Parameters
other(DepthMap?) - The stored map, or null for flat.
Returns. True when the bytes agree.
Set(int, int, DepthPixel)¶
Writes a pixel's depth. Out-of-bounds and non-solid pixels are ignored: transparent pixels have no depth.
Parameters
x(int) - Column.y(int) - Row.pixel(DepthPixel) - The depth to store.
Summary()¶
What the depth looks like overall.
Returns. Empty, paper, uniform (with its depth) or varied.
TakeDirty()¶
The bounding rectangle of every pixel whose depth CHANGED since the last call (a write of the value a pixel already held changes nothing), and forgets it. A derived view of this surface (the combined stack of a recipe) recomputes just that rectangle.
Returns. The rectangle, or null when nothing changed.
ToDepthMap()¶
The depth as a map to store.
Returns. Null when every solid pixel is 0 front and 0 back, so flat has one spelling: absent.
WithAlpha(DepthPixel, byte)¶
The same pixel with its alpha replaced and every other channel untouched.
Parameters
pixel(DepthPixel) - The pixel to rewrite.alpha(byte) - The alpha it should carry.
Returns. A pixel identical to pixel apart from its alpha.