Skip to content

Algorithms Class

Provides a few minor helper methods related to filling.

C#
public static class Algorithms

Inheritance object

FloodFill<TNode>(TNode, Func<TNode, bool>, Action<TNode>, Func<TNode, NodeConnections<TNode>>)

Section titled “FloodFill<TNode>(TNode, Func<TNode, bool>, Action<TNode>, Func<TNode, NodeConnections<TNode>>)”

A very slow 4-way fill algorithm to change items from one type to another.

C#
public static void FloodFill<TNode>(TNode node, Func<TNode, bool> shouldNodeChange, Action<TNode> changeNode, Func<TNode, Algorithms.NodeConnections<TNode>> getNodeConnections)

node TNode
The item to change.

shouldNodeChange Func<TNode, bool>
Determines if the node should change.

changeNode Action<TNode>
After it is determined if the node should change, this changes the node.

getNodeConnections Func<TNode, Algorithms.NodeConnections<TNode>>
Gets any other nodes connected to this node.

GradientFill(Point, Point, int, int, Rectangle, Gradient, Action<int, int, Color>)

Section titled “GradientFill(Point, Point, int, int, Rectangle, Gradient, Action<int, int, Color>)”

Processes an area and applies a gradient calculation to each part of the area.

C#
public static void GradientFill(Point cellSize, Point position, int strength, int angle, Rectangle area, Gradient gradient, Action<int, int, Color> applyAction)

cellSize SadRogue.Primitives.Point
The size of an individual cell. Makes the angle uniform.

position SadRogue.Primitives.Point
The center of the gradient.

strength int
The width of the gradient spread.

angle int
The angle to apply the gradient.

area SadRogue.Primitives.Rectangle
The area to calculate.

gradient SadRogue.Primitives.Gradient
The color gradient to fill with.

applyAction Action<int, int, Color>
The callback called for each part of the area.