### Install SVGO and Avocado via npm Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Installs SVGO for SVG optimization and Avocado for Android VectorDrawable optimization globally using npm. ```console npm -g install svgo ``` ```console npm -g install avocado ``` -------------------------------- ### Install SVGO for SVG Optimization Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md This command installs the SVGO tool globally using npm. SVGO is used to optimize SVG files by reducing the complexity of their paths, which is a feature of the SVG to Compose tool. ```bash npm -g install svgo ``` -------------------------------- ### Install Avocado for Android VectorDrawable Optimization Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md This command installs the Avocado tool globally using npm. Avocado is used to optimize Android VectorDrawable and AnimatedVectorDrawable XML files, which is another optimization feature supported by the SVG to Compose tool. ```bash npm -g install avocado ``` -------------------------------- ### Map Icon Names Example Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Demonstrates how to use the --map-icon-name-from-to option to rename icons during conversion, such as removing a specific suffix. This is useful for cleaning up icon names. ```console s2c \ -o ./my-app/src/my/pkg/icons \ -rt Icons.Filled \ --map-icon-name-from-to "_filled" ""\ ./my-app/assets/svgs ``` -------------------------------- ### Show SVG-to-Compose CLI Help Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Displays the help message for the svg-to-compose command-line tool, outlining all available options and arguments for advanced usage. ```console s2c --help ``` -------------------------------- ### SVG-to-Compose CLI Help Output Details Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Provides a detailed breakdown of the command-line interface's options for the svg-to-compose tool, including version, package, theme, output, optimization, receiver type, and more. ```console Usage: s2c [] Options: -v, --version Show this CLI version -p, --package= Specify icons' package. This will replace package at the top of the icon file -t, --theme= Specify project's theme name. This will take place in the Icon Preview composable function and in the ImageVector Builder's names. -o, --output= output filename; if no .kt extension specified, it will be automatically added. In case of the input is a directory, output MUST also be a directory. -opt, --optimize=true|false Enable SVG/AVG optimization before parsing to Jetpack Compose icon. The optimization process uses the following programs: svgo, avocado from NPM Registry -rt, --receiver-type= Adds a receiver type to the Icon definition. This will generate the Icon as a extension of the passed argument. E.g.: s2c -o MyIcon.kt -rt Icons.Filled my-icon.svg will creates the Compose Icon: val Icons.Filled.MyIcon: ImageVector. --add-to-material Add the icon to the Material Icons context provider. --debug Enable debug log. --verbose Enable verbose log. -np, --no-preview Removes the preview function from the file. It is very useful if you are generating the icons for KMP, since KMP doesn't support previews yet. --kmp Ensures the output is compatible with KMP. Default: false --make-internal Mark the icon as internal --minified Remove all comments explaining the path logic creation and inline all method parameters. -r, --recursive Enables parsing of all files in the input directory, including those in subdirectories up to a maximum depth of 10 --recursive-depth, --depth= The depth level for recursive file search within directory. The default value is 10. --silent Enable silent run mode. This will suppress all the output logs this CLI provides. --exclude= A regex used to exclude some icons from the parsing. --map-icon-name-from-to, --from-to, --rename=... Replace the icon's name first value of this parameter with the second. This is useful when you want to remove part of the icon's name from the output icon. Example: ╭────────────────────────────────────────────╮ │ s2c \ │ -o ./my-app/src/my/pkg/icons \ │ -rt Icons.Filled \ │ --map-icon-name-from-to "_filled" ""│ │ ./my-app/assets/svgs │ ╰────────────────────────────────────────────╯ -h, --help Show this message and exit Arguments: file *.svg | *.xml | directory ``` -------------------------------- ### Run Web Application (Gradle Task) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/playground-kmp/README.md This Gradle task is used to open and run the web application developed with Compose Multiplatform. It specifically targets the wasmJsBrowserDevelopmentRun configuration. ```gradle open the web application by running the ":composeApp:wasmJsBrowserDevelopmentRun" Gradle task. ``` -------------------------------- ### Configure Common svg-to-compose Settings Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose-gradle-plugin/README.md Defines common settings for all SVG processors, including optimization, recursive directory traversal, and icon-specific configurations like minification. It also sets up specific icon sets for 'outlined' and 'filled' icons with their respective source directories and destination packages. ```kotlin svgToCompose { processor { common { optimize(true) recursive() icons { minify() } } val outlinedIcons by creating { from(layout.projectDirectory.dir("src/main/resources/icons/outlined")) destinationPackage("com.example.app.ui.icons.outlined") } val filledIcons by creating { from(layout.projectDirectory.dir("src/main/resources/icons/filled")) destinationPackage("com.example.app.ui.icons.filled") } } } ``` -------------------------------- ### Convert Directory of SVGs/Drawables to Compose Icons Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Recursively converts all SVG and Android Drawable XML files within a specified directory to Jetpack Compose Icons. The output path must also be a directory. ```console s2c -o /my/desired/directory \ -p your.app.package.icon \ -t your.app.package.theme.YourAppComposeTheme \ /my/svg/or/xml/directory ``` -------------------------------- ### Grant Execution Permission to s2c Script Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md This command grants execute permissions to the 's2c' script, making it runnable. It's a necessary step after downloading or cloning the project. ```console chmod +xw s2c ``` -------------------------------- ### SVG to Compose Gradle Plugin Basic Configuration Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Configures the SVG to Compose Gradle plugin to process icons from a specific directory, set a destination package, and define the Compose theme. ```kotlin svgToCompose { processor { val projectIcons by creating { from(layout.projectDirectory.dir("src/main/resources/icons")) destinationPackage("com.example.app.ui.icons") icons { theme("com.example.app.ui.theme.AppTheme") } // Additional configurations... } } } ``` -------------------------------- ### SVG to Compose CLI: Convert SVG to Compose Icon Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Converts a single SVG file into a Jetpack Compose Icon Kotlin file, specifying the output file, package name, and theme class. ```console s2c -o OutputIconFile.kt \ -p your.app.package.icon \ -t your.app.package.theme.YourAppComposeTheme \ input.svg ``` -------------------------------- ### Configure Gradle Plugin Repositories Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Ensures that Maven Central and Gradle Plugin Portal are included in the plugin management repositories for resolving the SVG to Compose plugin. ```kotlin pluginManagement { repositories { mavenCentral() gradlePluginPortal() } } ``` -------------------------------- ### Convert SVG to Compose Icon (With Optimization) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Converts an SVG file to a Jetpack Compose Composable Icon with optimizations applied. This command takes the output path, package name, theme, optimization flag (true), and the input SVG file path as arguments. ```console ./s2c -o /app/src/main/java/dev/tonholo.composeicons/ui/icon/ShieldSolid.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=true \ /shield-halved-solid.svg ``` ```console ./s2c -o /app/src/main/java/dev/tonholo.composeicons/ui/icon/Illustration.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=true \ /illustration.svg ``` -------------------------------- ### Convert Android Drawable to Compose Icon Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Converts a single Android Drawable XML file into a Jetpack Compose Icon. Requires specifying the output file, package name, and theme. ```console s2c -o OutputIconFile.kt \ -p your.app.package.icon \ -t your.app.package.theme.YourAppComposeTheme \ input.xml ``` -------------------------------- ### Configure .gitignore for s2c Output Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Adds the '.s2c' hidden folder to the .gitignore file to prevent version control conflicts. ```gitignore .s2c ``` -------------------------------- ### Enable Parallel Processing for svg-to-compose Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose-gradle-plugin/README.md Enables experimental parallel processing for faster icon generation by specifying the number of parallel threads to use. This feature is experimental and might lead to unexpected behavior. ```kotlin svgToCompose { processor { @OptIn(dev.tonholo.s2c.annotations.ExperimentalParallelProcessing) useParallelism(parallelism = 4) // Processor configurations... } } ``` -------------------------------- ### Configure SVG to Compose Gradle Plugin Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose-gradle-plugin/README.md This snippet shows a basic configuration for the SVG to Compose Gradle plugin within your build.gradle.kts file. It specifies the input icon directory, destination package, optimization settings, and icon processing rules. ```kotlin svgToCompose { processor { val icons by creating { from(layout.projectDirectory.dir("src/main/resources/icons")) destinationPackage("com.example.app.ui.icons") optimize(true) recursive() icons { theme("com.example.app.ui.theme.AppTheme") minify() exclude(".*_exclude\.svg".toRegex()) mapIconNameTo { iconName -> iconName.replace("_filled", "") } } } } } ``` -------------------------------- ### Apply SVG to Compose Gradle Plugin Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Applies the 'dev.tonholo.s2c' Gradle plugin to your project's build.gradle.kts file. ```kotlin plugins { id("dev.tonholo.s2c") version "" } ``` -------------------------------- ### Convert SVG to Compose Icon Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Converts a single SVG file into a Jetpack Compose Icon. Specifies output file, package name, and theme for the generated composable. ```console s2c -o OutputIconFile.kt \ -p your.app.package.icon \ -t your.app.package.theme.YourAppComposeTheme \ input.svg ``` -------------------------------- ### Grant Execution Permission to s2c Script Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Sets execute permissions for the 's2c' script, allowing it to be run from the command line. ```console chmod +xw s2c ``` -------------------------------- ### Add s2c Script to System PATH Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md This command adds the directory containing the 's2c' script to your system's PATH environment variable. This allows you to run the 's2c' command from any location in your terminal. ```shell export PATH=:$PATH ``` -------------------------------- ### Apply SVG to Compose Gradle Plugin (buildSrc/Build Conventions) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose-gradle-plugin/README.md After adding the plugin as a dependency in buildSrc or a build conventions plugin, apply it to your module's build.gradle.kts using the plugins block. ```kotlin plugins { id("dev.tonholo.s2c") } ``` -------------------------------- ### Apply SVG to Compose Gradle Plugin (Plugins DSL) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose-gradle-plugin/README.md This snippet shows how to apply the SVG to Compose Gradle plugin to your module's build.gradle.kts file using the Plugins DSL. Ensure Maven Central is available in your plugin repositories. ```kotlin plugins { id("dev.tonholo.s2c") version "" } pluginManagement { repositories { mavenCentral() gradlePluginPortal() } } ``` -------------------------------- ### SVG to Compose CLI: Convert Directory of Vectors Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Converts all SVG and VectorDrawable files within a specified directory into Jetpack Compose Icons, outputting them to a designated directory. ```console s2c -o /my/desired/directory \ -p your.app.package.icon \ -t your.app.package.theme.YourAppComposeTheme \ /my/svg/or/xml/directory ``` -------------------------------- ### Add s2c Script to PATH Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Adds the directory containing the 's2c' script to the system's PATH environment variable, enabling execution from any location. ```shell export PATH=:$PATH ``` -------------------------------- ### Convert SVG to Compose Icon (Without Optimization) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Converts an SVG file to a Jetpack Compose Composable Icon without applying any optimizations. This command takes the output path, package name, theme, optimization flag (false), and the input SVG file path as arguments. ```console ./s2c -o /app/src/main/java/dev/tonholo/composeicons/ui/icon/ShieldSolid.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=false \ /shield-halved-solid.svg ``` ```console ./s2c -o /app/src/main/java/dev/tonholo/composeicons/ui/icon/Illustration.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=false \ /illustration.svg ``` -------------------------------- ### SVG to Compose CLI: Convert AVD to Compose Icon Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Converts an Android Vector Drawable (XML) file into a Jetpack Compose Icon Kotlin file, specifying the output file, package name, and theme class. ```console s2c -o OutputIconFile.kt \ -p your.app.package.icon \ -t your.app.package.theme.YourAppComposeTheme \ input.xml ``` -------------------------------- ### Convert SVG to Compose (Non-Optimized) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Converts an SVG file to Jetpack Compose Kotlin code without applying optimizations. Requires specifying the output path, package name, theme, and input SVG file path. ```console s2c -o /app/src/main/java/dev/tonholo/composeicons/ui/icon/ShieldSolid.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=false \ /shield-halved-solid.svg ``` ```console s2c -o /app/src/main/java/dev/tonholo/composeicons/ui/icon/Illustration.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=false \ /illustration.svg ``` -------------------------------- ### Enable Persistent Generation for svg-to-compose Icons Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose-gradle-plugin/README.md Configures the plugin to persist generated icon files directly into the source set, overwriting existing files. This operation is delicate and should be used with caution. ```kotlin svgToCompose { processor { val persistentIcons by creating { // Processor configurations... icons { @OptIn(dev.tonholo.s2c.annotations.DelicateSvg2ComposeApi) persist() } } } } ``` -------------------------------- ### Convert SVG to Compose (Optimized) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/README.md Converts an SVG file to Jetpack Compose Kotlin code with optimizations enabled. This process may result in more efficient composable functions. Requires specifying the output path, package name, theme, and input SVG file path. ```console s2c -o /app/src/main/java/dev/tonholo/composeicons/ui/icon/ShieldSolid.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=true \ /shield-halved-solid.svg ``` ```console s2c -o /app/src/main/java/dev/tonholo/composeicons/ui/icon/Illustration.kt \ -p dev.tonholo.composeicons.ui.icon \ --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \ -opt=true \ /illustration.svg ``` -------------------------------- ### Add SVG to Compose Gradle Plugin Dependency (buildSrc) Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose-gradle-plugin/README.md This snippet demonstrates how to add the SVG to Compose Gradle plugin as a dependency within your buildSrc/build.gradle.kts file. This approach is useful for managing plugins via buildSrc. ```kotlin repositories { mavenCentral() } dependencies { implementation("dev.tonholo.s2c:svg-to-compose-gradle-plugin:") } ``` -------------------------------- ### Convert SVG with Disabled Optimization Source: https://github.com/rafaeltonholo/svg-to-compose/blob/main/svg-to-compose/README.md Converts an SVG file to a Compose Icon while disabling the default SVG optimization process. Useful for debugging or when optimization is not desired. ```console s2c -o OutputIconFile.kt \ -p your.app.package.icon \ -t your.app.package.theme.YourAppComposeTheme \ --optimize false \ input.svg ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.