Aprillz.MewUI.Svg - A MewUI port of SVG.NET #178
al6uiz
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
SVG Icon Sample
SVG Viewer Sample
Aprillz.MewUI.Svg
Pure managed, no System.Drawing. Built on SVG.NET with its
System.Drawingrendering replaced by a MewUIIGraphicsContextbackend, so it parses and renders SVG on every MewUI backend (Direct2D, GDI, MewVG/OpenGL) and is NativeAOT/trim compatible.Install
Targets
net8.0andnet10.0.Quick start
SvgImageSourceplugs into the standardImagecontrol, so an SVG renders like any other image — and stays crisp at any size (it re-renders at the laid-out size instead of stretching a bitmap):SvgImageSourceis anIVectorImageSource:Imagedraws it vector at the current size each paint, so it stays sharp when resized or on high-DPI displays.Loading
Recoloring (monochrome icons)
Set
Tintto recolor icons whose fill is inherited (no explicit per-element fill). Changing it re-renders the hosting control automatically:IntrinsicSize— the SVG viewBox size (used byImagefor measuring).RasterWidth/RasterHeight— only affect theCreateImageraster fallback (e.g. when something asks the source for pixels); the vectorImagepath ignores them.Advanced: SvgDocument
For direct document access, the SVG.NET engine type
SvgDocument(namespaceSvg) is available:Use
doc.ViewBoxWidth/doc.ViewBoxHeightfor aspect ratio. For most cases preferSvgImageSource+Image.Backends
MewUI.Svg only uses
IGraphicsContext, so it renders on whichever backend the host app registers. Direct2D and MewVG (OpenGL) give the best curve/text quality; GDI works but anti-aliases curves and text less smoothly.Building from source
SVG.NET is brought in as a git submodule and its non-
System.Drawingsource is compiled into this assembly, so initialize submodules before building:The submodule (
ThirdParty/SvgNet) is kept pristine; the*.Drawing.csrendering partials are excluded and replaced by the MewUI*.MewUI.cspartials in this project.Dependencies
Aprillz.MewUIand ExCSS (CSS style parsing). SVG.NET itself is compiled in, not a package reference.License
Aprillz.MewUI.Svgis MIT. It includes a copy of SVG.NET (Microsoft Public License, Ms-PL); seeTHIRD_PARTY_NOTICES.md. System.Drawing is not used or redistributed.Aprillz.MewUI.Svg
MewUI의
IGraphicsContext로 그리는 MewUI용 SVG 파싱/렌더링 확장입니다.순수 관리 코드, System.Drawing 비의존. SVG.NET을 기반으로 하되
System.Drawing렌더링을 MewUIIGraphicsContext백엔드로 교체했습니다. 따라서 모든 MewUI 백엔드(Direct2D, GDI, MewVG/OpenGL)에서 SVG를 파싱/렌더링하며 NativeAOT/트리밍 호환입니다.설치
net8.0,net10.0을 대상으로 합니다.빠른 시작
SvgImageSource는 표준Image컨트롤에 그대로 꽂혀, SVG를 일반 이미지처럼 표시하면서 어떤 크기에서도 선명합니다(비트맵을 늘리는 게 아니라 레이아웃 크기로 다시 그림):SvgImageSource는IVectorImageSource라,Image가 매 페인트마다 현재 크기로 벡터를 그립니다. 리사이즈/고DPI에서도 선명합니다.로딩
재색칠 (단색 아이콘)
Tint를 설정하면 fill이 상속되는(요소별 명시 fill이 없는) 아이콘을 재색칠합니다. 변경 시 호스트 컨트롤이 자동으로 다시 그립니다:IntrinsicSize— SVG viewBox 크기(Image측정에 사용).RasterWidth/RasterHeight—CreateImage래스터 폴백(픽셀이 필요한 소비자용)에만 영향. 벡터Image경로는 무시.고급: SvgDocument
문서에 직접 접근하려면 SVG.NET 엔진 타입
SvgDocument(네임스페이스Svg)를 쓸 수 있습니다:비율 유지에는
doc.ViewBoxWidth/doc.ViewBoxHeight. 대부분의 경우SvgImageSource+Image를 권장합니다.백엔드
MewUI.Svg는
IGraphicsContext만 사용하므로 호스트 앱이 등록한 백엔드 위에서 렌더링됩니다. Direct2D와 MewVG(OpenGL)가 곡선/텍스트 품질이 가장 좋고, GDI도 동작하지만 곡선/텍스트 안티앨리어싱 품질이 떨어집니다.소스에서 빌드
SVG.NET은 git submodule로 가져와
System.Drawing비의존 소스만 이 어셈블리에 컴파일됩니다. 빌드 전에 submodule을 초기화하세요:submodule(
ThirdParty/SvgNet)은 원본 그대로 유지됩니다.*.Drawing.cs렌더링 partial은 제외되고 이 프로젝트의 MewUI*.MewUI.cspartial로 대체됩니다.의존성
Aprillz.MewUI와 ExCSS(CSS 스타일 파싱). SVG.NET 자체는 컴파일되어 들어가므로 패키지 참조가 아닙니다.라이선스
Aprillz.MewUI.Svg는 MIT입니다. SVG.NET(Microsoft Public License, Ms-PL) 사본을 포함하며,THIRD_PARTY_NOTICES.md를 참고하세요. System.Drawing은 사용하거나 재배포하지 않습니다.Beta Was this translation helpful? Give feedback.
All reactions