{"id":16378029,"url":"https://github.com/devsrsouza/svg-to-compose","last_synced_at":"2025-04-09T05:11:08.701Z","repository":{"id":39630611,"uuid":"311092034","full_name":"DevSrSouza/svg-to-compose","owner":"DevSrSouza","description":"Converts SVG and Android Vector Drawable in Compose Multiplatform source code","archived":false,"fork":false,"pushed_at":"2024-09-15T21:42:11.000Z","size":122,"stargazers_count":451,"open_issues_count":18,"forks_count":38,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T04:04:08.074Z","etag":null,"topics":["android","compose-for-desktop","compose-jb","compose-multiplatform","compose-multiplatform-library","jetpack-compose","kotlin","svg"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevSrSouza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-08T15:23:31.000Z","updated_at":"2025-03-31T10:22:24.000Z","dependencies_parsed_at":"2023-12-27T21:16:40.625Z","dependency_job_id":"0cab33e1-8c8e-4fb6-8f6f-29ecf7c97c41","html_url":"https://github.com/DevSrSouza/svg-to-compose","commit_stats":{"total_commits":39,"total_committers":7,"mean_commits":5.571428571428571,"dds":"0.15384615384615385","last_synced_commit":"0dc8f216386013b63719427dd9b71434796bb05b"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2Fsvg-to-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2Fsvg-to-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2Fsvg-to-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2Fsvg-to-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevSrSouza","download_url":"https://codeload.github.com/DevSrSouza/svg-to-compose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980837,"owners_count":21027808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","compose-for-desktop","compose-jb","compose-multiplatform","compose-multiplatform-library","jetpack-compose","kotlin","svg"],"created_at":"2024-10-11T03:44:28.515Z","updated_at":"2025-04-09T05:11:08.678Z","avatar_url":"https://github.com/DevSrSouza.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SVG to Compose [Experimental]\n\nConverts SVG or Android Vector Drawable to Compose code.\n\n- [Android Studio/IntelliJ plugin](https://plugins.jetbrains.com/plugin/18619-svg-to-compose) by [overpass](https://github.com/overpas)\n\n### Why this project\n\nOn the start of the [Compose for Desktop](https://www.jetbrains.com/lp/compose/) it does not support SVG files and Android Vector Drawables. This also difficulties a migration of the App to Multiplatform (Desktop and Android).\nCurrently, it does support Android Vector Drawables in the Desktop allowing share your vectors. \n\n### Use cases\n\nNow Compose for Desktop supports android vector drawables, this means that the first reason that the project was created does not apply anymore,\nthis does not mean that it is not useful anymore.\n\nUse cases:\n- Manipulate dynamic an SVG file in code, you can generate and do source code modifications.\n- Create an Icon pack similar to how Material Icons works on Compose ([compose-icons](https://github.com/DevSrSouza/compose-icons) is build with SVG to Compose)\n\n### How its work\n\nThe project uses Android's [Svg2Vector](https://android.googlesource.com/platform/tools/base/+/master/sdk-common/src/main/java/com/android/ide/common/vectordrawable/Svg2Vector.java) to convert SVG to Android Drawables and uses a customized material icon code generator from the Jetpack Compose [source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material/material/icons/generator/) to generate the source code of the SVG file.\n\n### Example 1: Running with Kotlin Scripting\n\nfile: `jetnews-drawables-to-compose.main.kts`\n\n```kotlin\n@file:Repository(\"https://jitpack.io\")\n@file:Repository(\"https://maven.google.com\")\n@file:Repository(\"https://jetbrains.bintray.com/trove4j\")\n\n@file:DependsOn(\"com.github.DevSrSouza:svg-to-compose:-SNAPSHOT\")\n@file:DependsOn(\"com.google.guava:guava:23.0\")\n@file:DependsOn(\"com.android.tools:sdk-common:27.2.0-alpha16\")\n@file:DependsOn(\"com.android.tools:common:27.2.0-alpha16\")\n@file:DependsOn(\"com.squareup:kotlinpoet:1.7.2\")\n@file:DependsOn(\"org.ogce:xpp3:1.1.6\")\n\nimport br.com.devsrsouza.svg2compose.Svg2Compose\nimport br.com.devsrsouza.svg2compose.VectorType\nimport java.io.File\n\nval assetsDir = File(\"assets\")\nval srcDir = File(\"src/main/kotlin\")\n\nSvg2Compose.parse(\n    applicationIconPackage = \"assets\",\n    accessorName = \"JetnewsAssets\",\n    outputSourceDirectory = srcDir,\n    vectorsDirectory = assetsDir,\n    type = VectorType.DRAWABLE,\n    allAssetsPropertyName = \"AllAssets\"\n)\n```\n\n![](https://i.imgur.com/f7txCag.png)\n\nGenerating code by using executing `kotlin jetnews-drawables-to-compose`\n\n![](https://i.imgur.com/5UTmT70.png)\n\n**Using in code**: `JetnewsAssets.JetnewsLogo`\n\n![](https://i.imgur.com/YAriDvV.png)\n\n#### Svg\n\nThe only difference for SVG files is the `VectorType.SVG`.\n\n### Example 2: Generating a whole Icon pack\n\nFor Icon Packs, subgroups is supported: `IconPack/group/icon.svg`\n\n![](https://i.imgur.com/cunhmxl.png)\n\n```kotlin\nval assetsDir = File(\"linea-icons\")\nval srcDir = File(\"src/main/kotlin\")\n\nSvg2Compose.parse(\n    applicationIconPackage = \"assets\",\n    accessorName = \"LineaIcons\",\n    outputSourceDirectory = srcDir,\n    vectorsDirectory = assetsDir,\n    type = VectorType.SVG,\n    iconNameTransformer = { name, group -\u003e name.removePrefix(group) },\n    allAssetsPropertyName = \"AllIcons\"\n)\n```\n\n**Using in code**: `LineaIcons.Arrows.Buhttps://github.com/overpas/svg-to-compose-intellijttonUp`\n\nThe project also generate an accessor for all yours assets, for the given example, it should be `LineaIcons.AllIcons` and it also generated for child groups `LineaIcons.Arrows.AllIcons`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsrsouza%2Fsvg-to-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevsrsouza%2Fsvg-to-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsrsouza%2Fsvg-to-compose/lists"}