Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Solido committed Sep 3, 2019
1 parent 9dd6f63 commit b2a8614
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 10 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Generate Dart
# Generative d.Art

Generate d.Art using Flutter relying on RenderBox and not Widget.
Demonstrate how to generate your very own d.Art using Flutter.
As a technical point we are NOT relying Widget but RenderBox directly.

Don't be afraid of those 60 lines of codes & change everything you want
(but not the line with Math.Exp, it can damage your computer permanently)

Code is tuned to work on a << TABLET SCREEN SIZE >>

And post your Creation on Twitter with the #creative.d.Art so everyone
can appreciate it !

## Final Result

Expand Down
29 changes: 21 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:vector_math/vector_math.dart' as v;

// Look Ma NO WIDGET in Flutter !!!
class Colored extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final simplex = v.SimplexNoise();
final random = v.SimplexNoise();
final frames = 200;
canvas.drawPaint(Paint()..color = Colors.black87);

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

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

// Blue trail is made of rectangle
canvas.drawRect(
area,
Paint()
..filterQuality = FilterQuality.high
..blendMode = BlendMode.screen
..filterQuality =
FilterQuality.high // Change this to lower render time
..blendMode =
BlendMode.screen // Remove this to see the natural drawing shape
..color =
// Addition of Opacity gives you the fading effect from dark to light
Colors.blue.withRed(i.toInt() * 20 % 11).withOpacity(i / 850));
final int tailFibers = (i * 1).toInt();

// Tail particles effect

// Change this to add more fibers
final int tailFibers = (i * 1.5).toInt();

for (double d = 0; d < area.width; d += tailFibers) {
for (double e = 0; e < area.height; e += tailFibers) {
final n = simplex.noise2D(d, e);
final n = random.noise2D(d, e);
final tail = exp(i / 50) - 5;
final tailWidth = .2 + (i * .11 * n);
canvas.drawCircle(
Offset(d, e),
tailWidth,
Paint()
..color = Colors.red.withOpacity(.4)
..isAntiAlias = true
..isAntiAlias = true // Change this to lower render time
// Particles accelerate as they fall so we change the blur size for movement effect
..imageFilter = ImageFilter.blur(sigmaX: tail, sigmaY: 0)
..filterQuality = FilterQuality.high
..blendMode = BlendMode.screen);
..filterQuality =
FilterQuality.high // Change this to lower render time
..blendMode = BlendMode
.screen); // Remove this to see the natural drawing shape
}
}
canvas.restore();
Expand Down
49 changes: 49 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -29,6 +43,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -46,6 +74,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -74,6 +109,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
Expand Down Expand Up @@ -142,5 +184,12 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
sdks:
dart: ">=2.4.0 <3.0.0"

0 comments on commit b2a8614

Please sign in to comment.