Detailed Description

Performs rasterisation scanning of glyphs/ vectors.

Inheritance diagram for Blaze.Scanner:
Blaze.PointReceiver

Public Member Functions

void Start ()
 Called automatically when the first vector is rasterized. More...
 
void CreateDistanceCache ()
 
void MoveTo (float x, float y)
 
void AddPoint (float x, float y)
 Adds the given point as a point on our vector. Note that it's relative at this point. More...
 
void ReindexDistanceCache ()
 Clears out all node entries in the distance cache. More...
 
void ClearDistanceCache ()
 Clears out all node entries in the distance cache. More...
 
bool Rasterise (VectorPath glyph, Color32[] atlasPixels, int atlasWidth, int baseIndex, int width, int height, float hOffset, float vOffset, Color32 fill, bool clear)
 Rasterises a generic vector. More...
 

Public Attributes

int BlurSpread =10
 The size of the SDF "blur" (distance field) in pixels around each vector. More...
 
float ScalarX =1f
 Read only. Use Scale or ScaleX. A scalar value applied to all vectors rendered by this scanner. More...
 
float ScalarY =1f
 Read only. Use Scale or ScaleX. A scalar value applied to all vectors rendered by this scanner. More...
 
float VerticalOffset
 A vertical offset value applied to each point. Used for example on glyphs which extend below the baseline. More...
 
float HorizontalOffset
 A horizontal offset value applied to each point. Used for example on glyphs which are offset and would otherwise waste space. More...
 
bool RequiresStart =true
 True if this scanner needs some values to be setup. Set this true if you e.g. change the blur spread. More...
 

Package Attributes

float RawSampleDistance
 The distance between each row of pixels. Set automatically. More...
 
const int MaxPoolCount =50
 The max pixel count in the pool. More...
 
int PooledPixels
 The number of pixels in the pool. More...
 
DistanceCacheSquare[] DistanceCache
 Shared pool of vector verts. More...
 
int DistanceCacheWidth
 The width of the distance cache. More...
 
int DistanceCacheHeight
 The height of the distance cache. More...
 
ScannerPixel FirstPooled
 Shared pool of scanner pixels. More...
 

Properties

float SampleDistance [get, set]
 The distance between each row of pixels. Set automatically. More...
 
int SDFSize [get, set]
 Changes the "spread" of SDF rastered vectors. More...
 
bool SDF [get, set]
 Change this scanners draw mode. Defaults to SDF draw mode. More...
 
float ScaleY [get, set]
 The scale applied to all vectors rendered with this scanner. More...
 
float ScaleX [get, set]
 The scale applied to all vectors rendered with this scanner. More...
 
float Scale [get, set]
 The scale applied to all vectors rendered with this scanner. More...
 
int DrawHeight [get, set]
 Change the SDF default draw height of the scanner. More...
 
- Properties inherited from Blaze.PointReceiver
float SampleDistance [get, set]
 

Private Member Functions

void AddPixel (float x, int y)
 Adds a given pixel to the scanline buffer. More...
 

Private Attributes

bool Blurred =true
 True if the raster result is "blurred" (actually an SDF). More...
 
int DoubleBlurSpread
 Computed when the first vector is rasterised. BlurSpread * 2. More...
 
int HalfBlurSpread
 Computed when the first vector is rasterised. BlurSpread / 2. More...
 
ScannerScanLine[] ScanLineBuffer
 A globally shared scan line buffer. More...
 
float MaxDistance
 Used in SDF rendering. The max distance a pixel can be from the outline. Same as BlurSpread, but as a float. More...
 
float MaxDistanceSquared
 The square of the maximum distance. Used in SDF rendering. More...
 
float DistanceAdjuster
 Used in SDF rendering. Maps a distance value to being in 0-255 byte range. More...
 
int RawSDFSize
 The raw spread of SDF rastered vectors. See SDFSize. More...
 
bool WentUp
 Used whilst adding points to scanlines. Did we last go up or down. More...
 
int MoveToY
 Used whilst adding points to scanlines. The Y line that was moved to. More...
 
int PreviousY
 Used whilst adding points to scanlines. The previous visited line. More...
 
int LineChangeY =-1
 The cached "line change" point's X value. More...
 
float LineChangeX
 The cached "line change" point's X value. The line change point is essentially the first point that is not on the moveTo line. More...
 
bool LineChangeWentUp
 Did the line change point go up? More...
 

Member Function Documentation

void Blaze.Scanner.AddPixel ( float  x,
int  y 
)
inlineprivate

Adds a given pixel to the scanline buffer.

void Blaze.Scanner.AddPoint ( float  x,
float  y 
)
inline

Adds the given point as a point on our vector. Note that it's relative at this point.

Implements Blaze.PointReceiver.

