优化绘制冰墩墩

This commit is contained in:
toly
2022-02-16 22:11:03 +08:00
parent 2ea12bce09
commit 2cc5dad887
2 changed files with 3 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ class _DunDunViewState extends State<DunDunView> {
}
void loadImage() async {
ByteData data2 = await rootBundle.load('assets/images/logo1.png');
ByteData data2 = await rootBundle.load('assets/images/logo1.webp');
image = await decodeImageFromList(data2.buffer.asUint8List());
if (mounted) setState(() {});
}
@@ -232,11 +232,10 @@ class DunDunPainter extends CustomPainter {
pathPaint..color = Colors.red;
starPath = starPath.shift(Offset(152, -20));
canvas.drawPath(starPath, pathPaint);
if (image != null) {
Rect src2 = Rect.fromLTWH(
0, 0, image!.width.toDouble(), image!.height.toDouble());
Rect dst2 = Rect.fromLTWH(50, 55, 899 / 27, 1066 / 27);
Rect dst2 = Rect.fromLTWH(50, 55, 899 / 28, 1066 / 28);
canvas.drawImageRect(image!, src2, dst2, Paint());
}

View File

@@ -113,7 +113,7 @@ class GalleryFactory {
title: "冰墩墩",
author: "张风捷特烈",
info:
" 本样例绘制 2022 年北京冬奥会吉祥物冰墩墩的绘制,可以学到路径绘制、渐变色等知识。",
" 本样例绘制 2022 年北京冬奥会吉祥物冰墩墩的形体,从中可以学到路径绘制、渐变色等知识。",
content: DunDunView()),
FrameShower(
title: "井字棋",