Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SVG na ratunek nudnym UI (FlutteredWrocław)
Search
Wojciech Warwas
November 09, 2022
Technology
32
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SVG na ratunek nudnym UI (FlutteredWrocław)
Wojciech Warwas
November 09, 2022
Transcript
44 slides
Wojciech Warwas 2022 SVG Na ratunek nudnym UI
None
None
None
None
O czym NIE będziemy mówić?
SVG? Zdjęcie dodane przez Laura Meinhardt: https://www.pexels.com/pl-pl/zdjecie/pozycja- fi gur-3678799/
SVG? <svg height="80" width="300"> <g fill="none"> <path stroke="red" d="M5 20
l215 0" /> <path stroke="black" d="M5 40 l215 0" /> <path stroke="blue" d="M5 60 l215 0" /> </g> </svg>
SVG? <svg viewBox="0 0 100 100" xmlns=“…”> <path fill="none" stroke="red"
d="M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z" /> </svg>
Co jest nie tak z SVG w Flutter?
None
None
None
Porównanie wydajności 34 ms! https://alibaba-cloud.medium.com/how-to-make-better-use-of-svg-in- fl utter- applications-964d38cb15a5
Przy podejmowaniu decyzji, zmierz wydajność!
None
None
Czy możemy coś z tym zrobić?
Czy możemy coś z tym zrobić?
<svg height="80" width="300"> <g fill="none"> <path stroke="red" d="M5 20 l215
0" /> <path stroke="black" d="M5 40 l215 0" /> <path stroke="blue" d="M5 60 l215 0" /> </g> </svg>
Zalety tego podejścia • Brak I/O • Lepsza kontrola nad
rysowaniem • Możliwość dalszej optymalizacji / zmian / animacji
SVG to Flutter
SVG to fl utter - node.js CLI • - generuje
kod Flutter na podstawie SVG • - krzywe beziera • - FILL oraz STROKE • - path tracing • - custom clipper svg-to- fl utter convert ~/path.svg
Rysowanie
Rysowanie
Rysowanie
Rysowanie
Show me the code!
Show me the code!
Show me the code! <svg height="80" width="300"> <g fill="none"> <path
stroke="red" d="M5 20 l215 0" /> <path stroke="black" d="M5 40 l215 0" /> <path stroke="blue" d="M5 60 l215 0" /> </g> </svg>
Show me the code! <svg height="80" width="300"> <g fill="none"> <path
stroke="red" d="M5 20 l215 0" /> <path stroke="black" d="M5 40 l215 0" /> <path stroke="blue" d="M5 60 l215 0" /> </g> </svg> class StrokesPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { Path path = Path(); final Paint paint = Paint(); // Path 3 Stroke path = Path(); paint.color = const Color(0xff0000ff); paint.style = PaintingStyle.stroke; paint.strokeWidth = 1; path.moveTo(size.width * 0.02, size.height * 0.75); path.lineTo(size.width * 0.73, size.height * 0.75); canvas.drawPath(path, paint); } @override bool shouldRepaint(CustomPainter oldDelegate) { return true; } } // Path 1 Stroke paint.color = const Color(0xffff0000); paint.style = PaintingStyle.stroke; paint.strokeWidth = 1; path.moveTo(size.width * 0.02, size.height * 0.25); path.lineTo(size.width * 0.73, size.height * 0.25); canvas.drawPath(path, paint);
Show me the code! <svg height="80" width="300"> <g fill="none"> <path
stroke="red" d="M5 20 l215 0" /> <path stroke="black" d="M5 40 l215 0" /> <path stroke="blue" d="M5 60 l215 0" /> </g> </svg> // Path 1 Stroke paint.color = const Color(0xffff0000); paint.style = PaintingStyle.stroke; paint.strokeWidth = 1; path.moveTo(size.width * 0.02, size.height * 0.25); path.lineTo(size.width * 0.73, size.height * 0.25); canvas.drawPath(path, paint);
Clip Photo by Chevanon Photography: https://www.pexels.com/photo/two-yellow-labrador-retriever-puppies-1108099/ Photo by Pixabay: https://www.pexels.com/photo/short-coated-black-and-brown-puppy-in-white-and-red-polka-dot-ceramic-mug-on-green-
fi eld-39317/ Photo by Denniz Futalan: https://www.pexels.com/photo/close-up-photo-of-a-small-short-coated-white-puppy-2523934/ svg-to- fl utter convert —clip {path}
Clip Photo by Chevanon Photography: https://www.pexels.com/photo/two-yellow-labrador-retriever-puppies-1108099/ Photo by Pixabay: https://www.pexels.com/photo/short-coated-black-and-brown-puppy-in-white-and-red-polka-dot-ceramic-mug-on-green-
fi eld-39317/ Photo by Denniz Futalan: https://www.pexels.com/photo/close-up-photo-of-a-small-short-coated-white-puppy-2523934/ class MyClipper extends CustomClipper<Path> { @override Path getClip(Size size) { Path path = Path(); // Path 1 Fill path.moveTo(size.width * 0.7558, size.height * 1.0861); path.lineTo(size.width * 0.4946, size.height * 0.9256); path.lineTo(size.width * 0.2408, size.height * 1.1038); path.lineTo(size.width * 0.2821, size.height * 0.7435); path.lineTo(size.width * 0.0683, size.height * 0.4966); path.lineTo(size.width * 0.355, size.height * 0.4345); path.lineTo(size.width * 0.4766, size.height * 0.1038); path.lineTo(size.width * 0.6125, size.height * 0.4256); path.lineTo(size.width * 0.9015, size.height * 0.4681); path.lineTo(size.width * 0.6988, size.height * 0.7292); path.lineTo(size.width * 0.7558, size.height * 1.0861); return path; } @override bool shouldReclip(covariant CustomClipper<Path> oldClipper) { return true; } }
Clip route transitions Photo by Denniz Futalan: https://www.pexels.com/photo/close- up- photo-of-a-small-short-coated-white-puppy-2523934/
return PageRouteBuilder( transitionDuration: const Duration(seconds: 1), pageBuilder: (context, animation, _) => Page2(), transitionsBuilder: (context, animation, _, child) { if (animation.value == 1) { return child; } return ClipPath( clipper: PawClipper(progress: animation.value), child: child, ); }, );
Path tracing Gra fi ki oneline wykorzystane dzięki uprzejmości fi
rmy
Path tracing
Path tracing PathMetrics pathMetrics = path.computeMetrics(); for (PathMetric pathMetric in
pathMetrics) { Path extractPath = pathMetric.extractPath( 0.0, pathMetric.length * progress, ); canvas.drawPath(extractPath, paint); } svg-to- fl utter convert ~/path.svg --path-tracing svg-to- fl utter convert ~/path.svg --path-tracing-all
Wnioski
Wnioski - Mierz wydajność
Wnioski - Mierz wydajność - Nie bój się eksperymentować
Wnioski - Mierz wydajność - Nie bój się eksperymentować -
Znaj narzędzia i formaty, z których korzystasz - Każdy problem da się rozwiązać na kilka sposobów
Q&A https://github.com/obiwanzenobi/svg-to- fl utter-path-converter https://thecodebrothers.pl
The OpenSource Brothers
More Decks by Wojciech Warwas
See All by Wojciech Warwas
designSystemWW.pdf
obiwanzenobi
0
69
SVG na ratunek nudnym UI
obiwanzenobi
0
61
Mapy on Flutter [PL]
obiwanzenobi
1
130
Other Decks in Technology
See All in Technology
メルカリの小規模チーム「Pod」で、 エンジニアがデータアナリストなしで、 AIを使ってデータ分析の自走を目指す取り組み
jackojacko_
1
370
本の挿絵に困ったから挿絵メーカーを自作した
yoshimura_datam
1
120
実測データからサービスの成長余力を測る。負荷シナリオ・テストデータ・限界値の設計
kazatohiei
1
190
対話 AI プラットフォーム「アイブリー」で実践する自然言語処理と事業開発
ivry_presentationmaterials
0
130
AIエージェントのアーキテクチャ設計
nsatoh
0
590
Welcome JXL!
dynamis
0
1k
[DBRE Summit 26] DBRE はデータベース運用をどう変えたのか
_awache
0
140
ポケモンバトルのAIエージェント
koji_kawamura
0
310
FPGAでアクティブセンシングがやりたくてカメラモジュールを自作した話
ryuz88
0
140
フルTypeScript × AI駆動開発で開発量が数倍に (JSConf JP 2026 スポンサーLT:NCDC株式会社)
keitaibaraki
0
560
データから見る AI時代のエンジニア転職と採用
junya_okura
4
1.4k
想定外の利用がプロダクトの価値を広げる
lycorptech_jp
PRO
0
130
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
310
Test your architecture with Archunit
thirion
2
2.5k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.3k
Documentation Writing (for coders)
carmenintech
77
5.7k
Code Review Best Practice
trishagee
74
20k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
620
Un-Boring Meetings
codingconduct
0
510
Navigating Team Friction
lara
192
16k
How to build a perfect <img>
jonoalderson
1
6.3k