books
This commit is contained in:
1
assets/draw/p05/p05.dart
Normal file
1
assets/draw/p05/p05.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'p05_page.dart';
|
||||
39
assets/draw/p05/p05_page.dart
Normal file
39
assets/draw/p05/p05_page.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:idraw/components/demo_shower.dart';
|
||||
import 's01.dart' as s1;
|
||||
import 's02.dart' as s2;
|
||||
import 's03.dart' as s3;
|
||||
import 's04.dart' as s4;
|
||||
import 's05.dart' as s5;
|
||||
import 's06.dart' as s6;
|
||||
import 's07.dart' as s7;
|
||||
import 's08.dart' as s8;
|
||||
import 's09.dart' as s9;
|
||||
import 's10.dart' as s10;
|
||||
import 's11.dart' as s11;
|
||||
|
||||
|
||||
class P05Page extends StatelessWidget {
|
||||
const P05Page({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const DemoShower(
|
||||
srcCodeDir: 'draw/p05',
|
||||
demos: [
|
||||
s1.Paper(),
|
||||
s2.Paper(),
|
||||
s3.Paper(),
|
||||
s4.Paper(),
|
||||
s5.Paper(),
|
||||
s6.Paper(),
|
||||
s7.Paper(),
|
||||
s8.Paper(),
|
||||
s9.Paper(),
|
||||
s10.Paper(),
|
||||
s11.Paper(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
58
assets/draw/p05/s01.dart
Normal file
58
assets/draw/p05/s01.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
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;
|
||||
}
|
||||
60
assets/draw/p05/s02.dart
Normal file
60
assets/draw/p05/s02.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
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();
|
||||
|
||||
@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.green
|
||||
..style = PaintingStyle.fill;
|
||||
path
|
||||
..relativeMoveTo(0, 0)
|
||||
..relativeLineTo(100, 120)
|
||||
..relativeLineTo(-10, -60)
|
||||
..relativeLineTo( 60,-10,)
|
||||
..close();
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
path.reset();
|
||||
paint
|
||||
..style = PaintingStyle.stroke..color=Colors.green
|
||||
..strokeWidth = 2;
|
||||
path
|
||||
..relativeMoveTo(-200, 0)
|
||||
..relativeLineTo(100, 120)
|
||||
..relativeLineTo(-10, -60)
|
||||
..relativeLineTo( 60,-10,)..close();
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
54
assets/draw/p05/s03.dart
Normal file
54
assets/draw/p05/s03.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.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();
|
||||
|
||||
@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.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
var rect = Rect.fromCenter(center: Offset(0, 0), width: 160, height: 100);
|
||||
|
||||
path.lineTo(30, 30);
|
||||
path..arcTo(rect, 0, pi * 1.5, true);
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
path.reset();
|
||||
canvas.translate(200, 0);
|
||||
path.lineTo(30, 30);
|
||||
path..arcTo(rect, 0, pi * 1.5, false);
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
77
assets/draw/p05/s04.dart
Normal file
77
assets/draw/p05/s04.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
import 'package:flutter/material.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.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
path.lineTo(80, -40);
|
||||
|
||||
//绘制中间
|
||||
path
|
||||
..arcToPoint(
|
||||
Offset(40, 40),
|
||||
radius: Radius.circular(60),
|
||||
largeArc: false,
|
||||
)
|
||||
..close();
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
//绘制左侧
|
||||
path.reset();
|
||||
canvas.translate(-150, 0);
|
||||
path.lineTo(80, -40);
|
||||
path
|
||||
..arcToPoint(Offset(40, 40),
|
||||
radius: Radius.circular(60), largeArc: true, clockwise: false)
|
||||
..close();
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
//绘制右侧
|
||||
path.reset();
|
||||
canvas.translate(150 + 150.0, 0);
|
||||
path.lineTo(80, -40);
|
||||
path
|
||||
..arcToPoint(
|
||||
Offset(40, 40),
|
||||
radius: Radius.circular(60),
|
||||
largeArc: true,
|
||||
)
|
||||
..close();
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
80
assets/draw/p05/s05.dart
Normal file
80
assets/draw/p05/s05.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.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();
|
||||
|
||||
final Offset p1 = Offset(80, -100);
|
||||
final Offset p2 = Offset(160, 0);
|
||||
|
||||
|
||||
@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.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
//抛物线
|
||||
path.conicTo(p1.dx, p1.dy, p2.dx, p2.dy, 1);
|
||||
_drawHelper(canvas);
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
//椭圆线
|
||||
path.reset();
|
||||
canvas.translate(-180, 0);
|
||||
path.conicTo(p1.dx, p1.dy, p2.dx, p2.dy, 0.5);
|
||||
canvas.drawPath(path, paint);
|
||||
_drawHelper(canvas);
|
||||
|
||||
//双曲线
|
||||
path.reset();
|
||||
canvas.translate(180+180.0, 0);
|
||||
path.conicTo(p1.dx, p1.dy, p2.dx, p2.dy, 1.5);
|
||||
canvas.drawPath(path, paint);
|
||||
_drawHelper(canvas);
|
||||
}
|
||||
|
||||
void _drawHelper(Canvas canvas) {
|
||||
canvas.drawPoints(
|
||||
PointMode.points,
|
||||
[
|
||||
p1,
|
||||
p2,
|
||||
],
|
||||
Paint()
|
||||
..strokeWidth = 6
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = Colors.blue);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
88
assets/draw/p05/s06.dart
Normal file
88
assets/draw/p05/s06.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.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();
|
||||
|
||||
final Offset p1 = Offset(100, -100);
|
||||
final Offset p2 = Offset(160, 50);
|
||||
|
||||
|
||||
@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.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
path.quadraticBezierTo(p1.dx, p1.dy, p2.dx, p2.dy);
|
||||
_drawHelper(canvas);
|
||||
|
||||
path.relativeQuadraticBezierTo(p1.dx, p1.dy, p2.dx, p2.dy);
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
}
|
||||
|
||||
void _drawHelper(Canvas canvas) {
|
||||
canvas.drawPoints(
|
||||
PointMode.polygon,
|
||||
[
|
||||
Offset.zero,
|
||||
p1,
|
||||
p2,
|
||||
p1.translate(160, 50),
|
||||
p2.translate(160, 50),
|
||||
],
|
||||
Paint()
|
||||
..strokeWidth = 1
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = Colors.blue);
|
||||
canvas.drawPoints(
|
||||
PointMode.points,
|
||||
[
|
||||
Offset.zero,
|
||||
p1,
|
||||
p2,
|
||||
p1.translate(160, 50),
|
||||
p2.translate(160, 50),
|
||||
],
|
||||
Paint()
|
||||
..strokeWidth = 6
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = Colors.blue);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
91
assets/draw/p05/s07.dart
Normal file
91
assets/draw/p05/s07.dart
Normal file
@@ -0,0 +1,91 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.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();
|
||||
|
||||
final Offset p1 = Offset(80, -100);
|
||||
final Offset p2 = Offset(80, 50);
|
||||
final Offset p3 = Offset(160, 50);
|
||||
|
||||
@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();
|
||||
|
||||
paint
|
||||
..color = Colors.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
path.cubicTo(p1.dx, p1.dy, p2.dx, p2.dy, p3.dx, p3.dy);
|
||||
_drawHelper(canvas);
|
||||
|
||||
path.relativeCubicTo(p1.dx, p1.dy, p2.dx, p2.dy, p3.dx, p3.dy);
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
}
|
||||
|
||||
void _drawHelper(Canvas canvas) {
|
||||
canvas.drawPoints(
|
||||
PointMode.lines,
|
||||
[
|
||||
Offset.zero,
|
||||
p1,
|
||||
p2,
|
||||
p3,
|
||||
Offset.zero + p3,
|
||||
p1 + p3,
|
||||
p2 + p3,
|
||||
p3 + p3,
|
||||
],
|
||||
Paint()
|
||||
..strokeWidth = 1
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = Colors.blue);
|
||||
canvas.drawPoints(
|
||||
PointMode.points,
|
||||
[
|
||||
Offset.zero,
|
||||
p1,
|
||||
p2,
|
||||
p3,
|
||||
Offset.zero + p3,
|
||||
p1 + p3,
|
||||
p2 + p3,
|
||||
p3 + p3,
|
||||
],
|
||||
Paint()
|
||||
..strokeWidth = 6
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = Colors.blue);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
50
assets/draw/p05/s08.dart
Normal file
50
assets/draw/p05/s08.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.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.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
Rect rect = Rect.fromPoints(Offset(100, 100), Offset(160, 160));
|
||||
path
|
||||
..lineTo(100, 100)
|
||||
..addRect(rect)
|
||||
..relativeLineTo(100, -100)
|
||||
..addRRect(RRect.fromRectXY(rect.translate(100, -100), 10, 10));
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
52
assets/draw/p05/s09.dart
Normal file
52
assets/draw/p05/s09.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.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.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
Rect rect = Rect.fromPoints(Offset(100, 100), Offset(160, 140));
|
||||
path
|
||||
..lineTo(100, 100)
|
||||
..addOval(rect)
|
||||
..relativeLineTo(100, -100)
|
||||
..addArc(rect.translate(100 + 60.0, -100), 0, pi);
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
66
assets/draw/p05/s10.dart
Normal file
66
assets/draw/p05/s10.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.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(
|
||||
coordinate: Coordinate()
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PaperPainter extends CustomPainter {
|
||||
|
||||
final Coordinate? coordinate;
|
||||
PaperPainter({this.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.purpleAccent
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
var p0 = Offset(100, 100);
|
||||
path
|
||||
..lineTo(100, 100)
|
||||
..addPolygon([
|
||||
p0,
|
||||
p0.translate(20, -20),
|
||||
p0.translate(40, -20),
|
||||
p0.translate(60, 0),
|
||||
p0.translate(60, 20),
|
||||
p0.translate(40, 40),
|
||||
p0.translate(20, 40),
|
||||
p0.translate(0, 20),
|
||||
], true)
|
||||
..addPath(
|
||||
Path()..relativeQuadraticBezierTo(125, -100, 260, 0), Offset.zero)
|
||||
..lineTo(160, 100);
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
39
assets/draw/p05/s11.dart
Normal file
39
assets/draw/p05/s11.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.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(step: 25);
|
||||
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
coordinate.paint(canvas, size);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(PaperPainter oldDelegate) => false;
|
||||
}
|
||||
Reference in New Issue
Block a user