Draw_Your_Image는 사용자가 손가락이나 스타일러스로 사용자 정의된 UI 위에 직접 그릴 수 있도록 해주는 플러터 패키지입니다. 앱 내에서 스케치, 페인팅 또는 서명을 위한 간단하고 인터랙티브한 캔버스를 제공합니다. 창의적인 도구, 메모 앱, 디지털 서명 캡처에 적합하며 모바일, 웹, 데스크톱 등 다양한 플랫폼을 지원합니다. 플러터 위젯 시스템과 원활하게 통합되며 사용자 지정 브러시 설정도 제공합니다. 오픈소스이며 전담 개발자가 유지 관리하고 있습니다.
사용 사례
디지털 스케치
서명 캡처
인터랙티브 화이트보드
교육용 그림 그리기 앱
창의적 디자인 도구
주요 기능
터치 기반의 그림 그리기
사용자 정의 가능한 브러시 크기 및 색상
크로스 플랫폼 지원
Flutter와의 간단한 통합
오픈소스 코드베이스
적합한 대상
창의적인 도구를 구축하는 앱 개발자
인터랙티브 학습 앱을 만드는 교육자
사용자 서명이 필요한 앱
그림 기능이 필요한 디자이너
상호작용 인터페이스 프로토타이핑
고려 사항
저사양 기기에서는 성능이 다를 수 있습니다
제한된 고급 편집 도구
내장된 내보내기 기능 없음
수동으로 저장/로드 로직을 처리해야 합니다
브러시 사용자 정의 옵션은 기본적입니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
draw_your_image
A Flutter package for creating customizable drawing canvases with a declarative API.
Core Concept
Fully declarative, fully customizable
No controllers required - Manage stroke data in your widget state
Customize everything - Control stroke behavior through simple callbacks
Bring your own features - Implement undo/redo, zoom/pan, image export as your app needs
This package focuses on providing a flexible drawing widget, leaving app-specific features to you.
Features
✨ Device-aware drawing - Distinguish between stylus, finger, and mouse input
🎨 Flexible stroke handling - Customize behavior per input device or any other criteria
🖌️ Built-in smoothing - Catmull-Rom spline interpolation included
⚙️ Fully customizable - Colors, widths, smoothing algorithms
🔍 Intersection detection - Customizable stroke overlap detection
Quick Start
classMyDrawingPageextendsStatefulWidget{
@override_MyDrawingPageStatecreateState() => _MyDrawingPageState();
}
class_MyDrawingPageStateextendsState<MyDrawingPage> {
/// Store all the strokes on app side as stateList<Stroke> _strokes = [];
@overrideWidgetbuild(BuildContext context) {
returnDraw(
strokes: _strokes, // pass strokes via
onStrokeDrawn: (stroke) {
// store new drawn stroke and rebuildsetState(() {
_strokes = [..._strokes, stroke];
});
},
);
}
}
That's it! The canvas accepts any input and draws with default settings.
Device-Aware Drawing with onStrokeStarted
The onStrokeStarted callback lets you control stroke behavior based on input devices or any other criteria.
classStrokePoint{
finalOffset position; // Position of the pointfinaldouble pressure; // Raw pressure (0.0 to 1.0+)finaldouble pressureMin; // Minimum pressure for this devicefinaldouble pressureMax; // Maximum pressure for this devicefinaldouble tilt; // Stylus tilt angle (0 to π/2 radians)finaldouble orientation; // Stylus orientation (-π to π radians)// Normalized pressure getter (0.0 to 1.0)doubleget normalizedPressure;
}
Note that all the parameters are originated in Flutter's PointerEvent. See documentation of PointerEvent for detailed information.
Key features:
tilt and orientation enable calligraphy-style effects
normalizedPressure automatically adjusts for device-specific pressure ranges
Works seamlessly with all input devices (stylus, touch, mouse)
Path Builder Modes
Path building algorithm is also customizable. You can choose pre-defined modes below or provide your own Path Function(Stroke).
PathBuilderMode.catmullRom.converter // Smooth curves (default)PathBuilderMode.none.converter // No smoothing (straight lines)PathBuilderMode.pressureSensitive.converter // Variable-width based on pressure
Pressure-Sensitive Drawing
Create variable-width strokes that respond to stylus pressure using PathBuilderMode.pressureSensitive:
The strokePainter callback allows you to fully customize how strokes are rendered. You can create advanced visual effects like gradients, glows, shadows, and shader effects by returning multiple Paint objects.
The package provides utility functions for creating Paint objects:
paintWithDefault - Creates a paint with default properties
paintWithOverride - Creates a paint with overridden properties
eraseWithDefault - Creates a paint with BlendMode.clear for pixel-level erasing
Using with InteractiveViewer
The shouldAbsorbScale callback allows you to control which pointer events are handled by the Draw widget versus parent widgets like InteractiveViewer. This enables powerful combinations like:
Touch for pan/zoom, stylus for drawing
Device-specific gesture handling
Conditional pointer event absorption
InteractiveViewer(
child: Draw(
strokes: _strokes,
shouldAbsorbScale: (event) {
// Absorb stylus events for drawing, let touch events pass through for pan/zoomreturn event.kind == PointerDeviceKind.stylus ||
event.kind == PointerDeviceKind.invertedStylus;
},
onStrokeDrawn: (stroke) => setState(() => _strokes.add(stroke)),
onStrokeStarted: (newStroke, currentStroke) {
if (currentStroke != null) return currentStroke;
// Only draw with stylus (touch is for pan/zoom)return newStroke.deviceKind == PointerDeviceKind.stylus ? newStroke : null;
},
),
)
See the example app for a complete implementation of touch-for-pan/stylus-for-draw functionality.
Working with AI Assistants
This package is designed to work well with AI coding assistants. If you want accurate response from AI agents, refer AI_GUIDE.md before asking.