Graph Maker
WMG_Util Class Reference

Static utility class for performing miscellaneous functions such as data generation functions. More...

Static Public Member Functions

static float RemapFloat (float val, float start1, float end1, float start2, float end2)
 Remaps the value of a float from one range to another range. More...
 
static Vector2 RemapVec2 (float val, float start1, float end1, Vector2 start2, Vector2 end2)
 Remaps a float value to a Vector2 using a source float range and target Vector2 range. More...
 
static Sprite createSprite (int x, int y)
 
static Texture2D createTexture (int x, int y)
 
static void listChanged< T > (bool editorChange, ref WMG_List< T > w_list, ref List< T > list, bool oneValChanged, int index)
 
static void updateCacheAndFlag< T > (ref T cache, T val, ref bool flag)
 Update the value of a cached value, and set bool flag to true if the cache was different. More...
 
static void updateCacheAndFlagList< T > (ref List< T > cache, List< T > val, ref bool flag)
 Cache the values of a list, and set bool flag to true if the cache was different. More...
 
static void SwapVals< T > (ref T val1, ref T val2)
 Swaps one value with another value. More...
 
static void SwapValsList< T > (ref List< T > val1, ref List< T > val2)
 Swaps one list with another list. More...
 
static List< Vector2 > GenLinear (int numPoints, float minX, float maxX, float a, float b)
 Generate data of the form Y = aX + b More...
 
static List< Vector2 > GenQuadratic (int numPoints, float minX, float maxX, float a, float b, float c)
 Generate data of the form Y = aX^2 + bX + c More...
 
static List< Vector2 > GenExponential (int numPoints, float minX, float maxX, float a, float b, float c)
 Generate data of the form Y = ab^X + c More...
 
static List< Vector2 > GenLogarithmic (int numPoints, float minX, float maxX, float a, float b, float c)
 Generate data of the form Y = a * log base b of X + c More...
 
static List< Vector2 > GenCircular (int numPoints, float a, float b, float c, float degreeOffset=0)
 Generate data of the form c^2 = (X - a)^2 * (Y - b)^2. More...
 
static List< Vector2 > GenRadar (List< float > data, float a, float b, float degreeOffset)
 Generates a list of Vector2 used in a Radar graph. More...
 
static List< Vector2 > GenRandomXY (int numPoints, float minX, float maxX, float minY, float maxY)
 Generates a list of Vector2 where both x and y are random. More...
 
static List< Vector2 > GenRandomY (int numPoints, float minX, float maxX, float minY, float maxY)
 Generates a list of Vector2 where x increases uniformly and y is random. More...
 
static List< float > GenRandomList (int numPoints, float min, float max)
 Generates a list of random values. More...
 
