Raycaster

References
public sealed class Raycaster : IObjectStack
Type for populating images with a raycasting technique.

Constructors

Raycaster

#
public Raycaster(int width, int height, ColourShader background, IEnumerable<ShapeShaderPair> objects)
Create a new raycaster.
width (int)Target image width.
height (int)Target image height.
background (ColourShader)Background shader. If null, a transparent background will be used.
objects (IEnumerable<ShapeShaderPair>)Ordered collection of objects.

Raycaster

#
public Raycaster(int width, int height, IEnumerable<ShapeShaderPair> objects)
Create a new raycaster with a transparent background.
width (int)Target image width.
height (int)Target image height.
objects (IEnumerable<ShapeShaderPair>)Ordered collection of objects.

Fields

MaxSize

#
public const int MaxSize = 16384
Specifies the maximum linear size (in pixels) of a raycasting image.

Properties

Background

#
public ColourShader Background { get; }
Gets the background shader. This shader may be null, in which case a fully transparent background is implied.

CurrentSamplingLevel

#
public int CurrentSamplingLevel { get; }
Gets the current sampling level. Not all pixels are necessarily being sampled at this level though, only at least one of them is. Negative sampling levels indicate a coarse sampling, every (-N)th pixels.

Height

#
public int Height { get; }
Gets the height of the raycasting image.

Width

#
public int Width { get; }
Gets the width of the raycasting image.

Indexers

this[]

#
public Pixel this[int indexX, int indexY] { get; }
Gets the pixel at the given coordinates.
indexX (int)X index.
indexY (int)Y index.
Pixel at index.

this[]

#
public ShapeShaderPair this[int index] { get; }
Gets the shape+shader pair at the given index.
index (int)Index of pair.
Pair at index.

Methods

ComputeImage

#
public void ComputeImage(RaycasterSettings settings, CancellationToken token)
Start a new raycasting process.
settings (RaycasterSettings)Settings.
token (CancellationToken)Cancellation token.

ComputeImageAsync

#
public void ComputeImageAsync(RaycasterSettings settings, CancellationToken token)
Start the image computation asynchronously.
settings (RaycasterSettings)Settings.
token (CancellationToken)Cancellation token.

ContinueAndSample

#
public Color ContinueAndSample(Ray ray)
Continue an existing ray.
ray (Ray)Ray to continue.
Colour at continued ray location.
ContinueAndSample

ContinueImage

#
public void ContinueImage(RaycasterSettings settings, CancellationToken token)
Continue a finished raycasting process. This method cannot be called while a process is already running.
settings (RaycasterSettings)Settings to use.
token (CancellationToken)Cancellation token.

ContinueImageAsync

#
public void ContinueImageAsync(RaycasterSettings settings, CancellationToken token)
Continue a finished raycasting process asynchronously. This method cannot be called while a process is already running.
settings (RaycasterSettings)Settings to use.
token (CancellationToken)Cancellation token.

FirstObjectAbove

#
public int FirstObjectAbove(double x, double y, int startAt)
Find the index of the first object at the (u,v) location at or above the given layer index.
x (double)U coordinate.
y (double)V coordinate.
startAt (int)Start layer. Objects on this layer are taken into account.
The index of the first object coincident with (u,v) at or above the start layer. Or, if no object was found, -1.
FirstObjectAbove

FirstObjectBelow

#
public int FirstObjectBelow(double x, double y, int startAt)
Find the index of the first object at the (u,v) location at or below the given layer index.
x (double)U coordinate.
y (double)V coordinate.
startAt (int)Start layer. Objects on this layer are taken into account.
The index of the first object coincident with (u,v) at or below the start layer. Or, if no object was found, -1.
FirstObjectBelow

ResurrectAllPixels

#
public void ResurrectAllPixels()
Move all dead pixels back onto the alive list.

ResurrectAllPixels

#
public void ResurrectAllPixels(Func<Pixel, bool> filter)
Move all dead pixels back onto the alive list.
filter (Func<Pixel, bool>)Per pixel filter method.

Sample

#
public Color Sample(Ray ray)
Shoot a way into the object stack and evaluate the colour.
ray (Ray)Ray to shoot.
Colour at ray location.
Sample

ToBitmap

#
public Bitmap ToBitmap()
Create a bitmap from the current cache.

ToBitmap

#
public void ToBitmap(Bitmap bitmap)
Blit this raycaster into an existing bitmap. The bitmap will be locked for this procedure.
bitmap (Bitmap)Lockable bitmap with the correct dimensions.

ToBucketMap

#
public Bitmap ToBucketMap()
Create a bitmap showing the bucket occupancy.
Bucket map.

ToCompletionMap

#
public Bitmap ToCompletionMap(Gradient gradient, Color? liveColour)
Create a bitmap showing the completed pixels vs the live pixels.
gradient (Gradient)Gradient to use on dead pixels. If null, the default gradient will be used.
liveColour (Color?)Optional colour to use on live pixels. If omitted, live pixels will be mapped onto the gradient.

ToCompletionMap

#
public void ToCompletionMap(Bitmap bitmap, Gradient gradient, Color? liveColour)
Blit the raycaster live-pixel data into an existing bitmap. The bitmap will be locked for this procedure.
bitmap (Bitmap)Lockable bitmap with the correct dimensions.
gradient (Gradient)Gradient to use on dead pixels. If null, the default gradient will be used.
liveColour (Color?)Optional colour to use on live pixels. If omitted, live pixels will be mapped onto the gradient.