<p align="center">
<img width="200" src="https://raw.githubusercontent.com/nateshmbhat/touchable/master/.github/logo.svg"/>
</p>
<h2 align="center"> Flutter library to bring your CustomPainter ð¨ to Life â¨â¡ï¸ </h2>
[![](https://img.shields.io/pub/v/touchable)](https://pub.dev/packages/touchable)
[![](https://img.shields.io/badge/package-flutter-blue)](https://github.com/nateshmbhat/touchable)
[![](https://img.shields.io/github/license/nateshmbhat/touchable)](https://github.com/nateshmbhat/touchable)
[![](https://img.shields.io/github/stars/nateshmbhat/touchable)](https://github.com/nateshmbhat/touchable)
[![](https://img.shields.io/github/forks/nateshmbhat/touchable)](https://github.com/nateshmbhat/touchable)
[![](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fnateshmbhat%2Ftouchable)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fnateshmbhat%2Ftouchable)
[![](https://img.shields.io/github/languages/code-size/nateshmbhat/touchable)](https://github.com/nateshmbhat/touchable)
[![](https://img.shields.io/badge/author-nateshmbhat-green.svg)](https://github.com/nateshmbhat)
#### `touchable` library gives you the ability to add various **gestures** and animations to each **Shape** you draw on your canvas in the CustomPainter
<br />
<p align="center">
<img src="https://i.imgur.com/0Ft9FHJ.gif"/>
<img src="https://i.imgur.com/Un41cTo.gif"/>
</p>
## Index :
- [Why Use Touchable ?](#why-use-touchable)
- [Installation](#installation)
- [Usage](#usage)
- [How it works](#how-touchable-works)
- [Road Map ðº](#road-map)
- [Links](#links)
## 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`
```dart
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.
```dart
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.
```dart
var myCanvas = TouchyCanvas(context,canvas);
myCanvas.drawRect( rect , Paint() , onTapDown: (tapDetail){
//Do stuff here. Probably change your state and animate
});
```
### MyPainter example :
```dart
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](https://medium.com/flutter-community/bring-your-custompainter-paintings-to-life-in-flutter-using-touchable-c2413cd1897)
---
<br />
## 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
+ [Touchable Docs](https://pub.dev/documentation/touchable/latest/)
+ [Pub Dev](https://pub.dev/packages/touchable)
+ [Other Dart/Flutter Packages](https://pub.dev/packages?q=email%3Anateshmbhat1%40gmail.com)
+ [HomePage](https://github.com/nateshmbhat/touchable)
+ [My Github Page](https://github.com/nateshmbhat)
没有合适的资源?快使用搜索试试~ 我知道了~
Flutter库为您在CustomPainter画布上绘制的每个形状添加手势和动画_Dart_HTML_下载.zip
共115个文件
dart:35个
png:26个
xml:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 79 浏览量
2023-05-01
11:40:46
上传
评论
收藏 1.66MB ZIP 举报
温馨提示
Flutter库为您在CustomPainter画布上绘制的每个形状添加手势和动画_Dart_HTML_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
Flutter库为您在CustomPainter画布上绘制的每个形状添加手势和动画_Dart_HTML_下载.zip (115个子文件)
touchy_canvas.dart 21KB
arc.dart 10KB
canvas_touch_detector.dart 9KB
screen2.dart 6KB
defer_to_child.dart 5KB
translucent.dart 5KB
screen1.dart 5KB
opaque.dart 5KB
point.dart 5KB
util.dart 4KB
point.dart 4KB
shape_handler.dart 3KB
arc.dart 3KB
line.dart 3KB
rectangle.dart 3KB
line.dart 3KB
screen3.dart 3KB
rounded_rectangle.dart 2KB
rounded_rectangle.dart 2KB
oval.dart 2KB
oval.dart 1KB
main.dart 1KB
shape.dart 1KB
circle.dart 1KB
touchable.dart 1KB
rectangle.dart 1KB
circle.dart 978B
clip.dart 916B
types.dart 879B
path.dart 571B
widget_test.dart 500B
shape.dart 300B
matter_test.dart 215B
shape_handler.dart 206B
constant.dart 105B
demo-shapes.gif 1.42MB
demo-smiley.gif 160KB
.gitignore 2KB
.gitignore 732B
.gitignore 542B
.gitignore 262B
build.gradle 2KB
build.gradle 582B
settings.gradle 462B
Runner-Bridging-Header.h 38B
index.html 1KB
Contents.json 2KB
manifest.json 574B
Contents.json 391B
MainActivity.kt 136B
LICENSE 16KB
pubspec.lock 3KB
pubspec.lock 3KB
README.md 6KB
CHANGELOG.md 842B
README.md 541B
README.md 336B
.metadata 310B
.metadata 305B
project.pbxproj 18KB
Info.plist 1KB
AppFrameworkInfo.plist 773B
IDEWorkspaceChecks.plist 238B
IDEWorkspaceChecks.plist 238B
[email protected] 11KB
Icon-512.png 8KB
Icon-192.png 5KB
ic_launcher.png 1KB
ic_launcher.png 1KB
favicon.png 917B
ic_launcher.png 721B
[email protected] 564B
ic_launcher.png 544B
ic_launcher.png 442B
LaunchImage.png 68B
gradle-wrapper.properties 231B
gradle.properties 82B
LaunchScreen.storyboard 2KB
Main.storyboard 2KB
logo.svg 57KB
logo-14.svg 4KB
AppDelegate.swift 404B
Debug.xcconfig 30B
Release.xcconfig 30B
Runner.xcscheme 3KB
共 115 条
- 1
- 2
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python代码案例详解-旅行商问题的多种求解算法.zip
- springcloud.rar
- 一键清理maven项目依赖下载失败生成的.lastUpdated文件, 以及解决无法连接远程仓库导致本地依赖找不到的批处理脚本
- C#+WPF开发IOC框架实战架构师课程
- 《JAVA WEB项目开发案例精粹》中的代码案例源文件(超全).rar
- 背景music,用作业网轮地址
- comment_6e56cd5d6e140046ef1cd248910ea5ca.png
- 基于卷积神经网络的自动驾驶系统的设计与实现
- MySQL的执行原理-2.md
- 基于 FCN 网络对无人机俯拍下的生活场景语义分割(12类别)【包含数据集、完整代码、训练好的结果、权重文件等等】
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功