books
This commit is contained in:
68
assets/draw/p03/s10.dart
Normal file
68
assets/draw/p03/s10.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../components/coordinate.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020-03-19
|
||||
/// 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();
|
||||
|
||||
late Paint _paint;
|
||||
|
||||
final double strokeWidth = 0.5;
|
||||
final Color color = Colors.blue;
|
||||
|
||||
PaperPainter() {
|
||||
_paint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..strokeWidth = strokeWidth
|
||||
..color = color;
|
||||
}
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
coordinate.paint(canvas, size);
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
|
||||
Path path = Path();
|
||||
path.lineTo(60, 60);
|
||||
path.lineTo(-60, 60);
|
||||
path.lineTo(60, -60);
|
||||
path.lineTo(-60, -60);
|
||||
path.close();
|
||||
|
||||
canvas.drawPath(path, _paint);
|
||||
canvas.translate(140, 0);
|
||||
canvas.drawPath(
|
||||
path,
|
||||
_paint
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
Reference in New Issue
Block a user