Android SVG Scripts


Source link: https://github.com/DreaminginCodeZH/AndroidSVGScripts

Android SVG Scripts

Bash scripts to automate and extend the process of using SVG as Android image asset.

This project is also used by DreaminginCodeZH/MaterialColdStart.

Dependencies

  • inkscape: For PNG genration
  • gcalccmd (shsvgdpi.sh): For (friendly) mathematical calculation.

svgdpi.sh

Usage: svgdpi.sh SVG_FILE [DIR_PREFIX [DIR_SUFFIX]] 

This script can automatically generate PNG asset of different Dips from SVG arranged properly for direct usage in Android application.

For instance:

./svgdpi.sh path/to/your/file.avg 

Will output the following files:

drawable-mdpi/file.png drawable-hdpi/file.png drawable-xhdpi/file.png drawable-xxhdpi/file.png drawable-xxxhdpi/file.png 

You can also add prefix and suffix to the drawable directory name with command line arguments. See the script source for more detail.

shsvgdpi.sh

Usage: shsvgdpi.sh SHSVG_FILE [DIR_PREFIX [DIR_SUFFIX]] 

This script implemented a powerful new file format called ShellSVG ( .shsvg), which allows you to embed any shell command/parameter substitution inside your SVG file.

dp (Device-independent Pixel) is supported as an exported function dp(), and mathematical expression is supported as an exported function calc(). You need to wrap dp() inside a calc() if it is used.

This makes drawing Nine-patch bitmaps where the surrounding lines are always 1px while the content must be drawn in dp easy.

What's more, you can now use parameters inside your SVG, a dimension, a color, a filter, everything is OK. Just do it as in shell, for instance ${ SOME_PARAMETER } . Parameter definitions can be written in a .conf file which will be source-ed before generation of a standard SVG file, which means this file can have all the shell semantics apart from regular key-value pair, such as source-ing another .conf.

This script has taken rounding on HDPI (with scaling factor 1.5) into account, so that nine-patch bitmaps won't have an anti-aliased border. It is recommended that you call dp() for every single dp dimension separately to avoid accumulated rounding inconsistency.

The usage of this script is just like svgdpi.sh.

For a detailed example, see the sample/ directory.

License

Copyright (c) 2015 Zhang Hai <[email protected]>  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.  You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>. 

Resources

RecyclerViewHelper provides the most common functions around recycler view like Swipe to dismiss, Drag and Drop, Divider in the ui, events for when item selected and when not selected, on-click listener for items.

Reactive Billing is a lightweight reactive wrapper around In App Billing API v3 for Android.

Easy splash screen library allows you to generate beautiful and customizable Splash screens with less effort.

A library that allows you to enable/disable features and/or part of code regarding a Context.

Adapter library for RecyclerView to display your app's OSS dependencies.

Estimates the size of a Google Play patch and the new gzipped APK.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes