Files
iroute/packages/idraw/lib/p05/s01.dart
toly 25e51d789f 24
2023-12-11 21:53:27 +08:00

59 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../components/coordinate.dart';
/// create by 张风捷特烈 on 2020/5/1
/// contact me by email 1981462002@qq.com
/// 说明:
class Paper extends StatelessWidget {
const Paper({super.key});
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: CustomPaint(
// 使用CustomPaint
painter: PaperPainter(),
),
);
}
}
class PaperPainter extends CustomPainter {
final Coordinate coordinate = Coordinate();
@override
void paint(Canvas canvas, Size size) {
coordinate.paint(canvas, size);
canvas.translate(size.width / 2, size.height / 2);
Path path = Path();
Paint paint = Paint()
..color = Colors.deepPurpleAccent
..style = PaintingStyle.fill;
path
..moveTo(0, 0) //移至(0,0)点
..lineTo(60, 80) //从(0,0)画线到(60, 80) 点
..lineTo(60, 0) //从(60,80)画线到(60, 0) 点
..lineTo(0, -80) //从(60, 0) 画线到(0, -80)点
..close(); //闭合路径
canvas.drawPath(path, paint);
paint
..style = PaintingStyle.stroke
..strokeWidth = 2;
path
..moveTo(0, 0)
..lineTo(-60, 80)
..lineTo(-60, 0)
..lineTo(0, -80);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => false;
}