Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SVG na ratunek nudnym UI (FlutteredWrocław)
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Wojciech Warwas
November 09, 2022
Technology
27
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
More Decks by Wojciech Warwas
See All by Wojciech Warwas
designSystemWW.pdf
obiwanzenobi
0
63
SVG na ratunek nudnym UI
obiwanzenobi
0
59
Mapy on Flutter [PL]
obiwanzenobi
1
130
Other Decks in Technology
See All in Technology
リージョンの壁を越える、 ちょっと変わったAWSサービスの話
falken
PRO
0
260
【Oracle AI Spotlight ウェビナー】AWSか、Azureか、Google Cloudか。その議論にオラクルを含める意義。
oracle4engineer
PRO
2
240
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
2
460
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
240
PdMをやめて、 "プロダクトビルダー"という 働き方に変えました / PdM to Product Builder
shikichee
2
720
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
130
Benchmarking Vector Databases: pgvector vs. LanceDB
tsho
0
150
Bet AI Day 2026丨AIによって本質に戻るシステムリスク管理
layerx
PRO
0
1.2k
『止めない』を設計する — 制約の中で、事業の根幹を支える判断
hiroyaterui
0
210
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
110
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
260
AIで実装は速くなった。なのにプロダクトは速くならない。職能の壁を越えて価値のフローを設計する
nwiizo
6
7.3k
Featured
See All Featured
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
820
KATA
mclloyd
PRO
35
15k
Exploring anti-patterns in Rails
aemeredith
3
490
エンジニアに許された特別な時間の終わり
watany
108
250k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
The Language of Interfaces
destraynor
162
27k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
310
From π to Pie charts
rasagy
0
350
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
470
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.1k
Transcript
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