
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
87 lines
2.4 KiB
Dart
87 lines
2.4 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class _MultiplyPainter extends CustomPainter {
|
|
_MultiplyPainter(this._color);
|
|
|
|
final Color _color;
|
|
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
const int xDenominator = 2;
|
|
const int yDenominator = 10;
|
|
final double width = size.width / xDenominator;
|
|
final double height = size.height / yDenominator;
|
|
|
|
for (int y = 0; y < yDenominator; y++) {
|
|
for (int x = 0; x < xDenominator; x++) {
|
|
final Rect rect = Offset(x * width, y * height) & Size(width, height);
|
|
final Paint basePaint =
|
|
Paint()
|
|
..color = Color.fromARGB(
|
|
(((x + 1) * width) / size.width * 255.0).floor(),
|
|
(((y + 1) * height) / size.height * 255.0).floor(),
|
|
255,
|
|
127,
|
|
);
|
|
canvas.drawRect(rect, basePaint);
|
|
|
|
final Paint multiplyPaint =
|
|
Paint()
|
|
..color = _color
|
|
..blendMode = BlendMode.multiply;
|
|
canvas.drawRect(rect, multiplyPaint);
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(CustomPainter oldDelegate) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
class AnimatedAdvancedBlend extends StatefulWidget {
|
|
const AnimatedAdvancedBlend({super.key});
|
|
|
|
@override
|
|
State<AnimatedAdvancedBlend> createState() => _AnimatedAdvancedBlendState();
|
|
}
|
|
|
|
class _AnimatedAdvancedBlendState extends State<AnimatedAdvancedBlend>
|
|
with SingleTickerProviderStateMixin {
|
|
late final AnimationController controller = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(milliseconds: 5000),
|
|
);
|
|
late final Animation<double> animation = controller.drive(Tween<double>(begin: 0.0, end: 1.0));
|
|
Color _color = const Color.fromARGB(255, 255, 0, 255);
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
controller.repeat();
|
|
animation.addListener(() {
|
|
setState(() {
|
|
_color = Color.fromARGB((animation.value * 255).floor(), 255, 0, 255);
|
|
});
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
home: Scaffold(body: CustomPaint(painter: _MultiplyPainter(_color), child: Container())),
|
|
);
|
|
}
|
|
}
|