Empeld
Empeld plugin documentation.
pluginbase.Helpers.Data.GradientBrush Class Reference
Inheritance diagram for pluginbase.Helpers.Data.GradientBrush:
pluginbase.Helpers.Data.IBrush

Public Member Functions

 GradientBrush (Vector2 pt1, Rgba col1, Vector2 pt2, Rgba col2)
 
Rgba GetColor (float x, float y)
 

Properties

Rgba Default [get]
 
- Properties inherited from pluginbase.Helpers.Data.IBrush
Rgba Default [get]
 

Constructor & Destructor Documentation

◆ GradientBrush()

pluginbase.Helpers.Data.GradientBrush.GradientBrush ( Vector2  pt1,
Rgba  col1,
Vector2  pt2,
Rgba  col2 
)
16  {
17  _start = pt1;
18  _startCol = col1;
19  _end = pt2;
20  _endCol = col2;
21 
22  _vec = _end - _start;
23  _coeff1 = _vec.X * _start.X + _vec.Y * _start.Y;
24  _coeff2 = _vec.X * _end.X + _vec.Y * _end.Y;
25  }

Member Function Documentation

◆ GetColor()

Rgba pluginbase.Helpers.Data.GradientBrush.GetColor ( float  x,
float  y 
)

Implements pluginbase.Helpers.Data.IBrush.

28  {
29  float c = _vec.X * x + _vec.Y * y;
30  if (c <= _coeff1) return _startCol;
31  if (c >= _coeff2) return _endCol;
32  return (_startCol * (_coeff2 - c) + _endCol * (c - _coeff1)) / (_coeff2 - _coeff1);
33  }

Property Documentation

◆ Default

Rgba pluginbase.Helpers.Data.GradientBrush.Default
get

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