LunaSVG는 가볍고 휴대 가능하도록 설계된 C++의 SVG 렌더링 라이브러리로, SVG(Scalable Vector Graphics) 파일의 효율적인 렌더링 및 조작을 제공합니다.
# include < lunasvg.h >
using namespace lunasvg ;
int main ()
{
auto document = Document::loadFromFile ( " tiger.svg " );
if (document == nullptr )
return - 1 ;
auto bitmap = document-> renderToBitmap ();
if (bitmap. isNull ())
return - 1 ;
bitmap. writeToPng ( " tiger.png " );
return 0 ;
}
LunaSVG는 SVG 1.1 및 SVG 1.2 Tiny 사양에 설명된 거의 모든 그래픽 기능을 지원합니다. 주요 예외는 애니메이션, 필터 및 스크립트입니다. LunaSVG는 정적 렌더링을 위해 설계되었으므로 앞으로 애니메이션이 지원되지 않을 것입니다. 그러나 필터에 대한 지원이 추가될 수 있습니다. 현재 다음을 포함하여 다양한 요소를 처리합니다.
<a>
<circle>
<clipPath>
<defs>
<ellipse>
<g>
<image>
<line>
<linearGradient>
<marker>
<mask>
<path>
<pattern>
<polygon>
<polyline>
<radialGradient>
<rect>
<stop>
<style>
<svg>
<symbol>
<text>
<tspan>
<use>
CMake 또는 Meson을 사용하여 LunaSVG를 설치하려면 아래 단계를 따르세요.
git clone https://github.com/sammycage/lunasvg.git
cd lunasvg
cmake -B build .
cmake --build build
cmake --install build
LunaSVG를 설치한 후 find_package
사용하여 CMake 프로젝트에 라이브러리를 포함할 수 있습니다.
find_package (lunasvg REQUIRED)
# Link LunaSVG to your target
target_link_libraries (your_target_name PRIVATE lunasvg::lunasvg)
또는 CMake의 FetchContent
사용하여 LunaSVG를 먼저 설치할 필요 없이 프로젝트에 직접 포함할 수 있습니다.
include (FetchContent)
FetchContent_Declare(
lunasvg
GIT_REPOSITORY https://github.com/sammycage/lunasvg.git
GIT_TAG master # Specify the desired branch or tag
)
FetchContent_MakeAvailable(lunasvg)
# Link LunaSVG to your target
target_link_libraries (your_target_name PRIVATE lunasvg::lunasvg)
your_target_name
실행 파일 또는 라이브러리 대상의 이름으로 바꾸십시오.
git clone https://github.com/sammycage/lunasvg.git
cd lunasvg
meson setup build
meson compile -C build
meson install -C build
LunaSVG를 설치한 후 dependency
기능을 사용하여 Meson 프로젝트에 라이브러리를 포함할 수 있습니다.
lunasvg_dep = dependency ( ' lunasvg ' , required : true )
또는 LunaSVG를 먼저 설치할 필요 없이 프로젝트에 직접 포함하려면 lunasvg.wrap
subprojects
디렉터리에 추가하세요. 다음 내용으로 lunasvg.wrap
이라는 파일을 만듭니다.
[wrap-git]
url = https://github.com/sammycage/lunasvg.git
revision = head
depth = 1
[provide]
lunasvg = lunasvg_dep
다음을 사용하여 랩 대체에서 종속성을 검색할 수 있습니다.
lunasvg_dep = dependency ( ' lunasvg ' , fallback : [ ' lunasvg ' , ' lunasvg_dep ' ])
LunaSVG는 SVG 파일을 PNG 형식으로 변환하기 위한 명령줄 도구 svg2png
제공합니다.
svg2png [filename] [resolution] [bgColor]
$ svg2png input.svg
$ svg2png input.svg 512x512
$ svg2png input.svg 512x512 0xff00ffff