Pythagoras tree: Difference between revisions
→Drawing in Flutter: refactoring
m (→Drawing in Flutter: mini refactoring) |
(→Drawing in Flutter: refactoring) |
||
Line 476:
@override
Widget build(BuildContext context)
child: CustomPaint(painter: TreePainter(), size: const Size(2400, 1600)));
),▼
}
Line 489 ⟶ 483:
@override
void paint(Canvas canvas, Size size) {
canvas.drawColor(Colors.white, BlendMode.src);▼
final stroke = Paint()
..style = PaintingStyle.stroke
..strokeWidth = 0.9
..color = Colors.white;
final fill = Paint()..style = PaintingStyle.fill;
▲ canvas.drawColor(Colors.white, BlendMode.src);
const halfBase = Offset(200, 0);
var basis = [(size.bottomCenter(-halfBase), size.bottomCenter(halfBase))];
for (var lvl = 0; lvl < 12; lvl++) {
final path = Path();
Line 503 ⟶ 497:
basis = [];
for (var (a, b) in basis0) {
final v = Offset((b
final
final e =
basis.addAll([(c, e), (e, d)]);
path.addPolygon([a, c, e, d, c, d, b], true);
}
rg(int step) => (80 + (lvl - 2) * step) & 255;
}
}
|