Skip to content

MoveSelection<TPixel>

Namespace Nfty.Core.Editing in assembly Nfty.Core.

public sealed class MoveSelection<TPixel> : RegionEditCommand<TPixel>

Moves a rectangular selection by (dx, dy) on a single flat raster: the source area is cleared to transparent and its pixels are re-stamped at the shifted position. Later writes win, so a pixel that is both cleared and re-stamped ends up stamped.

Type parameters

  • TPixel - The pixel the target surface stores.

Remarks

The re-stamped pixels are copied from the surface, so they arrive carrying whatever alpha they already had — an imported soft edge included. Under OpacityLock.Locked the base snaps them like any other painted pixel: moving a soft-edged sprite hardens its edge, which is the lock doing what it says rather than a gap in it.

Constructors

MoveSelection(PixelRect, int, int, OpacityLock)

public MoveSelection(PixelRect source, int dx, int dy, OpacityLock opacity = OpacityLock.Locked);

Moves a rectangular selection, clearing what it left behind.

Parameters

  • source (PixelRect) - The region to move.
  • dx (int) - Horizontal offset in pixels.
  • dy (int) - Vertical offset in pixels.
  • opacity (OpacityLock) - Whether partial alpha is admitted on the moved pixels; locked by default.

Methods

ComputePixels(IEditSurface<TPixel>)

protected override IReadOnlyList<(int, int, TPixel)> ComputePixels(IEditSurface<TPixel> surface);

Target pixels and their new values. Only in-bounds pixels, each coordinate at most once; computed before any mutation.

Parameters

  • surface (IEditSurface<TPixel>) - The surface being edited, for reading the pixels the edit depends on.

Returns. The pixels to write, before the opacity lock is applied to them.