Git Product home page Git Product logo

svgpathkotlin's Introduction

SVGPathKotlin

Simple library for drawing Path from svg path data written in Kotlin

Image

About

SVGPathKotlin is simple library that generate commands that are used for creating Path with applied curves, that can later be drawn to Canvas on any View. Commands are extracted from raw path data string that is passed as argument to the constructor of the SvgPath class. If you want to learn more about the library and how it works you check the official wiki page.

Platform API Download

Add to your project

Add the jitpack maven repository

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add the dependency

dependencies { 
  implementation 'com.github.slaviboy:SVGPathKotlin:0.3.0'
}

How to use

Create SvgPath object and pass you svg path data as string. To apply any of the available transformations: rotation, scale, skew or translate to the path, use the matrix variable. To change properties for the Paint object such as: strokeWidth, strokeColor, fillColor, opacity when the path is being drawn to the canvas use the renderProperties variable.

// create SvgPath object using raw path data as string
val svgPath = SvgPath("M 10 80 Q 52.5 10, 95 80 T 180 80")

// change stroke color and width for the path
svgPath.renderProperties.apply { 
     strokeWidth = 5.0f
     strokeColor = Color.GREEN
}
        
// apply transformation to the path using its matrix
svgPath.matrix.apply {
     postRotate(45.0f)
     postSkew(0.5f, 0.0f)
}

To check the available example on creating SvgPath and SvgPathGroup check the classes in the views package.

svgpathkotlin's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hieutv-ht

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.