Git Product home page Git Product logo

vectorimage's Introduction

Vector Image Widget

This widget uses SVG to render images.

This is intended primarily for icon images where they are needed in multiple sizes, styles, colours, and need to look sharp on all platforms.

Need an icon to be 40mm? What's the dpi on every device that exists and ever will exist?

Need an icon in five different colours? How large would your app be if you were to generate five separate images in all the different scaling factors? What if you need to make a simple change? Tell your designers to spin up 25 new assets for you!

What about font icons?

Font icons have a few limitations. They cannot be positioned precisely, they can only be one colour, the cannot be styled, and they difficult to modify, and nearly impossible to change on the fly.

By using SVG images and an optional style sheet, this widget can use a single image, and a handful of stylesheets to create rich vector images, that look sharp on every platform, without having to generate dozens of copies of every image for every platform.

Getting started

git clone [email protected]:appcelerator-services/VectorImage.git

This git provides a sample app to explore that shows two different use cases.

  1. The first case is three different icons, all looking sharp. These are done with a single SVG image and three style sheets.
  2. The second case is a complex SVG image that renders sharp on all platforms.

To use the widget

<Widget class="light" src="com.capnajax.vectorimage" 
	svg="svg/light.svg" style="svg/stop.css"/>

That's all there is to it. The two parameters svg and style are the locations of the files, or the svg and css code itself.

Alloy.createWidget({
	src:"com.capnajax.vectorimage",
	svg:"svg/light.svg",
	css:"circle{stroke:#f60}"
});

The image will scale to fit the space provided by the widget but will not change its aspect ratio.

Known Issues

This widget has a cacheing feature, the rendered SVG is saved as a blob in the app's cache. Unfortunately this is not working at the moment, and there will be a fix coming soon.

The demonstration app uses rotation transforms which are not supported by an Android versions Jelly Bean or older.

vectorimage's People

Contributors

thomasdelbert avatar loloof64 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.