TornPainterBackground constructor
TornPainterBackground()
Constuctor of the TornPainterBackground
Implementation
TornPainterBackground(
this.path,
this.width,
this.height,
Color backgroundColor,
this.hasNoise,
this.noiseColor,
this.hasShadow,
Offset shadowOffset,
this.shadowColor,
) {
shiftedPath = path.shift(shadowOffset);
paintBackground = Paint()
..color = backgroundColor
..style = PaintingStyle.fill;
if (hasNoise) {
final List<List<double>> noise = noise2(width.toInt(), height.toInt(),
noiseType: NoiseType.Perlin,
octaves: 5,
frequency: 0.75,
cellularDistanceFunction: CellularDistanceFunction.Euclidean,
cellularReturnType: CellularReturnType.CellValue);
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
// var c = (0x80 + 0x80 * noise[x][y]).floor(); // grayscale
final offset = Offset(x.toDouble(), y.toDouble());
if (!path.contains(offset)) {
continue;
}
final color = Color.fromRGBO(
noiseColor.red, noiseColor.green, noiseColor.blue, noise[x][y]);
noisePoints.putIfAbsent(color, () => []);
noisePoints[color]!.add(offset);
}
}
}
}