static void updateBandColors (ref Color[] colors, float maxSize, float inner, float outer, bool antiAliasing, float antiAliasingStrength, Color[] orig=null)
 For filling texture based on a circular band (e.g. More...
 
static bool LineIntersectsCircle (float x0, float y0, float x1, float y1, float x2, float y2, float r)
 Returns true if a line segment intersect a circle. More...
 
static bool LineSegmentsIntersect (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y, float p4x, float p4y)
 Returns true if line segment (p1x,p1y) - (p2x,p2y) intersects line segment (p3x,p3y) - (p4x,p4y) More...
 
static string FormatValueLabel (string text, WMG_Enums.labelTypes labelType, float value, float percent, int numDecimals)
 Returns a string given an input string / input float and some formatting options. More...
 
static Vector2 ExpressionEvaluator (List< string > rpnString, float x)
 Evaluate arbitrary expression of the form (y = ...) for a given input value of x (expression doesn't have to have an x). More...
 
static List< string > ShuntingYardAlgorithm (string input)
 Convert space delimited infix expression string to reverse polish notation More...
 

Detailed Description

Static utility class for performing miscellaneous functions such as data generation functions.

Member Function Documentation

◆ createSprite()

static Sprite WMG_Util.createSprite ( int  x,
int  y 
)
static

◆ createTexture()

static Texture2D WMG_Util.createTexture ( int  x,
int  y 
)
static

◆ ExpressionEvaluator()

static Vector2 WMG_Util.ExpressionEvaluator ( List< string >  rpnString,
float  x 
)
static

Evaluate arbitrary expression of the form (y = ...) for a given input value of x (expression doesn't have to have an x).

Input expression must be in reverse polish notation with each token of the expression put in a List<string>

Returns
The result as the point (x, y).
Parameters
rpnStringReverse Polish Notation (RPN) string.
xThe x coordinate.

◆ FormatValueLabel()

static string WMG_Util.FormatValueLabel ( string  text,
WMG_Enums.labelTypes  labelType,
float  value,
float  percent,
int  numDecimals 
)
static

Returns a string given an input string / input float and some formatting options.

Returns
The value label.
Parameters
textText.
labelTypeLabel type.
valueValue.
percentPercent.
numDecimalsNumber decimals.

◆ GenCircular()

static List<Vector2> WMG_Util.GenCircular ( int  numPoints,
float  a,
float  b,
float  c,
float  degreeOffset = 0 
)
static

Generate data of the form c^2 = (X - a)^2 * (Y - b)^2.

Can be used to generate shapes as well (e.g. 3 points for triangle).

Parameters
numPointsNumber points.
aThe alpha component.
bThe blue component.
cC.
degreeOffsetDegree offset.

◆ GenExponential()

static List<Vector2> WMG_Util.GenExponential ( int  numPoints,
float  minX,
float  maxX,
float  a,
float  b,
float  c 
)
static

Generate data of the form Y = ab^X + c

Parameters
numPointsNumber points.
minXMinimum x.
maxXMax x.
aThe alpha component.
bThe blue component.
cC.

◆ GenLinear()

static List<Vector2> WMG_Util.GenLinear ( int  numPoints,
float  minX,
float  maxX,
float  a,
float  b 
)
static

Generate data of the form Y = aX + b

Returns
The linear.
Parameters
numPointsNumber points.
minXMinimum x.
maxXMax x.
aThe alpha component.
bThe blue component.

◆ GenLogarithmic()

static List<Vector2> WMG_Util.GenLogarithmic ( int  numPoints,
float  minX,
float  maxX,
float  a,
float  b,
float  c 
)
static

Generate data of the form Y = a * log base b of X + c

Parameters
numPointsNumber points.
minXMinimum x.
maxXMax x.
aThe alpha component.
bThe blue component.
cC.

◆ GenQuadratic()

static List<Vector2> WMG_Util.GenQuadratic ( int  numPoints,
float  minX,
float  maxX,
float  a,
float  b,
float  c 
)
static

Generate data of the form Y = aX^2 + bX + c

Parameters
numPointsNumber points.
minXMinimum x.
maxXMax x.
aThe alpha component.
bThe blue component.
cC.

◆ GenRadar()

static List<Vector2> WMG_Util.GenRadar ( List< float >  data,
float  a,
float  b,
float  degreeOffset 
)
static

Generates a list of Vector2 used in a Radar graph.

Parameters
dataData.
aThe alpha component.
bThe blue component.
degreeOffsetDegree offset.

◆ GenRandomList()

static List<float> WMG_Util.GenRandomList ( int  numPoints,
float  min,
float  max 
)
static

Generates a list of random values.

Returns
The random list.
Parameters
numPointsNumber points.
minMinimum.
maxMax.

◆ GenRandomXY()

static List<Vector2> WMG_Util.GenRandomXY ( int  numPoints,
float  minX,
float  maxX,
float  minY,
float  maxY 
)
static

Generates a list of Vector2 where both x and y are random.

Parameters
numPointsNumber points.
minXMinimum x.
maxXMax x.
minYMinimum y.
maxYMax y.

◆ GenRandomY()

static List<Vector2> WMG_Util.GenRandomY ( int  numPoints,
float  minX,
float  maxX,
float  minY,
float  maxY 
)
static

Generates a list of Vector2 where x increases uniformly and y is random.

Parameters
numPointsNumber points.
minXMinimum x.
maxXMax x.
minYMinimum y.
maxYMax y.

◆ LineIntersectsCircle()

static bool WMG_Util.LineIntersectsCircle ( float  x0,
float  y0,
float  x1,
float  y1,
float  x2,
float  y2,
float  r 
)
static

Returns true if a line segment intersect a circle.

Line segment is (x0, y0) to (x1, y1). Circle is centered at (x2, y2) with radius r

Returns
true, if circle and line intersect, false otherwise.
Parameters
x0X0.
y0Y0.
x1The first x value.
y1The first y value.
x2The second x value.
y2The second y value.
rThe red component.

◆ LineSegmentsIntersect()

static bool WMG_Util.LineSegmentsIntersect ( float  p1x,
float  p1y,
float  p2x,
float  p2y,
float  p3x,
float  p3y,
float  p4x,
float  p4y 
)
static

Returns true if line segment (p1x,p1y) - (p2x,p2y) intersects line segment (p3x,p3y) - (p4x,p4y)

Returns
true, if line and line intersect, false otherwise.
Parameters
p1xP1x.
p1yP1y.
p2xP2x.
p2yP2y.
p3xP3x.
p3yP3y.
p4xP4x.
p4yP4y.

◆ listChanged< T >()

static void WMG_Util.listChanged< T > ( bool  editorChange,
ref WMG_List< T >  w_list,
ref List< T >  list,
bool  oneValChanged,
int  index 
)
static

◆ RemapFloat()

static float WMG_Util.RemapFloat ( float  val,
float  start1,
float  end1,
float  start2,
float  end2 
)
static

Remaps the value of a float from one range to another range.

Returns
The float.
Parameters
valValue.
start1Start1.
end1End1.
start2Start2.
end2End2.

◆ RemapVec2()

static Vector2 WMG_Util.RemapVec2 ( float  val,
float  start1,
float  end1,
Vector2  start2,
Vector2  end2 
)
static

Remaps a float value to a Vector2 using a source float range and target Vector2 range.

Returns
The vec2.
Parameters
valValue.
start1Start1.
end1End1.
start2Start2.
end2End2.

◆ ShuntingYardAlgorithm()

static List<string> WMG_Util.ShuntingYardAlgorithm ( string  input)
static

Convert space delimited infix expression string to reverse polish notation

Returns
The yard algorithm.
Parameters
inputInput.

◆ SwapVals< T >()

static void WMG_Util.SwapVals< T > ( ref T  val1,
ref T  val2 
)
static

Swaps one value with another value.

Parameters
val1Val1.
val2Val2.
Template Parameters
TThe 1st type parameter.

◆ SwapValsList< T >()

static void WMG_Util.SwapValsList< T > ( ref List< T >  val1,
ref List< T >  val2 
)
static

Swaps one list with another list.

Parameters
val1Val1.
val2Val2.
Template Parameters
TThe 1st type parameter.

◆ updateBandColors()

static void WMG_Util.updateBandColors ( ref Color []  colors,
float  maxSize,
float  inner,
float  outer,
bool  antiAliasing,
float  antiAliasingStrength,
Color []  orig = null 
)
static

For filling texture based on a circular band (e.g.

doughnut defined by inner and outer radii)

Parameters
colorsColors.
maxSizeMax size.
innerInner.
outerOuter.
antiAliasingIf set to true anti aliasing.
antiAliasingStrengthAnti aliasing strength.
origOriginal.

◆ updateCacheAndFlag< T >()

static void WMG_Util.updateCacheAndFlag< T > ( ref T  cache,
val,
ref bool  flag 
)
static

Update the value of a cached value, and set bool flag to true if the cache was different.

Parameters
cacheCache.
valValue.
flagFlag.
Template Parameters
TThe 1st type parameter.

◆ updateCacheAndFlagList< T >()

static void WMG_Util.updateCacheAndFlagList< T > ( ref List< T >  cache,
List< T >  val,
ref bool  flag 
)
static

Cache the values of a list, and set bool flag to true if the cache was different.

Parameters
cacheCache.
valValue.
flagFlag.
Template Parameters
TThe 1st type parameter.

The documentation for this class was generated from the following file: