Line data Source code
1 : import 'package:mrx_icon_font_gen/parser/path/model/arguments/coordinate_pair.dart'; 2 : import 'package:mrx_icon_font_gen/parser/path/model/command_arguments.dart'; 3 : import 'package:vector_math/vector_math_64.dart'; 4 : 5 : abstract class Command { 6 : late final String command; 7 : final CommandArguments? commandArguments; 8 : 9 12 : Command({ 10 : String? command, 11 : bool? isRelative, 12 : this.commandArguments, 13 : }) { 14 : if (command == null && isRelative == null) { 15 11 : throw ArgumentError( 16 : 'One of "command" and "isRelative" arguments must be not null', 17 : ); 18 : } 19 : if (command != null && 20 24 : command != absoluteCommandName && 21 24 : command != relativeCommandName) { 22 10 : throw ArgumentError( 23 30 : 'Unsupported command "$command". Acceptable commands are $absoluteCommandName and $relativeCommandName', 24 : ); 25 : } 26 12 : this.command = command ?? 27 24 : ((isRelative ?? false) ? relativeCommandName : absoluteCommandName); 28 : } 29 : 30 : String get relativeCommandName; 31 : 32 : String get absoluteCommandName; 33 : 34 : List<Command> applyTransformation( 35 : Matrix3 transform, 36 : CoordinatePair startPoint, 37 : ); 38 : 39 : CoordinatePair getLastPoint(CoordinatePair startPoint); 40 : 41 8 : bool get isRelative => command == relativeCommandName; 42 : 43 40 : bool get isAbsolute => command == absoluteCommandName; 44 : 45 10 : @override 46 : String toString() { 47 30 : return '$command${commandArguments ?? ''}'; 48 : } 49 : }