All Projects → nateshmbhat → Touchable

nateshmbhat / Touchable

Licence: gpl-3.0
Flutter library to add gestures and animations to each Shape you draw on your canvas in your CustomPainter

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Touchable

Flutter Canvas
About using of canvas in the flutter
Stars: ✭ 259 (+215.85%)
Mutual labels:  paint, draw, canvas
Sketchpad
Sketchpad is fully customisable collaborative whiteboard plugin written in pure JavaScript.
Stars: ✭ 85 (+3.66%)
Mutual labels:  paint, draw, canvas
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-39.02%)
Mutual labels:  paint, draw, canvas
Photoeditor
A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
Stars: ✭ 3,105 (+3686.59%)
Mutual labels:  paint, canvas
awesome-canvas
Canvas资源库大全中文版。An awesome Canvas packages and resources.
Stars: ✭ 288 (+251.22%)
Mutual labels:  canvas, draw
Ananas
An easy image editor integration for your Android apps.
Stars: ✭ 186 (+126.83%)
Mutual labels:  paint, canvas
Tui.image Editor
🍞🎨 Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.
Stars: ✭ 4,761 (+5706.1%)
Mutual labels:  paint, canvas
React Sketch
Sketch Tool for React-based applications, backed up by FabricJS
Stars: ✭ 414 (+404.88%)
Mutual labels:  paint, draw
Jspaint
🎨 Classic MS Paint, REVIVED + ✨Extras
Stars: ✭ 5,972 (+7182.93%)
Mutual labels:  paint, canvas
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-56.1%)
Mutual labels:  draw, canvas
Doodle
Image doodle for Android, with functions such as undo, zoom, move, text, image, etc. Also a powerful, customizable and extensible doodle framework & multi-function drawing board. Android图片涂鸦,具有撤消,缩放,移动,添加文字,贴图等功能。还是一个功能强大,可自定义和可扩展的涂鸦框架、多功能画板。
Stars: ✭ 809 (+886.59%)
Mutual labels:  paint, draw
Minipaint
online image editor
Stars: ✭ 1,014 (+1136.59%)
Mutual labels:  paint, canvas
gridder
A Grid based 2D Graphics library
Stars: ✭ 51 (-37.8%)
Mutual labels:  paint, draw
jmonet
An easy-to-use toolkit for incorporating MacPaint / Microsoft Paint-like tools into a Java Swing or JavaFX application.
Stars: ✭ 27 (-67.07%)
Mutual labels:  paint, canvas
Simple Draw
A canvas you can draw on with different colors.
Stars: ✭ 256 (+212.2%)
Mutual labels:  draw, canvas
canvas-constructor
An ES6 utility for canvas with built-in functions and chained methods.
Stars: ✭ 96 (+17.07%)
Mutual labels:  canvas, draw
Drawing
Drawing and fill color
Stars: ✭ 37 (-54.88%)
Mutual labels:  paint, draw
leaflet-paintpolygon
Leaflet plugin to create polygon with circle as paint
Stars: ✭ 38 (-53.66%)
Mutual labels:  paint, draw
canvas-paint
🎨 helper functions for drawing onto <canvas> elements
Stars: ✭ 18 (-78.05%)
Mutual labels:  paint, draw
Makeup
让你的“女神”逆袭,代码撸彩妆(画妆)
Stars: ✭ 655 (+698.78%)
Mutual labels:  draw, canvas

Flutter library to bring your CustomPainter 🎨 to Life ✨⚡️

touchable library gives you the ability to add various gestures and animations to each Shape you draw on your canvas in the CustomPainter


           

Index :

