Giter Club home page Giter Club logo

doodlecanvaslibrary's Introduction

A simple Android Library to allow drawing in Android

Want to provide functionality to draw on an android device? You can use this Library.

Every Action is performed nativley, so you can expect the best possible performance.

Add Library to Project:

1.) Add the JitPack repository to your project

Add this line in the build.gradle(app) file

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

2.) Add the dependency in your project

Add this line in the build.gradle(app) file

dependencies {
    .
    .
    implementation 'com.github.Luciferx86:DoodleCanvasLibrary:0.1.0-alpha3'
    .
    .
}

Use the DoodleCanvas View

.
.

<com.luciferx86.doodlecanvaslibrary.DoodleCanvas
        android:id="@+id/doodleCanvas"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
.
.

Use Canvas Properties

You can modify the canvas properties like current Paint color and Stroke Width.

Get a reference to the canvas

DoodleCanvas canvas;
.
.
.
public void onCreate(Bundle savedInstanceState)
{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.filters); 

        //get reference to canvas
        canvas = findViewById(R.id.doodleCanvas);
}
.
.

Set Paint Color

canvas.setStrokeColor(Color.GREEN);
//set custom color
canvas.setStrokeColor(Color.parseColor("#00ffbf"));

Set Stroke Width

// would recommend using something between 10f and 100f
canvas.setStrokeWidth(20f);

Enable or Disable drawing programmatically

// true and false are self explanatory
canvas.canUserDraw(false);

Undo Last move

// undo last path drawn
canvas.undoMove();

Enable Erasing

// simply sets the paint color to White, which acts as erasing 
canvas.enableErasing();

Enable Painting

// restores the last saved painting configuration
canvas.enablePainting();

Clear Out the canvas

// removes all paths on canvas
canvas.clearCanvas();

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.