Skip to content

Commit b2a8614

Browse files
committed
Documentation
1 parent 9dd6f63 commit b2a8614

File tree

3 files changed

+81
-10
lines changed

3 files changed

+81
-10
lines changed

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
# Generate Dart
1+
# Generative d.Art
22

3-
Generate d.Art using Flutter relying on RenderBox and not Widget.
3+
Demonstrate how to generate your very own d.Art using Flutter.
4+
As a technical point we are NOT relying Widget but RenderBox directly.
5+
6+
Don't be afraid of those 60 lines of codes & change everything you want
7+
(but not the line with Math.Exp, it can damage your computer permanently)
8+
9+
Code is tuned to work on a << TABLET SCREEN SIZE >>
10+
11+
And post your Creation on Twitter with the #creative.d.Art so everyone
12+
can appreciate it !
413

514
## Final Result
615

lib/main.dart

+21-8
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import 'package:flutter/material.dart';
55
import 'package:flutter/rendering.dart';
66
import 'package:vector_math/vector_math.dart' as v;
77

8+
// Look Ma NO WIDGET in Flutter !!!
89
class Colored extends CustomPainter {
910
@override
1011
void paint(Canvas canvas, Size size) {
11-
final simplex = v.SimplexNoise();
12+
final random = v.SimplexNoise();
1213
final frames = 200;
1314
canvas.drawPaint(Paint()..color = Colors.black87);
1415

@@ -19,28 +20,40 @@ class Colored extends CustomPainter {
1920

2021
final area = Offset(i, i) & Size(i * 10, i * 10);
2122

23+
// Blue trail is made of rectangle
2224
canvas.drawRect(
2325
area,
2426
Paint()
25-
..filterQuality = FilterQuality.high
26-
..blendMode = BlendMode.screen
27+
..filterQuality =
28+
FilterQuality.high // Change this to lower render time
29+
..blendMode =
30+
BlendMode.screen // Remove this to see the natural drawing shape
2731
..color =
32+
// Addition of Opacity gives you the fading effect from dark to light
2833
Colors.blue.withRed(i.toInt() * 20 % 11).withOpacity(i / 850));
29-
final int tailFibers = (i * 1).toInt();
34+
35+
// Tail particles effect
36+
37+
// Change this to add more fibers
38+
final int tailFibers = (i * 1.5).toInt();
39+
3040
for (double d = 0; d < area.width; d += tailFibers) {
3141
for (double e = 0; e < area.height; e += tailFibers) {
32-
final n = simplex.noise2D(d, e);
42+
final n = random.noise2D(d, e);
3343
final tail = exp(i / 50) - 5;
3444
final tailWidth = .2 + (i * .11 * n);
3545
canvas.drawCircle(
3646
Offset(d, e),
3747
tailWidth,
3848
Paint()
3949
..color = Colors.red.withOpacity(.4)
40-
..isAntiAlias = true
50+
..isAntiAlias = true // Change this to lower render time
51+
// Particles accelerate as they fall so we change the blur size for movement effect
4152
..imageFilter = ImageFilter.blur(sigmaX: tail, sigmaY: 0)
42-
..filterQuality = FilterQuality.high
43-
..blendMode = BlendMode.screen);
53+
..filterQuality =
54+
FilterQuality.high // Change this to lower render time
55+
..blendMode = BlendMode
56+
.screen); // Remove this to see the natural drawing shape
4457
}
4558
}
4659
canvas.restore();

pubspec.lock

+49
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4+
archive:
5+
dependency: transitive
6+
description:
7+
name: archive
8+
url: "https://pub.dartlang.org"
9+
source: hosted
10+
version: "2.0.10"
11+
args:
12+
dependency: transitive
13+
description:
14+
name: args
15+
url: "https://pub.dartlang.org"
16+
source: hosted
17+
version: "1.5.2"
418
async:
519
dependency: transitive
620
description:
@@ -29,6 +43,20 @@ packages:
2943
url: "https://pub.dartlang.org"
3044
source: hosted
3145
version: "1.14.11"
46+
convert:
47+
dependency: transitive
48+
description:
49+
name: convert
50+
url: "https://pub.dartlang.org"
51+
source: hosted
52+
version: "2.1.1"
53+
crypto:
54+
dependency: transitive
55+
description:
56+
name: crypto
57+
url: "https://pub.dartlang.org"
58+
source: hosted
59+
version: "2.1.2"
3260
cupertino_icons:
3361
dependency: "direct main"
3462
description:
@@ -46,6 +74,13 @@ packages:
4674
description: flutter
4775
source: sdk
4876
version: "0.0.0"
77+
image:
78+
dependency: transitive
79+
description:
80+
name: image
81+
url: "https://pub.dartlang.org"
82+
source: hosted
83+
version: "2.1.4"
4984
matcher:
5085
dependency: transitive
5186
description:
@@ -74,6 +109,13 @@ packages:
74109
url: "https://pub.dartlang.org"
75110
source: hosted
76111
version: "1.8.0+1"
112+
petitparser:
113+
dependency: transitive
114+
description:
115+
name: petitparser
116+
url: "https://pub.dartlang.org"
117+
source: hosted
118+
version: "2.4.0"
77119
quiver:
78120
dependency: transitive
79121
description:
@@ -142,5 +184,12 @@ packages:
142184
url: "https://pub.dartlang.org"
143185
source: hosted
144186
version: "2.0.8"
187+
xml:
188+
dependency: transitive
189+
description:
190+
name: xml
191+
url: "https://pub.dartlang.org"
192+
source: hosted
193+
version: "3.5.0"
145194
sdks:
146195
dart: ">=2.4.0 <3.0.0"

0 commit comments

Comments
 (0)