Why Use Touchable ?

  • The CustomPainter lets you only draw shapes on the canvas. But most would want to let user interact with the drawings.

  • Add all kinds of gesture callbacks to each drawing to give interaction capability to the shapes you draw on the canvas.

  • Animating individual shapes has never been this easy.

  • Auto Handles the painting style (filled ▮ , stroke ▯) and detects touch accordingly.

  • Handles Painting stroke width. So if your shapes are painted thick , we still got it covered ✓

  • Supports clipping and different clipping modes for the drawings.

  • Supports HitTestBehavior for each shape.

  • Simple and Easy API. Just wrap your CustomPaint with CanvasTouchDetector and use the TouchyCanvas in your painter.

With touchable , you get what the normal canvas always missed : touchability 😉

Installation

Add the touchable package as dependency in your pubspec.yaml

dependencies:
  touchable:

Usage

  • Just Wrap your CustomPaint widget with CanvasTouchDetector. It takes a builder function as argument that expects your CustomPaint widget as shown below.
CanvasTouchDetector(
    builder: (context) => 
        CustomPaint(
            painter: MyPainter(context)
        )
)
  • Inside your CustomPainter class's paint method , create and use the TouchyCanvas object (using the context obtained from the CanvasTouchDetector and canvas) to draw any shape with different gesture callbacks.
var myCanvas = TouchyCanvas(context,canvas);
myCanvas.drawRect( rect , Paint() , onTapDown: (tapDetail){
    //Do stuff here. Probably change your state and animate
});

MyPainter example :

class MyPainter extends CustomPainter {

  final BuildContext context ;
  MyPainter(this.context); // context from CanvasTouchDetector

  @override
  void paint(Canvas canvas, Size size) {
    var myCanvas = TouchyCanvas(context,canvas); 

    myCanvas.drawCircle(Offset(10, 10), 60, Paint()..color=Colors.orange ,
        onTapDown: (tapdetail) {
         print("orange Circle touched");
       },
        onPanDown:(tapdetail){
          print("orange circle swiped");
        } 
    );

    myCanvas.drawLine(
        Offset(0, 0),
        Offset(size.width - 100, size.height - 100),
        Paint()
          ..color = Colors.black
          ..strokeWidth = 50, 
        onPanUpdate: (detail) {
            print('Black line Swiped'); //do cooler things here. Probably change app state or animate
    });
  }
}

Read the article on Medium : Bring Your CustomPainter to Life using Touchable



How Touchable Works

When you draw shapes on the canvas (TouchyCanvas) , it keeps track of the dimensions of each shape you draw and their painting style , stroke , order , clippings etc.

When user performs any gesture on the screen , based on the location of the gesture , the appropriate shape is selected from the lot taking clipping regions , paint , hitTest behaviour etc into account in an optimized way. Callbacks of the corresponding shapes (one or more depending on the hitTest behavior) are executed.

Road Map

  • [x] Basic Shape Detection
    • [x] Line
    • [x] Rectangle (Rect)
    • [x] Circle
    • [x] Oval or Ellipse
    • [x] Arc
      • [x] segment
      • [x] sector
    • [x] Rounded Rectangle (RRect)
    • [x] Custom Path [only supports opaque hittest]
    • [x] Points (PointMode.points , PointMode.lines , PointMode.polygon)
    • [ ] Vertices
      • [ ] Traingle
      • [ ] Traingle Strip
      • [ ] Traingle Fan
  • [x] Support for proper edge detection based on the Paint object properties :
    • [x] Paint style
    • [x] Stroke Width
    • [ ] Stroke Cap
      • [x] StrokeCap to draw Points
      • [ ] StrokeCap.round for lines with huge width.
  • [x] Support Clipping and clipping modes
    • [x] ClipRect
      • [x] intersect mode [Touch detection enabled only inside the clipped region]
      • [x] difference mode [Touch detection enabled only outside the clipped region]
    • [x] ClipRRect
    • [x] ClipPath
  • [x] Support for HitTestBehavior
  • [ ] Make the touch detection handling to run in a seperate isolate.
  • [ ] Support for translation , rotation , scaling and skewing transformations that needs some vector math

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].