搜索插件、代码仓与 APP 分类

finger_painter 封面
插件详情v1.1.0

finger_painter

一个绘画包,可使用不同画笔和混合模式进行手指绘画。结果可以读取为位图或点列表,例如用于地图。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
59
喜欢数
45
Pub 分数
130

安装插件

flutter pub add finger_painter

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,支持使用可自定义画笔和混合模式进行交互式手指绘画。它允许用户直接在屏幕上创建数字艺术作品,支持跨多个平台的触摸输入。绘制结果可以导出为位图图像,或作为点列表用于进一步用途,例如映射或数据处理。非常适合需要手势输入的创意应用、绘图工具或交互式地图。

适合场景

  • 数字素描
  • 交互式地图注释
  • 基于手势的艺术应用程序
  • 教育绘图工具
  • 自定义签名捕获

主要特点

  • 多种画笔类型
  • 混合模式支持
  • 位图导出
  • 点列表输出
  • 跨平台兼容性

适合对象

  • 艺术家和设计师
  • 教育类应用开发者
  • 地图交互功能
  • 基于触摸的用户界面
  • 创意原型设计

使用建议

  • 性能在低端设备上可能有所不同
  • 需要触摸输入以获得最佳使用体验
  • 仅限2D画布渲染
  • 无内置的撤销/重做功能
  • 可能需要额外的逻辑来处理复杂手势

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Painting package that let you finger paint with different brushes and different blend modes. The result can be read as a bitmap or list of Points to be used ie on a Map.

Features

Pub Version Pub Publisher

Image

Getting started

The usage is simple: put the Painter() widget into your widget tree then use PainterController() to control its parameters and to get current painting image and/or drawn points.

Try online

Features

  • 3 kinds of pens
  • min and max stroke width for paintbrush strokes
  • get the last drawing image and drawing points
  • set a background widget (like Google Map)
  • set background color
  • uses image blending modes while painting

Usage

initialize the painter controller ie in the initState():

@override
void initState() {
  super.initState();
  painterController = PainterController()
    ..setPenType(PenType.pencil)
    ..setStrokeColor(Colors.black)
    ..setMinStrokeWidth(3)
    ..setMaxStrokeWidth(10)
    ..setBlurSigma(0.0)
    ..setBlendMode(ui.BlendMode.srcOver);
}

insert Painter() widget somewhere in your widget tree:

Painter(
  controller: painterController,
  backgroundColor: Colors.green.withOpacity(0.4),
  size: const Size(300, 300),
  child: Image.asset(...),
  onDrawingEnded: (Uint8List bytes) async{
    ...
  },
  // the child could be ie a Google Map
  // PS: the [backgroundColor] and child are not rendered in the resulting image 
  child: Image.asset('assets/...'),
),

Full example

📜 Painter widget properties
Properties Required Default Description
key false Widget key.
controller false Get and set Painter parameters (see PainterController below).
backgroundColor false Colors.transparent Color of the active painting area.
size false Size of painting area. If not set it takes the child area. If also the child is not set, it will take the available size from the parent.
child false Child Widget to put as the background of the painting area
onDrawingEnded false Callbackd that returns the last drawing as Uint8List filled with uncompressed BMP 32 bpp format. Here it's possible to get the drawn point with controller.getPoints()
📜 PainterController
Method return type Description
getState() PenState? Get the penType, strokeColor, strokeMinWidth, strokeMaxWidth, blendMode.
getImageBytes() Uint8List? Get current drawing image as uncompressed 32bit BMP Uint8List.
getPoints() List<Offset>? Get the point list drawn.
clearContent({Color? clearColor}) Clear current drawings with [clearColor] color. Default is transparent.
setPenType(PenType type) Set pen type: pencil, paintbrush, paintbrush2.
setBlendMode(ui.BlendMode mode) Set the painting blending mode. ui.BlendMode.dstOut can be used as an eraser pen.
setStrokeColor(Color color) Set stroke color.
setMinStrokeWidth(double width) Set the minimum stroke width.
setMaxStrokeWidth(double width) Set the maximum stroke width.
setBlurSigma(double sigma) Set the blur. 0 means no blur.
setBackgroundImage(Uint8List image) Set the background image. The painting will not modify this image.
📜 PenState
Method Default Description
penType PenType.paintbrush enum with pencil, paintbrush, paintbrush2.
pencil: constant stroke width using strokeMinWidth
paintBrush: variable stroke width. Near strokeMinWidth when moving slowly, near strokeMaxWidth when moving fast.
paintBrush2: variable stroke width. Near strokeMaxWidth when moving slowly, near strokeMinWidth when moving fast.
strokeColor Colors.black pen color
strokeMinWidth 3 Pen width when moving slowing.
strokeMaxWidth 10 Pen width when moving fast.
blurSigma 0 Blur stroke.
blendMode ui.BlendMode.srcOver Painting blending mode. See ui.BlendMode
⚠️ Note on web

The html renderer running on Web is not supported and using it will not save the drawing. https://github.com/flutter/flutter/issues/42767

Hence when using this package on web, the canvaskit renderer must be used, ie: flutter run -d chrome --web-renderer canvaskit

所属分类

源码仓库

使用此插件的项目

暂无相关数据。