void Blaze.Scanner.ClearDistanceCache ( )
inline

Clears out all node entries in the distance cache.

void Blaze.Scanner.CreateDistanceCache ( )
inline
void Blaze.Scanner.MoveTo ( float  x,
float  y 
)
inline

Implements Blaze.PointReceiver.

bool Blaze.Scanner.Rasterise ( VectorPath  glyph,
Color32[]  atlasPixels,
int  atlasWidth,
int  baseIndex,
int  width,
int  height,
float  hOffset,
float  vOffset,
Color32  fill,
bool  clear 
)
inline

Rasterises a generic vector.

void Blaze.Scanner.ReindexDistanceCache ( )
inline

Clears out all node entries in the distance cache.

void Blaze.Scanner.Start ( )
inline

Called automatically when the first vector is rasterized.

Member Data Documentation

bool Blaze.Scanner.Blurred =true
private

True if the raster result is "blurred" (actually an SDF).

int Blaze.Scanner.BlurSpread =10

The size of the SDF "blur" (distance field) in pixels around each vector.

float Blaze.Scanner.DistanceAdjuster
private

Used in SDF rendering. Maps a distance value to being in 0-255 byte range.

DistanceCacheSquare [] Blaze.Scanner.DistanceCache
package

Shared pool of vector verts.

Shared grid-cache. It's used for rapid distance checking. It's a 2D grid. x + (width*y).

int Blaze.Scanner.DistanceCacheHeight
package

The height of the distance cache.

int Blaze.Scanner.DistanceCacheWidth
package

The width of the distance cache.

int Blaze.Scanner.DoubleBlurSpread
private

Computed when the first vector is rasterised. BlurSpread * 2.

ScannerPixel Blaze.Scanner.FirstPooled
package

Shared pool of scanner pixels.

int Blaze.Scanner.HalfBlurSpread
private

Computed when the first vector is rasterised. BlurSpread / 2.

float Blaze.Scanner.HorizontalOffset

A horizontal offset value applied to each point. Used for example on glyphs which are offset and would otherwise waste space.

bool Blaze.Scanner.LineChangeWentUp
private

Did the line change point go up?

float Blaze.Scanner.LineChangeX
private

The cached "line change" point's X value. The line change point is essentially the first point that is not on the moveTo line.

int Blaze.Scanner.LineChangeY =-1
private

The cached "line change" point's X value.

float Blaze.Scanner.MaxDistance
private

Used in SDF rendering. The max distance a pixel can be from the outline. Same as BlurSpread, but as a float.

float Blaze.Scanner.MaxDistanceSquared
private

The square of the maximum distance. Used in SDF rendering.

const int Blaze.Scanner.MaxPoolCount =50
package

The max pixel count in the pool.

int Blaze.Scanner.MoveToY
private

Used whilst adding points to scanlines. The Y line that was moved to.

int Blaze.Scanner.PooledPixels
package

The number of pixels in the pool.

int Blaze.Scanner.PreviousY
private

Used whilst adding points to scanlines. The previous visited line.

float Blaze.Scanner.RawSampleDistance
package

The distance between each row of pixels. Set automatically.

int Blaze.Scanner.RawSDFSize
private

The raw spread of SDF rastered vectors. See SDFSize.

bool Blaze.Scanner.RequiresStart =true

True if this scanner needs some values to be setup. Set this true if you e.g. change the blur spread.

float Blaze.Scanner.ScalarX =1f

Read only. Use Scale or ScaleX. A scalar value applied to all vectors rendered by this scanner.

float Blaze.Scanner.ScalarY =1f

Read only. Use Scale or ScaleX. A scalar value applied to all vectors rendered by this scanner.

ScannerScanLine [] Blaze.Scanner.ScanLineBuffer
private

A globally shared scan line buffer.

float Blaze.Scanner.VerticalOffset

A vertical offset value applied to each point. Used for example on glyphs which extend below the baseline.

bool Blaze.Scanner.WentUp
private

Used whilst adding points to scanlines. Did we last go up or down.

Property Documentation

int Blaze.Scanner.DrawHeight
getset

Change the SDF default draw height of the scanner.

float Blaze.Scanner.SampleDistance
getset

The distance between each row of pixels. Set automatically.

float Blaze.Scanner.Scale
getset

The scale applied to all vectors rendered with this scanner.

float Blaze.Scanner.ScaleX
getset

The scale applied to all vectors rendered with this scanner.

float Blaze.Scanner.ScaleY
getset

The scale applied to all vectors rendered with this scanner.

bool Blaze.Scanner.SDF
getset

Change this scanners draw mode. Defaults to SDF draw mode.

int Blaze.Scanner.SDFSize
getset

Changes the "spread" of SDF rastered vectors.