109 lines
2.7 KiB
Dart
109 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Predefined paint configurations for common annotation styles.
|
|
///
|
|
/// Each preset defines a color and stroke width for drawing.
|
|
/// Stroke width is normalized (relative to canvas width).
|
|
class PaintPreset {
|
|
/// Display name for the preset
|
|
final String name;
|
|
|
|
/// Color of the paint (including opacity)
|
|
final Color color;
|
|
|
|
/// Stroke width in normalized units (relative to canvas width)
|
|
/// A value of 0.005 means the stroke is 0.5% of the canvas width
|
|
final double strokeWidth;
|
|
|
|
/// Icon to display for this preset
|
|
final IconData icon;
|
|
|
|
const PaintPreset({
|
|
required this.name,
|
|
required this.color,
|
|
required this.strokeWidth,
|
|
required this.icon,
|
|
});
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Default Presets
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// Black pen for writing/notes
|
|
static const blackPen = PaintPreset(
|
|
name: 'Black Pen',
|
|
color: Colors.black,
|
|
strokeWidth: 0.003, // Thin line for writing
|
|
icon: Icons.edit,
|
|
);
|
|
|
|
/// Red pen for corrections/markings
|
|
static const redPen = PaintPreset(
|
|
name: 'Red Pen',
|
|
color: Colors.red,
|
|
strokeWidth: 0.003,
|
|
icon: Icons.edit,
|
|
);
|
|
|
|
/// Blue pen for annotations
|
|
static const bluePen = PaintPreset(
|
|
name: 'Blue Pen',
|
|
color: Colors.blue,
|
|
strokeWidth: 0.003,
|
|
icon: Icons.edit,
|
|
);
|
|
|
|
/// Yellow highlighter (semi-transparent, thicker)
|
|
static const yellowMarker = PaintPreset(
|
|
name: 'Yellow Marker',
|
|
color: Color(0x80FFEB3B), // Yellow with 50% opacity
|
|
strokeWidth: 0.015, // Thicker for highlighting
|
|
icon: Icons.highlight,
|
|
);
|
|
|
|
/// Green highlighter
|
|
static const greenMarker = PaintPreset(
|
|
name: 'Green Marker',
|
|
color: Color(0x804CAF50), // Green with 50% opacity
|
|
strokeWidth: 0.015,
|
|
icon: Icons.highlight,
|
|
);
|
|
|
|
/// Pink highlighter
|
|
static const pinkMarker = PaintPreset(
|
|
name: 'Pink Marker',
|
|
color: Color(0x80E91E63), // Pink with 50% opacity
|
|
strokeWidth: 0.015,
|
|
icon: Icons.highlight,
|
|
);
|
|
|
|
/// All available default presets
|
|
static const List<PaintPreset> defaults = [
|
|
blackPen,
|
|
redPen,
|
|
bluePen,
|
|
yellowMarker,
|
|
greenMarker,
|
|
pinkMarker,
|
|
];
|
|
|
|
/// Quick access presets (shown in main toolbar)
|
|
static const List<PaintPreset> quickAccess = [
|
|
blackPen,
|
|
redPen,
|
|
yellowMarker,
|
|
];
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
return other is PaintPreset &&
|
|
other.name == name &&
|
|
other.color == color &&
|
|
other.strokeWidth == strokeWidth;
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(name, color, strokeWidth);
|
|
}
|