SVG
约 2 分钟阅读
- svg2-draft链接svgwg.org/svg2-draftsvg2-draft · Changes from SVG 1.1 · SVG Loaders · https://jakearchibald.github.io/svgomg/ · https://svgomg.net/ · https://svgcrop.com/笔记:SVG
- Changes from SVG 1.1链接www.w3.org/TR/SVG2/changes.htmlsvg2-draft · Changes from SVG 1.1 · SVG Loaders · https://jakearchibald.github.io/svgomg/ · https://svgomg.net/ · https://svgcrop.com/笔记:SVG
- SVG Loaders链接wpack.io/tutorials/using-various-svg-loadersvg2-draft · Changes from SVG 1.1 · SVG Loaders · https://jakearchibald.github.io/svgomg/ · https://svgomg.net/ · https://svgcrop.com/笔记:SVG
- jakearchibald.github.io/svgomg
- svgomg.net
- svgcrop.com
- daveknispel.github.io/svg2use
- simpleicons.org
- Free SVG icons for popular brands
- Editor
- Library/Engine
- thorvg/thorvgGitHubthorvg/thorvg
- MIT, C++, C
- svg.js/svg.jsGitHubsvgdotjs/svg.js
- MIT, JavaScript
- manipulating and animating SVG
- thorvg/thorvgGitHubthorvg/thorvg
# AI to SVG
inkscape --file=icon.ai --export-plain-svg=icon.svg
# macOS
qlmanage -t -s 1000 -o . picture.svg
brew install librsvg
rsvg-convert -h 32 icon.svg > icon-32.png
rsvg-convert -h 200 icon.svg > icon.png
rsvg-convert -h 200 icon.svg | oxipng -o max -i 0 --strip safe - > icon.png
# 通过替换 currentColor 来生成不同颜色的图标
cat ./svg/Home.svg | sed 's/currentColor/#999999/g' | rsvg-convert -h 48 | oxipng -o max -i 0 --strip safe - > HomeInactive.png
cat ./svg/Home.svg | sed 's/currentColor/#4579F6/g' | rsvg-convert -h 48 | oxipng -o max -i 0 --strip safe - > HomeActive.pngSVG 颜色
- fill="currentColor"
- 让 SVG 显示为当前文本颜色
- 对于
<img/>的方式不生效
<img/>filter: invert(1);黑色
缩放和大小
- viewBox 控制可见区域
- minx, miny, width, height
- width,height 控制缩放大小
- css-tricks.com/scale-svg
file-rule
Fill-Rule is an SVG property that basically defines how to determine what shapes are filled or subtracted from the shape. The default svg value is “nonzero”, and this is what Android requires. Unfortunately Sketch uses “evenodd”
命令行操作 inkscape -g $filename --verb=EditSelectAll --verb=SelectionUnGroup --verb=StrokeToPath --verb=FileSave"
fill-rule evenodd 可能会导致内部的一些内容被忽略
TL;DR: SVG icons should use fill-rule
instead of Sketch default evenodd property to support Android VectorDrawable (as of now)font
viewBox vs width/height
- viewBox="min-x min-y width height"
- 视窗或视区
- width/height
- 物理大小 - 即实际在页面上占据的空间大小
关联信息
反向链接、本文链接的其他页面和外部资料。
参考资料
GitHub3 条
- jaywcjlove/svgtofontgithub.com/jaywcjlove/svgtofont
- svgdotjs/svg.jsgithub.com/svgdotjs/svg.js
- thorvg/thorvggithub.com/thorvg/thorvg
其他外链14 条
- boxy-svg.comboxy-svg.com/
- css-tricks.com/scale-svgcss-tricks.com/scale-svg
- daveknispel.github.io/svg2usedaveknispel.github.io/svg2use
- inkscape.orginkscape.org/
- jakearchibald.github.io/svgomgjakearchibald.github.io/svgomg
- simpleicons.orgsimpleicons.org/
- svgcrop.comsvgcrop.com/
- svgomg.netsvgomg.net/
- svgwg.org/svg2-draftsvgwg.org/svg2-draft
- uxwing.com/svg-icon-editoruxwing.com/svg-icon-editor
- wpack.io/tutorials/using-various-svg-loaderwpack.io/tutorials/using-various-svg-loader
- www.svgviewer.devwww.svgviewer.dev/
- www.w3.org/TR/SVG2/changes.htmlwww.w3.org/TR/SVG2/changes.html
- yqnn.github.io/svg-path-editoryqnn.github.io/svg-path-editor