# new DensityFunction2D(data)
Creates a new DensityFunction2D instance
Parameters:
Name | Type | Description |
---|---|---|
data |
DensityFunction2D
|
Array.<Array.<number>>
|
Either an existing DensityFunction2D or a 2D array of density values |
Classes
Members
Methods
# assignDensity(stipples, voronoi) → {Array.<Stipple>}
Assigns density values to stipples based on their Voronoi cells
Parameters:
Name | Type | Description |
---|---|---|
stipples |
Array.<Stipple>
|
Array of stipples |
voronoi |
Voronoi.<Stipple>
|
Voronoi diagram |
Updated stipples with assigned densities
Array.<Stipple>
# createMachBanding2D(quantisationopt, weightopt, blurRadiusopt) → {DensityFunction2D}
Creates a Mach banding effect on the density function
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
quantisation |
Array.<number>
|
<optional> |
Quantization levels |
|
weight |
number
|
<optional> |
0.5 | Blending weight |
blurRadius |
number
|
<optional> |
4 | Blur radius |
New density function with Mach banding
DensityFunction2D
# densityAt(x, y) → {number}
Gets density value at specific coordinates
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
X coordinate |
y |
number
|
Y coordinate |
Density value at (x,y)
number
# densityInPolygon() → {number}
Calculates total density within a polygon
Parameters:
Type | Description |
---|---|
Total density within polygon
number
# float2DtoImage(data) → {ImageData}
Converts 2D float array to ImageData
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<Array.<number>>
|
2D array of float values |
Converted image data
ImageData
# getBoundingBoxOfPolygon() → {Object}
Gets bounding box of a polygon
Parameters:
Type | Description |
---|---|
Bounding box coordinates
Object
# image2DtoFloat(imageData) → {Array.<number>}
Converts ImageData to float array
Parameters:
Name | Type | Description |
---|---|---|
imageData |
ImageData
|
Image data to convert |
Array of float values
Array.<number>
# static createQuantisation(num) → {Array.<number>}
Creates a quantization of the range [0, 1]
Parameters:
Name | Type | Description |
---|---|---|
num |
number
|
Number of quantization steps |
Array of quantization values
Array.<number>
# static quantise(array, quantisation) → {Array.<number>}
Quantizes an array of numbers using given quantization levels
Parameters:
Name | Type | Description |
---|---|---|
array |
Array.<number>
|
Array to quantize |
quantisation |
Array.<number>
|
Quantization levels |
Quantized array
Array.<number>