forked from LinwoodDev/Butterfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
property.dart
59 lines (50 loc) 路 1.71 KB
/
property.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import 'colors.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'property.g.dart';
part 'property.freezed.dart';
abstract class PathProperty implements Property {
@override
double get strokeWidth;
double get thinning;
double get smoothing;
double get streamline;
}
enum HorizontalAlignment { left, center, right, justify }
enum VerticalAlignment { top, center, bottom }
@freezed
sealed class Property with _$Property {
@Implements<PathProperty>()
const factory Property.pen({
@Default(5) double strokeWidth,
@Default(0.4) double thinning,
@Default(BasicColors.black) int color,
@Default(false) bool fill,
@Default(0.5) double smoothing,
@Default(0.3) double streamline,
}) = PenProperty;
const factory Property.shape({
@Default(5) double strokeWidth,
required PathShape shape,
@Default(BasicColors.black) int color,
}) = ShapeProperty;
factory Property.fromJson(Map<String, dynamic> json) =>
_$PropertyFromJson(json);
}
@freezed
sealed class PathShape with _$PathShape {
const PathShape._();
const factory PathShape.circle(
{@Default(BasicColors.transparent) int fillColor}) = CircleShape;
const factory PathShape.rectangle(
{@Default(BasicColors.transparent) int fillColor,
@Default(0) double topLeftCornerRadius,
@Default(0) double topRightCornerRadius,
@Default(0) double bottomLeftCornerRadius,
@Default(0) double bottomRightCornerRadius}) = RectangleShape;
const factory PathShape.line() = LineShape;
const factory PathShape.triangle({
@Default(BasicColors.transparent) int fillColor,
}) = TriangleShape;
factory PathShape.fromJson(Map<String, dynamic> json) =>
_$PathShapeFromJson(json);
}