books
This commit is contained in:
1
assets/draw/p03/p03.dart
Normal file
1
assets/draw/p03/p03.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'p03_page.dart';
|
||||
42
assets/draw/p03/p03_page.dart
Normal file
42
assets/draw/p03/p03_page.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
import 's12.dart' as s12;
|
||||
import 's13.dart' as s13;
|
||||
|
||||
class P03Page extends StatelessWidget {
|
||||
const P03Page({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const DemoShower(
|
||||
srcCodeDir: 'draw/p03',
|
||||
demos: [
|
||||
s1.Paper(),
|
||||
s2.Paper(),
|
||||
s3.Paper(),
|
||||
s4.Paper(),
|
||||
s5.Paper(),
|
||||
s6.Paper(),
|
||||
s7.Paper(),
|
||||
s8.Paper(),
|
||||
s9.Paper(),
|
||||
s10.Paper(),
|
||||
s11.Paper(),
|
||||
s12.Paper(),
|
||||
s13.Paper(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
45
assets/draw/p03/s01.dart
Normal file
45
assets/draw/p03/s01.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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 {
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
var paint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = Colors.blue;
|
||||
// 画布起点移到屏幕中心
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
canvas.drawCircle(Offset(0, 0), 50, paint);
|
||||
canvas.drawLine(
|
||||
Offset(20, 20),
|
||||
Offset(50, 50),
|
||||
paint
|
||||
..color = Colors.red
|
||||
..strokeWidth = 5
|
||||
..strokeCap = StrokeCap.round
|
||||
..style = PaintingStyle.stroke);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
96
assets/draw/p03/s02.dart
Normal file
96
assets/draw/p03/s02.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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 {
|
||||
late Paint _gridPint; // 画笔
|
||||
final double step = 20; // 小格边长
|
||||
final double strokeWidth = .5; // 线宽
|
||||
final Color color = Colors.grey; // 线颜色
|
||||
|
||||
PaperPainter() {
|
||||
_gridPint = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = strokeWidth
|
||||
..color = color;
|
||||
}
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
_drawGrid(canvas, size);
|
||||
_drawPart(canvas);
|
||||
}
|
||||
|
||||
void _drawPart(Canvas canvas) {
|
||||
var paint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = Colors.blue;
|
||||
canvas.drawCircle(Offset(0, 0), 50, paint);
|
||||
canvas.drawLine(
|
||||
Offset(20, 20),
|
||||
Offset(50, 50),
|
||||
paint
|
||||
..color = Colors.red
|
||||
..strokeWidth = 5
|
||||
..strokeCap = StrokeCap.round
|
||||
..style = PaintingStyle.stroke);
|
||||
}
|
||||
|
||||
void _drawGrid(Canvas canvas, Size size) {
|
||||
_drawBottomRight(canvas, size);
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(1, -1); //沿x轴镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(-1, 1); //沿y轴镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(-1, -1); //沿原点镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
void _drawBottomRight(Canvas canvas, Size size) {
|
||||
canvas.save();
|
||||
for (int i = 0; i < size.height / 2 / step; i++) {
|
||||
canvas.drawLine(Offset(0, 0), Offset(size.width / 2, 0), _gridPint);
|
||||
canvas.translate(0, step);
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
for (int i = 0; i < size.width / 2 / step; i++) {
|
||||
canvas.drawLine(Offset(0, 0), Offset(0, size.height / 2), _gridPint);
|
||||
canvas.translate(step , 0);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => true;
|
||||
}
|
||||
111
assets/draw/p03/s03.dart
Normal file
111
assets/draw/p03/s03.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.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 {
|
||||
late Paint _gridPint;
|
||||
final double step = 20;
|
||||
final double strokeWidth = .5;
|
||||
|
||||
PaperPainter() {
|
||||
_gridPint = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = strokeWidth
|
||||
..color = Colors.grey;
|
||||
}
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
_drawGrid(canvas, size);
|
||||
|
||||
var paint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = Colors.blue;
|
||||
|
||||
_drawPart(canvas, paint);
|
||||
_drawDot(canvas, paint);
|
||||
}
|
||||
|
||||
void _drawPart(Canvas canvas, Paint paint) {
|
||||
canvas.drawCircle(Offset(0, 0), 50, paint);
|
||||
canvas.drawLine(
|
||||
Offset(20, 20),
|
||||
Offset(50, 50),
|
||||
paint
|
||||
..color = Colors.red
|
||||
..strokeWidth = 5
|
||||
..strokeCap = StrokeCap.round
|
||||
..style = PaintingStyle.stroke);
|
||||
}
|
||||
|
||||
void _drawDot(Canvas canvas, Paint paint) {
|
||||
final int count = 12;
|
||||
paint
|
||||
..color = Colors.orangeAccent
|
||||
..style = PaintingStyle.stroke;
|
||||
canvas.save();
|
||||
for (int i = 0; i < count; i++) {
|
||||
var step = 2 * pi / count;
|
||||
canvas.drawLine(Offset(80, 0), Offset(100, 0), paint);
|
||||
canvas.rotate(step);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
void _drawGrid(Canvas canvas, Size size) {
|
||||
_drawBottomRight(canvas, size);
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(1, -1); //沿x轴镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(-1, 1); //沿y轴镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(-1, -1); //沿原点镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
void _drawBottomRight(Canvas canvas, Size size) {
|
||||
canvas.save();
|
||||
for (int i = 0; i < size.height / 2 / step; i++) {
|
||||
canvas.drawLine(Offset(0, 0), Offset(size.width / 2, 0), _gridPint);
|
||||
canvas.translate(0, step);
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
for (int i = 0; i < size.width / 2 / step; i++) {
|
||||
canvas.drawLine(Offset(0, 0), Offset(0, size.height / 2), _gridPint);
|
||||
canvas.translate(step , 0);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
156
assets/draw/p03/s04.dart
Normal file
156
assets/draw/p03/s04.dart
Normal file
@@ -0,0 +1,156 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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 {
|
||||
late Paint _paint;
|
||||
|
||||
late Paint _gridPint;
|
||||
final double step = 20;
|
||||
final double strokeWidth = 0.5;
|
||||
final Color color = Colors.blue;
|
||||
|
||||
PaperPainter() {
|
||||
_paint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..strokeWidth = strokeWidth
|
||||
..color = color;
|
||||
_gridPint = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = strokeWidth
|
||||
..color = Colors.grey;
|
||||
}
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
_drawGrid(canvas, size);
|
||||
_drawAxis(canvas,size);
|
||||
|
||||
_drawPointsWithPoints(canvas);
|
||||
// _drawPointsWithLines(canvas);
|
||||
_drawPointLineWithPolygon(canvas);
|
||||
_drawRawPoints(canvas);
|
||||
}
|
||||
|
||||
final List<Offset> points = [
|
||||
Offset(-120, -20),
|
||||
Offset(-80, -80),
|
||||
Offset(-40, -40),
|
||||
Offset(0, -100),
|
||||
Offset(40, -140),
|
||||
Offset(80, -160),
|
||||
Offset(120, -100),
|
||||
];
|
||||
|
||||
void _drawPointsWithPoints(Canvas canvas) {
|
||||
_paint
|
||||
..color = Colors.red
|
||||
..style = PaintingStyle.stroke..strokeWidth=10
|
||||
..strokeCap = StrokeCap.round;
|
||||
canvas.drawPoints(PointMode.points, points, _paint);
|
||||
}
|
||||
|
||||
void _drawPointsWithLines(Canvas canvas) {
|
||||
_paint
|
||||
..color = Colors.red
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..strokeCap = StrokeCap.round;
|
||||
canvas.drawPoints(PointMode.lines, points, _paint);
|
||||
}
|
||||
|
||||
void _drawPointLineWithPolygon(Canvas canvas) {
|
||||
_paint
|
||||
..color = Colors.red
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..strokeCap = StrokeCap.round;
|
||||
canvas.drawPoints(PointMode.polygon, points, _paint);
|
||||
}
|
||||
|
||||
void _drawRawPoints(Canvas canvas) {
|
||||
Float32List pos = Float32List.fromList([
|
||||
-120, -20,-80, -80,-40,
|
||||
-40,0, -100,40, -140,
|
||||
80, -160,120, -100]);
|
||||
_paint
|
||||
..color = Colors.red
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 10
|
||||
..strokeCap = StrokeCap.round;
|
||||
canvas.drawRawPoints(PointMode.points, pos, _paint);
|
||||
}
|
||||
|
||||
void _drawAxis(Canvas canvas, Size size) {
|
||||
_paint..color=Colors.blue..strokeWidth=1.5;
|
||||
canvas.drawLine(Offset(-size.width/2, 0) , Offset(size.width/2, 0),_paint);
|
||||
canvas.drawLine(Offset( 0,-size.height/2) , Offset( 0,size.height/2),_paint);
|
||||
canvas.drawLine(Offset( 0,size.height/2) , Offset( 0-7.0,size.height/2-10),_paint);
|
||||
canvas.drawLine(Offset( 0,size.height/2) , Offset( 0+7.0,size.height/2-10),_paint);
|
||||
canvas.drawLine(Offset(size.width/2, 0) , Offset(size.width/2-10, 7),_paint);
|
||||
canvas.drawLine(Offset(size.width/2, 0) , Offset(size.width/2-10, -7),_paint);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
|
||||
void _drawGrid(Canvas canvas, Size size) {
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.save();
|
||||
canvas.scale(1, -1); //沿x轴镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(-1, 1); //沿y轴镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
canvas.scale(-1, -1); //沿原点镜像
|
||||
_drawBottomRight(canvas, size);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
void _drawBottomRight(Canvas canvas, Size size) {
|
||||
canvas.save();
|
||||
for (int i = 0; i < size.height / 2 / step; i++) {
|
||||
canvas.drawLine(Offset(0, 0), Offset(size.width / 2, 0), _gridPint);
|
||||
canvas.translate(0, step);
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
canvas.save();
|
||||
for (int i = 0; i < size.width / 2 / step; i++) {
|
||||
canvas.drawLine(Offset(0, 0), Offset(0, size.height / 2), _gridPint);
|
||||
canvas.translate(step , 0);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
133
assets/draw/p03/s05.dart
Normal file
133
assets/draw/p03/s05.dart
Normal file
@@ -0,0 +1,133 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart: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);
|
||||
|
||||
_drawDRRect(canvas);
|
||||
|
||||
canvas.translate(-240, 0);
|
||||
_drawRect(canvas);
|
||||
|
||||
canvas.translate(480, 0);
|
||||
_drawRRect(canvas);
|
||||
}
|
||||
|
||||
void _drawRect(Canvas canvas) {
|
||||
_paint
|
||||
..color = Colors.blue
|
||||
..strokeWidth = 1.5;
|
||||
//【1】.矩形中心构造
|
||||
Rect rectFromCenter =
|
||||
Rect.fromCenter(center: Offset(0, 0), width: 160, height: 160);
|
||||
canvas.drawRect(rectFromCenter, _paint);
|
||||
//【2】.矩形左上右下构造
|
||||
Rect rectFromLTRB = Rect.fromLTRB(-120, -120, -80, -80);
|
||||
canvas.drawRect(rectFromLTRB, _paint..color = Colors.red);
|
||||
//【3】. 矩形左上宽高构造
|
||||
Rect rectFromLTWH = Rect.fromLTWH(80, -120, 40, 40);
|
||||
canvas.drawRect(rectFromLTWH, _paint..color = Colors.orange);
|
||||
//【4】. 矩形内切圆构造
|
||||
Rect rectFromCircle = Rect.fromCircle(center: Offset(100, 100), radius: 20);
|
||||
canvas.drawRect(rectFromCircle, _paint..color = Colors.green);
|
||||
//【5】. 矩形两点构造
|
||||
Rect rectFromPoints = Rect.fromPoints(Offset(-120, 80), Offset(-80, 120));
|
||||
canvas.drawRect(rectFromPoints, _paint..color = Colors.purple);
|
||||
}
|
||||
|
||||
void _drawRRect(Canvas canvas) {
|
||||
_paint
|
||||
..color = Colors.blue
|
||||
..strokeWidth = 1.5;
|
||||
//【1】.圆角矩形fromRectXY构造
|
||||
Rect rectFromCenter =
|
||||
Rect.fromCenter(center: Offset(0, 0), width: 160, height: 160);
|
||||
canvas.drawRRect(RRect.fromRectXY(rectFromCenter, 40, 20), _paint);
|
||||
|
||||
//【2】.圆角矩形fromLTRBXY构造
|
||||
canvas.drawRRect(RRect.fromLTRBXY(-120, -120, -80, -80, 10, 10),
|
||||
_paint..color = Colors.red);
|
||||
|
||||
//【3】. 圆角矩形fromLTRBR构造
|
||||
canvas.drawRRect(RRect.fromLTRBR(80, -120, 120, -80, Radius.circular(10)),
|
||||
_paint..color = Colors.orange);
|
||||
|
||||
//【4】. 圆角矩形fromLTRBAndCorners构造
|
||||
canvas.drawRRect(
|
||||
RRect.fromLTRBAndCorners(80, 80, 120, 120,
|
||||
bottomRight: Radius.elliptical(10, 10)),
|
||||
_paint..color = Colors.green);
|
||||
|
||||
//【5】. 矩形两点构造
|
||||
Rect rectFromPoints = Rect.fromPoints(Offset(-120, 80), Offset(-80, 120));
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndCorners(rectFromPoints,
|
||||
bottomLeft: Radius.elliptical(10, 10)),
|
||||
_paint..color = Colors.purple);
|
||||
}
|
||||
|
||||
void _drawDRRect(Canvas canvas) {
|
||||
_paint
|
||||
..color = Colors.blue
|
||||
..strokeWidth = 1.5;
|
||||
Rect outRect =
|
||||
Rect.fromCenter(center: Offset(0, 0), width: 160, height: 160);
|
||||
Rect inRect =
|
||||
Rect.fromCenter(center: Offset(0, 0), width: 100, height: 100);
|
||||
|
||||
canvas.drawDRRect(RRect.fromRectXY(outRect, 20, 20),
|
||||
RRect.fromRectXY(inRect, 20, 20), _paint);
|
||||
|
||||
Rect outRect2 =
|
||||
Rect.fromCenter(center: Offset(0, 0), width: 60, height: 60);
|
||||
Rect inRect2 = Rect.fromCenter(center: Offset(0, 0), width: 40, height: 40);
|
||||
canvas.drawDRRect(RRect.fromRectXY(outRect2, 15, 15),
|
||||
RRect.fromRectXY(inRect2, 10, 10), _paint..color = Colors.green);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
91
assets/draw/p03/s06.dart
Normal file
91
assets/draw/p03/s06.dart
Normal file
@@ -0,0 +1,91 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart: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);
|
||||
_draw(canvas);
|
||||
}
|
||||
|
||||
void _draw(Canvas canvas) {
|
||||
canvas.save();
|
||||
canvas.translate(-200, 0);
|
||||
canvas.drawCircle(Offset(0, 0), 60, _paint);
|
||||
canvas.restore();
|
||||
|
||||
var rect = Rect.fromCenter(center: Offset(0, 0), height: 100, width: 120);
|
||||
canvas.drawOval(rect, _paint);
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(200, 0);
|
||||
//drawArc(矩形区域,起始弧度,扫描弧度,是否连中心,画笔)
|
||||
canvas.drawArc(rect, 0, pi / 2 * 3, true, _paint);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
void _drawArcDetail(Canvas canvas) {
|
||||
var rect = Rect.fromCenter(center: Offset(0, 0), height: 100, width: 100);
|
||||
_paint
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2;
|
||||
canvas.save();
|
||||
canvas.translate(-200, 0);
|
||||
canvas.drawArc(rect, 0, pi / 2 * 3, false, _paint);
|
||||
canvas.restore();
|
||||
canvas.drawArc(rect, 0, pi / 2 * 3, true, _paint);
|
||||
canvas.save();
|
||||
canvas.translate(200, 0);
|
||||
var a = pi / 8;
|
||||
canvas.drawArc(rect, a, 2 * pi - a.abs() * 2, true, _paint..color=Colors.yellowAccent..style=PaintingStyle.fill);
|
||||
canvas.translate(40, 0);
|
||||
canvas.drawCircle(Offset(0, 0), 6, _paint);
|
||||
canvas.translate(25, 0);
|
||||
canvas.drawCircle(Offset(0, 0), 6, _paint);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
45
assets/draw/p03/s07.dart
Normal file
45
assets/draw/p03/s07.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart: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();
|
||||
|
||||
final double strokeWidth = 0.5;
|
||||
final Color color = Colors.blue;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
coordinate.paint(canvas, size);
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
canvas.drawColor(Colors.blue, BlendMode.lighten);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
74
assets/draw/p03/s08.dart
Normal file
74
assets/draw/p03/s08.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
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);
|
||||
|
||||
var colors = [
|
||||
Color(0xFFF60C0C),
|
||||
Color(0xFFF3B913),
|
||||
Color(0xFFE7F716),
|
||||
Color(0xFF3DF30B),
|
||||
Color(0xFF0DF6EF),
|
||||
Color(0xFF0829FB),
|
||||
Color(0xFFB709F4),
|
||||
];
|
||||
|
||||
var pos = [1.0 / 7, 2.0 / 7, 3.0 / 7, 4.0 / 7, 5.0 / 7, 6.0 / 7, 1.0];
|
||||
|
||||
_paint.shader = ui.Gradient.linear(
|
||||
Offset(0, 0), Offset(size.width, 0),
|
||||
colors, pos, TileMode.clamp);
|
||||
|
||||
_paint.blendMode=BlendMode.lighten;
|
||||
|
||||
canvas.drawPaint(_paint);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
73
assets/draw/p03/s09.dart
Normal file
73
assets/draw/p03/s09.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
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();
|
||||
final double strokeWidth = 0.5;
|
||||
final Color color = Colors.blue;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
// coordinate.paint(canvas, size);
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
|
||||
Paint paint = Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = Colors.white
|
||||
..isAntiAlias = true;
|
||||
double relativeX = 100;
|
||||
double angle = 0;
|
||||
double width = 10;
|
||||
double height = 10;
|
||||
double center = relativeX + width / 2;
|
||||
if(angle == 0) {
|
||||
center = relativeX + width/4;
|
||||
} else if (angle == 2) {
|
||||
center = relativeX + width/4*3;
|
||||
}
|
||||
|
||||
Path trianglePath = Path()
|
||||
..addPolygon([Offset(relativeX, height), Offset(relativeX + width, height), Offset(center, 0),], false)..close();
|
||||
|
||||
Path rectanglePath = Path()
|
||||
..addRRect(RRect.fromLTRBR(0, 10, 160, 100, Radius.circular(8)))..close();
|
||||
|
||||
|
||||
canvas.drawShadow(Path.combine(PathOperation.xor, trianglePath, rectanglePath), Colors.black, 3, false);
|
||||
canvas.drawPath(Path.combine(PathOperation.xor, trianglePath, rectanglePath), paint..color = Colors.white);
|
||||
paint.maskFilter = MaskFilter.blur(BlurStyle.inner, 20);
|
||||
canvas.drawPath(Path.combine(PathOperation.xor, trianglePath, rectanglePath), paint..color=Color(0xffBEC4C0));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
79
assets/draw/p03/s11.dart
Normal file
79
assets/draw/p03/s11.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
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);
|
||||
|
||||
// canvas.save();
|
||||
var rect = Rect.fromCenter(center: Offset.zero,width: 360,height: 240);
|
||||
canvas.clipRect(rect,doAntiAlias: true,clipOp: ui.ClipOp.intersect);
|
||||
|
||||
var colors = [
|
||||
Color(0xFFF60C0C),
|
||||
Color(0xFFF3B913),
|
||||
Color(0xFFE7F716),
|
||||
Color(0xFF3DF30B),
|
||||
Color(0xFF0DF6EF),
|
||||
Color(0xFF0829FB),
|
||||
Color(0xFFB709F4),
|
||||
];
|
||||
|
||||
var pos = [1.0 / 7, 2.0 / 7, 3.0 / 7, 4.0 / 7, 5.0 / 7, 6.0 / 7, 1.0];
|
||||
|
||||
_paint.shader = ui.Gradient.linear(
|
||||
rect.centerLeft, rect.centerRight,
|
||||
colors, pos, TileMode.clamp);
|
||||
|
||||
_paint.blendMode=BlendMode.lighten;
|
||||
|
||||
canvas.drawPaint(_paint);
|
||||
// canvas.restore();
|
||||
// canvas.drawColor(Colors.blue, BlendMode.lighten);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
49
assets/draw/p03/s12.dart
Normal file
49
assets/draw/p03/s12.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
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();
|
||||
|
||||
final double strokeWidth = 0.5;
|
||||
final Color color = Colors.blue;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
coordinate.paint(canvas, size);
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
|
||||
// canvas.save();
|
||||
var rect = Rect.fromCenter(center: Offset.zero,width: 200,height: 100);
|
||||
canvas.clipRRect(RRect.fromRectAndRadius(rect, Radius.circular(30)));
|
||||
canvas.drawColor(Colors.red, BlendMode.darken);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
52
assets/draw/p03/s13.dart
Normal file
52
assets/draw/p03/s13.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
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();
|
||||
|
||||
final double strokeWidth = 0.5;
|
||||
final Color color = Colors.blue;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
coordinate.paint(canvas, size);
|
||||
canvas.translate(size.width / 2, size.height / 2);
|
||||
|
||||
Path path = Path();
|
||||
path.lineTo(80, 80);
|
||||
path.lineTo(-80, 80);
|
||||
path.close();
|
||||
|
||||
canvas.clipPath(path);
|
||||
canvas.drawColor(Colors.red, BlendMode.darken);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
Reference in New Issue
Block a user