mirror of
https://github.com/izzy2lost/PCSX2_ARM64.git
synced 2026-06-19 10:16:23 -07:00
Android project
This commit is contained in:
+104
@@ -0,0 +1,104 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
set(PLUTOSVG_VERSION_MAJOR 0)
|
||||
set(PLUTOSVG_VERSION_MINOR 0)
|
||||
set(PLUTOSVG_VERSION_MICRO 6)
|
||||
|
||||
project(plutosvg LANGUAGES C VERSION ${PLUTOSVG_VERSION_MAJOR}.${PLUTOSVG_VERSION_MINOR}.${PLUTOSVG_VERSION_MICRO})
|
||||
|
||||
find_package(plutovg 1.0.0 QUIET)
|
||||
if(NOT plutovg_FOUND)
|
||||
add_subdirectory(plutovg)
|
||||
endif()
|
||||
|
||||
set(plutosvg_sources
|
||||
source/plutosvg.h
|
||||
source/plutosvg-ft.h
|
||||
source/plutosvg.c
|
||||
)
|
||||
|
||||
add_library(plutosvg ${plutosvg_sources})
|
||||
add_library(plutosvg::plutosvg ALIAS plutosvg)
|
||||
|
||||
set_target_properties(plutosvg PROPERTIES
|
||||
SOVERSION ${PLUTOSVG_VERSION_MAJOR}
|
||||
C_VISIBILITY_PRESET hidden
|
||||
C_STANDARD_REQUIRED ON
|
||||
C_STANDARD 99
|
||||
)
|
||||
|
||||
target_include_directories(plutosvg PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source
|
||||
)
|
||||
|
||||
target_include_directories(plutosvg PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/source>
|
||||
$<INSTALL_INTERFACE:include/plutosvg>
|
||||
)
|
||||
|
||||
target_link_libraries(plutosvg PUBLIC plutovg::plutovg)
|
||||
|
||||
find_library(MATH_LIBRARY m)
|
||||
if(MATH_LIBRARY)
|
||||
target_link_libraries(plutosvg PUBLIC ${MATH_LIBRARY})
|
||||
endif()
|
||||
|
||||
target_compile_definitions(plutosvg PRIVATE PLUTOSVG_BUILD)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(plutosvg PUBLIC PLUTOSVG_BUILD_STATIC)
|
||||
endif()
|
||||
|
||||
option(PLUTOSVG_ENABLE_FREETYPE "Enable Freetype integration" OFF)
|
||||
if(PLUTOSVG_ENABLE_FREETYPE)
|
||||
find_package(Freetype 2.12 REQUIRED)
|
||||
target_compile_definitions(plutosvg PUBLIC PLUTOSVG_HAS_FREETYPE)
|
||||
target_link_libraries(plutosvg PUBLIC Freetype::Freetype)
|
||||
endif()
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plutosvgConfig.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/plutosvgConfig.cmake"
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/plutosvg
|
||||
)
|
||||
|
||||
write_basic_package_version_file(plutosvgConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/plutosvg.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/plutosvg-ft.h
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/plutosvg
|
||||
)
|
||||
|
||||
install(TARGETS plutosvg
|
||||
EXPORT plutosvgTargets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
install(EXPORT plutosvgTargets
|
||||
FILE plutosvgTargets.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/plutosvg
|
||||
NAMESPACE plutosvg::
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/plutosvgConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/plutosvgConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/plutosvg
|
||||
)
|
||||
|
||||
export(EXPORT plutosvgTargets
|
||||
FILE ${CMAKE_CURRENT_BINARY_DIR}/plutosvgTargets.cmake
|
||||
NAMESPACE plutosvg::
|
||||
)
|
||||
|
||||
option(PLUTOSVG_BUILD_EXAMPLES "Build examples" ON)
|
||||
if(PLUTOSVG_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2025 Samuel Ugochukwu <sammycageagle@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+87
@@ -0,0 +1,87 @@
|
||||

|
||||
|
||||
# PlutoSVG
|
||||
|
||||
PlutoSVG is a compact and efficient SVG rendering library written in C. It is specifically designed for parsing and rendering SVG documents embedded in OpenType fonts, providing an optimal balance between speed and minimal memory usage. It is also suitable for rendering scalable icons.
|
||||
|
||||
## Basic Usage
|
||||
|
||||
```c
|
||||
#include <plutosvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
plutosvg_document_t* document = plutosvg_document_load_from_file("camera.svg", -1, -1);
|
||||
if(document == NULL) {
|
||||
printf("Unable to load: camera.svg\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
plutovg_surface_t* surface = plutosvg_document_render_to_surface(document, NULL, -1, -1, NULL, NULL, NULL);
|
||||
plutovg_surface_write_to_png(surface, "camera.png");
|
||||
plutosvg_document_destroy(document);
|
||||
plutovg_surface_destroy(surface);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Integrating with FreeType
|
||||
|
||||
```c
|
||||
#include <plutosvg-ft.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_MODULE_H
|
||||
|
||||
int main(void)
|
||||
{
|
||||
FT_Library library;
|
||||
|
||||
// Initialize the FreeType library
|
||||
if(FT_Init_FreeType(&library)) {
|
||||
// Handle error
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set PlutoSVG hooks for the SVG module
|
||||
if(FT_Property_Set(library, "ot-svg", "svg-hooks", &plutosvg_ft_hooks)) {
|
||||
// Handle error
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Your code here
|
||||
|
||||
// Clean up
|
||||
FT_Done_FreeType(library);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
Follow the steps below to install PlutoSVG using either [Meson](https://mesonbuild.com/) or [CMake](https://cmake.org/).
|
||||
|
||||
### Using Meson
|
||||
|
||||
```bash
|
||||
git clone https://github.com/sammycage/plutosvg.git
|
||||
cd plutosvg
|
||||
meson setup build
|
||||
meson compile -C build
|
||||
meson install -C build
|
||||
```
|
||||
|
||||
### Using CMake
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/sammycage/plutosvg.git
|
||||
cd plutosvg
|
||||
cmake -B build .
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
@@ -0,0 +1,6 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(plutovg)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/plutosvgTargets.cmake")
|
||||
@@ -0,0 +1,15 @@
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
FILE(COPY camera.svg DESTINATION "${CMAKE_BINARY_DIR}/examples")
|
||||
|
||||
add_executable(camera2png camera2png.c)
|
||||
target_link_libraries(camera2png plutosvg)
|
||||
|
||||
add_executable(svg2png svg2png.c)
|
||||
target_link_libraries(svg2png plutosvg)
|
||||
|
||||
if(PLUTOSVG_ENABLE_FREETYPE)
|
||||
add_executable(emoji2png emoji2png.c)
|
||||
target_link_libraries(emoji2png plutosvg)
|
||||
endif()
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 130 KiB |
@@ -0,0 +1,34 @@
|
||||
#include <plutosvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
plutosvg_document_t* document = NULL;
|
||||
plutovg_surface_t* surface = NULL;
|
||||
|
||||
fprintf(stdout, "Loading 'camera.svg'\n");
|
||||
document = plutosvg_document_load_from_file("camera.svg", -1, -1);
|
||||
if(document == NULL) {
|
||||
fprintf(stderr, "Unable to load 'camera.svg'\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Rendering 'camera.svg'\n");
|
||||
surface = plutosvg_document_render_to_surface(document, NULL, -1, -1, NULL, NULL, NULL);
|
||||
if(surface == NULL) {
|
||||
fprintf(stderr, "Unable to render 'camera.svg'\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Writing 'camera.png'\n");
|
||||
if(!plutovg_surface_write_to_png(surface, "camera.png")) {
|
||||
fprintf(stderr, "Unable to write 'camera.png'\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
plutovg_surface_destroy(surface);
|
||||
plutosvg_document_destroy(document);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <plutosvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_MODULE_H
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc != 4) {
|
||||
fprintf(stderr, "Usage: emoji2png font codepoint size\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* filename = argv[1];
|
||||
FT_ULong codepoint = strtoul(argv[2], NULL, 16);
|
||||
FT_ULong size = strtoul(argv[3], NULL, 10);
|
||||
|
||||
FT_Library library = NULL;
|
||||
FT_Face face = NULL;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
if((error = FT_Init_FreeType(&library)))
|
||||
goto cleanup;
|
||||
if((error = FT_Property_Set(library, "ot-svg", "svg-hooks", plutosvg_ft_svg_hooks())))
|
||||
goto cleanup;
|
||||
if((error = FT_New_Face(library, filename, 0, &face)))
|
||||
goto cleanup;
|
||||
if((error = FT_Set_Pixel_Sizes(face, 0, size)))
|
||||
goto cleanup;
|
||||
if((error = FT_Load_Char(face, codepoint, FT_LOAD_RENDER | FT_LOAD_COLOR))) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if(face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA) {
|
||||
plutovg_surface_t* surface = plutovg_surface_create_for_data(
|
||||
face->glyph->bitmap.buffer, face->glyph->bitmap.width,
|
||||
face->glyph->bitmap.rows, face->glyph->bitmap.pitch
|
||||
);
|
||||
|
||||
char name[64];
|
||||
sprintf(name, "emoji-%lx.png", codepoint);
|
||||
plutovg_surface_write_to_png(surface, name);
|
||||
plutovg_surface_destroy(surface);
|
||||
fprintf(stdout, "Generated Emoji: %s\n", name);
|
||||
} else {
|
||||
fprintf(stderr, "The glyph for codepoint %lx is not in color mode.\n", codepoint);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if(error) fprintf(stderr, "freetype error: %s\n", FT_Error_String(error));
|
||||
FT_Done_Face(face);
|
||||
FT_Done_FreeType(library);
|
||||
return error;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fs = import('fs')
|
||||
fs.copyfile('camera.svg')
|
||||
|
||||
executable('camera2png', 'camera2png.c', dependencies: plutosvg_dep)
|
||||
executable('svg2png', 'svg2png.c', dependencies: plutosvg_dep)
|
||||
if freetype_dep.found()
|
||||
executable('emoji2png', 'emoji2png.c', dependencies: [plutosvg_dep, freetype_dep])
|
||||
endif
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <plutosvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
static double elapsed_time(clock_t start, clock_t end)
|
||||
{
|
||||
return ((double)(end - start)) / CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc != 3 && argc != 4) {
|
||||
fprintf(stderr, "Usage: svg2png input output [id]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* input = argv[1];
|
||||
const char* output = argv[2];
|
||||
const char* id = NULL;
|
||||
if(argc == 4) {
|
||||
id = argv[3];
|
||||
}
|
||||
|
||||
plutosvg_document_t* document = NULL;
|
||||
plutovg_surface_t* surface = NULL;
|
||||
clock_t start, end;
|
||||
|
||||
start = clock();
|
||||
document = plutosvg_document_load_from_file(input, -1, -1);
|
||||
end = clock();
|
||||
|
||||
if(document == NULL) {
|
||||
fprintf(stderr, "Unable to load '%s'\n", input);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Finished loading '%s' in %.3f seconds\n", input, elapsed_time(start, end));
|
||||
|
||||
start = clock();
|
||||
surface = plutosvg_document_render_to_surface(document, id, -1, -1, NULL, NULL, NULL);
|
||||
end = clock();
|
||||
|
||||
if(surface == NULL) {
|
||||
fprintf(stderr, "Unable to render '%s'\n", input);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Finished rendering '%s' in %.3f seconds\n", input, elapsed_time(start, end));
|
||||
|
||||
start = clock();
|
||||
if(!plutovg_surface_write_to_png(surface, output)) {
|
||||
fprintf(stderr, "Unable to write '%s'\n", output);
|
||||
goto cleanup;
|
||||
}
|
||||
end = clock();
|
||||
|
||||
fprintf(stdout, "Finished writing '%s' in %.3f seconds\n", output, elapsed_time(start, end));
|
||||
cleanup:
|
||||
plutovg_surface_destroy(surface);
|
||||
plutosvg_document_destroy(document);
|
||||
return 0;
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
project('plutosvg', 'c',
|
||||
version: '0.0.6',
|
||||
license: 'MIT',
|
||||
meson_version: '>=0.64.0',
|
||||
default_options: ['c_std=c99']
|
||||
)
|
||||
|
||||
plutosvg_deps = []
|
||||
plutosvg_compile_args = []
|
||||
|
||||
plutovg_dep = dependency('plutovg',
|
||||
required: true,
|
||||
version: '>=1.0.0',
|
||||
fallback: ['plutovg', 'plutovg_dep']
|
||||
)
|
||||
|
||||
plutosvg_deps += [plutovg_dep]
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
math_dep = cc.find_library('m', required: false)
|
||||
if math_dep.found()
|
||||
plutosvg_deps += [math_dep]
|
||||
endif
|
||||
|
||||
freetype_dep = dependency('freetype2',
|
||||
required: get_option('freetype'),
|
||||
version: '>=2.12',
|
||||
allow_fallback: false
|
||||
)
|
||||
|
||||
if freetype_dep.found() and cc.has_type('SVG_RendererHooks', dependencies: freetype_dep, prefix: '#include <freetype/otsvg.h>')
|
||||
plutosvg_deps += [freetype_dep]
|
||||
plutosvg_compile_args += ['-DPLUTOSVG_HAS_FREETYPE']
|
||||
else
|
||||
freetype_dep = disabler()
|
||||
endif
|
||||
|
||||
if get_option('default_library') == 'static'
|
||||
plutosvg_compile_args += ['-DPLUTOSVG_BUILD_STATIC']
|
||||
endif
|
||||
|
||||
plutosvg_lib = library('plutosvg', 'source/plutosvg.c',
|
||||
include_directories: include_directories('source'),
|
||||
dependencies: plutosvg_deps,
|
||||
version: meson.project_version(),
|
||||
c_args: ['-DPLUTOSVG_BUILD'] + plutosvg_compile_args,
|
||||
cpp_args: ['-DPLUTOSVG_BUILD'] + plutosvg_compile_args,
|
||||
gnu_symbol_visibility: 'hidden',
|
||||
install: true
|
||||
)
|
||||
|
||||
plutosvg_dep = declare_dependency(
|
||||
link_with: plutosvg_lib,
|
||||
dependencies: plutovg_dep,
|
||||
include_directories: include_directories('source'),
|
||||
compile_args: plutosvg_compile_args
|
||||
)
|
||||
|
||||
meson.override_dependency('plutosvg', plutosvg_dep)
|
||||
install_headers('source/plutosvg.h', 'source/plutosvg-ft.h', subdir: 'plutosvg')
|
||||
|
||||
if not get_option('examples').disabled()
|
||||
subdir('examples')
|
||||
endif
|
||||
|
||||
pkgmod = import('pkgconfig')
|
||||
pkgmod.generate(plutosvg_lib,
|
||||
name: 'PlutoSVG',
|
||||
description: 'Tiny SVG rendering library',
|
||||
filebase: 'plutosvg',
|
||||
subdirs: 'plutosvg'
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
option('examples', type : 'feature', value : 'auto')
|
||||
option('tests', type : 'feature', value : 'auto')
|
||||
option('freetype', type : 'feature', value : 'auto')
|
||||
@@ -0,0 +1,111 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
set(PLUTOVG_VERSION_MAJOR 1)
|
||||
set(PLUTOVG_VERSION_MINOR 0)
|
||||
set(PLUTOVG_VERSION_MICRO 0)
|
||||
|
||||
project(plutovg LANGUAGES C VERSION ${PLUTOVG_VERSION_MAJOR}.${PLUTOVG_VERSION_MINOR}.${PLUTOVG_VERSION_MICRO})
|
||||
|
||||
set(plutovg_sources
|
||||
source/plutovg-blend.c
|
||||
source/plutovg-canvas.c
|
||||
source/plutovg-font.c
|
||||
source/plutovg-matrix.c
|
||||
source/plutovg-paint.c
|
||||
source/plutovg-path.c
|
||||
source/plutovg-rasterize.c
|
||||
source/plutovg-surface.c
|
||||
source/plutovg-ft-math.c
|
||||
source/plutovg-ft-raster.c
|
||||
source/plutovg-ft-stroker.c
|
||||
)
|
||||
|
||||
set(plutovg_headers
|
||||
include/plutovg.h
|
||||
source/plutovg-private.h
|
||||
source/plutovg-utils.h
|
||||
source/plutovg-ft-math.h
|
||||
source/plutovg-ft-raster.h
|
||||
source/plutovg-ft-stroker.h
|
||||
source/plutovg-ft-types.h
|
||||
source/plutovg-stb-image-write.h
|
||||
source/plutovg-stb-image.h
|
||||
source/plutovg-stb-truetype.h
|
||||
)
|
||||
|
||||
add_library(plutovg ${plutovg_sources} ${plutovg_headers})
|
||||
add_library(plutovg::plutovg ALIAS plutovg)
|
||||
|
||||
set_target_properties(plutovg PROPERTIES
|
||||
SOVERSION ${PLUTOVG_VERSION_MAJOR}
|
||||
C_VISIBILITY_PRESET hidden
|
||||
C_STANDARD_REQUIRED ON
|
||||
C_STANDARD 99
|
||||
)
|
||||
|
||||
target_include_directories(plutovg PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source
|
||||
)
|
||||
|
||||
target_include_directories(plutovg PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include/plutovg>
|
||||
)
|
||||
|
||||
find_library(MATH_LIBRARY m)
|
||||
if(MATH_LIBRARY)
|
||||
target_link_libraries(plutovg PRIVATE ${MATH_LIBRARY})
|
||||
endif()
|
||||
|
||||
target_compile_definitions(plutovg PRIVATE PLUTOVG_BUILD)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(plutovg PUBLIC PLUTOVG_BUILD_STATIC)
|
||||
endif()
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plutovgConfig.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/plutovgConfig.cmake"
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/plutovg
|
||||
)
|
||||
|
||||
write_basic_package_version_file(plutovgConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/plutovg.h
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/plutovg
|
||||
)
|
||||
|
||||
install(TARGETS plutovg
|
||||
EXPORT plutovgTargets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
install(EXPORT plutovgTargets
|
||||
FILE plutovgTargets.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/plutovg
|
||||
NAMESPACE plutovg::
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/plutovgConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/plutovgConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/plutovg
|
||||
)
|
||||
|
||||
export(EXPORT plutovgTargets
|
||||
FILE ${CMAKE_CURRENT_BINARY_DIR}/plutovgTargets.cmake
|
||||
NAMESPACE plutovg::
|
||||
)
|
||||
|
||||
option(PLUTOVG_BUILD_EXAMPLES "Build examples" ON)
|
||||
if(PLUTOVG_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2025 Samuel Ugochukwu <sammycageagle@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,99 @@
|
||||
[](https://github.com/sammycage/plutovg/releases)
|
||||
[](https://github.com/sammycage/plutovg/blob/main/LICENSE)
|
||||
[](https://github.com/sammycage/plutovg/actions)
|
||||
[](https://www.codefactor.io/repository/github/sammycage/plutovg)
|
||||
|
||||
# PlutoVG
|
||||
PlutoVG is a standalone 2D vector graphics library in C.
|
||||
|
||||
## Features
|
||||
- Path Filling, Stroking and Dashing
|
||||
- Soild, Gradient and Texture Paints
|
||||
- Fonts and Texts
|
||||
- Clipping and Compositing
|
||||
- Transformations
|
||||
- Images
|
||||
|
||||
## Example
|
||||
```c
|
||||
#include <plutovg.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int width = 150;
|
||||
const int height = 150;
|
||||
|
||||
const float center_x = width / 2.f;
|
||||
const float center_y = height / 2.f;
|
||||
const float face_radius = 70;
|
||||
const float mouth_radius = 50;
|
||||
const float eye_radius = 10;
|
||||
const float eye_offset_x = 25;
|
||||
const float eye_offset_y = 20;
|
||||
const float eye_x = center_x - eye_offset_x;
|
||||
const float eye_y = center_y - eye_offset_y;
|
||||
|
||||
plutovg_surface_t* surface = plutovg_surface_create(width, height);
|
||||
plutovg_canvas_t* canvas = plutovg_canvas_create(surface);
|
||||
|
||||
plutovg_canvas_save(canvas);
|
||||
plutovg_canvas_arc(canvas, center_x, center_y, face_radius, 0, PLUTOVG_TWO_PI, 0);
|
||||
plutovg_canvas_set_rgb(canvas, 1, 1, 0);
|
||||
plutovg_canvas_fill_preserve(canvas);
|
||||
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
|
||||
plutovg_canvas_set_line_width(canvas, 5);
|
||||
plutovg_canvas_stroke(canvas);
|
||||
plutovg_canvas_restore(canvas);
|
||||
|
||||
plutovg_canvas_save(canvas);
|
||||
plutovg_canvas_arc(canvas, eye_x, eye_y, eye_radius, 0, PLUTOVG_TWO_PI, 0);
|
||||
plutovg_canvas_arc(canvas, center_x + eye_offset_x, eye_y, eye_radius, 0, PLUTOVG_TWO_PI, 0);
|
||||
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
|
||||
plutovg_canvas_fill(canvas);
|
||||
plutovg_canvas_restore(canvas);
|
||||
|
||||
plutovg_canvas_save(canvas);
|
||||
plutovg_canvas_arc(canvas, center_x, center_y, mouth_radius, 0, PLUTOVG_PI, 0);
|
||||
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
|
||||
plutovg_canvas_set_line_width(canvas, 5);
|
||||
plutovg_canvas_stroke(canvas);
|
||||
plutovg_canvas_restore(canvas);
|
||||
|
||||
plutovg_surface_write_to_png(surface, "smiley.png");
|
||||
plutovg_canvas_destroy(canvas);
|
||||
plutovg_surface_destroy(surface);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Follow the steps below to install PlutoVG using either [Meson](https://mesonbuild.com/) or [CMake](https://cmake.org/).
|
||||
|
||||
### Using Meson
|
||||
|
||||
```bash
|
||||
git clone https://github.com/sammycage/plutovg.git
|
||||
cd plutovg
|
||||
meson setup build
|
||||
meson compile -C build
|
||||
meson install -C build
|
||||
```
|
||||
|
||||
### Using CMake
|
||||
|
||||
```bash
|
||||
git clone https://github.com/sammycage/plutovg.git
|
||||
cd plutovg
|
||||
cmake -B build .
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
## Projects using PlutoVG
|
||||
- [LunaSVG](https://github.com/sammycage/lunasvg)
|
||||
- [PlutoSVG](https://github.com/sammycage/plutosvg)
|
||||
@@ -0,0 +1,3 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/plutovgTargets.cmake")
|
||||
@@ -0,0 +1,2 @@
|
||||
add_executable(smiley smiley.c)
|
||||
target_link_libraries(smiley plutovg)
|
||||
@@ -0,0 +1 @@
|
||||
executable('smiley', 'smiley.c', dependencies: plutovg_dep)
|
||||
@@ -0,0 +1,48 @@
|
||||
#include <plutovg.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int width = 150;
|
||||
const int height = 150;
|
||||
|
||||
const float center_x = width / 2.f;
|
||||
const float center_y = height / 2.f;
|
||||
const float face_radius = 70;
|
||||
const float mouth_radius = 50;
|
||||
const float eye_radius = 10;
|
||||
const float eye_offset_x = 25;
|
||||
const float eye_offset_y = 20;
|
||||
const float eye_x = center_x - eye_offset_x;
|
||||
const float eye_y = center_y - eye_offset_y;
|
||||
|
||||
plutovg_surface_t* surface = plutovg_surface_create(width, height);
|
||||
plutovg_canvas_t* canvas = plutovg_canvas_create(surface);
|
||||
|
||||
plutovg_canvas_save(canvas);
|
||||
plutovg_canvas_arc(canvas, center_x, center_y, face_radius, 0, PLUTOVG_TWO_PI, 0);
|
||||
plutovg_canvas_set_rgb(canvas, 1, 1, 0);
|
||||
plutovg_canvas_fill_preserve(canvas);
|
||||
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
|
||||
plutovg_canvas_set_line_width(canvas, 5);
|
||||
plutovg_canvas_stroke(canvas);
|
||||
plutovg_canvas_restore(canvas);
|
||||
|
||||
plutovg_canvas_save(canvas);
|
||||
plutovg_canvas_arc(canvas, eye_x, eye_y, eye_radius, 0, PLUTOVG_TWO_PI, 0);
|
||||
plutovg_canvas_arc(canvas, center_x + eye_offset_x, eye_y, eye_radius, 0, PLUTOVG_TWO_PI, 0);
|
||||
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
|
||||
plutovg_canvas_fill(canvas);
|
||||
plutovg_canvas_restore(canvas);
|
||||
|
||||
plutovg_canvas_save(canvas);
|
||||
plutovg_canvas_arc(canvas, center_x, center_y, mouth_radius, 0, PLUTOVG_PI, 0);
|
||||
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
|
||||
plutovg_canvas_set_line_width(canvas, 5);
|
||||
plutovg_canvas_stroke(canvas);
|
||||
plutovg_canvas_restore(canvas);
|
||||
|
||||
plutovg_surface_write_to_png(surface, "smiley.png");
|
||||
plutovg_canvas_destroy(canvas);
|
||||
plutovg_surface_destroy(surface);
|
||||
return 0;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user