搜尋套件、儲存庫與 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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。