Skip to content

Commit

Permalink
Add copyExpandCanvas to Transform Commands, an doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wcfv committed Jun 29, 2023
1 parent bc45266 commit f6927d7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ void copyCropCircle({ int? radius, int? centerX, int? centerY });
void copyCrop({ required int x, required int y, required int width,
required int height, num radius = 0 });
void copyExpandCanvas({ required int newWidth, required int newHeight,
ExpandCanvasPosition position = ExpandCanvasPosition.center,
Color? backgroundColor,
Image? toImage });
void copyFlip({ required FlipDirection direction });
void copyRectify({ required Point topLeft,
Expand Down
35 changes: 35 additions & 0 deletions lib/src/command/transform/copy_expand_canvas.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import '../../../image.dart';
import '../../transform/copy_expand_canvas.dart';

class CopyExpandCanvasCmd extends Command {
int newWidth;
int newHeight;
ExpandCanvasPosition position;
Color? backgroundColor;
Image? toImage;

CopyExpandCanvasCmd(
Command? input, {
required this.newWidth,
required this.newHeight,
this.position = ExpandCanvasPosition.center,
this.backgroundColor,
this.toImage,
}) : super(input);

@override
Future<void> executeCommand() async {
await input?.execute();
final img = input?.outputImage;
outputImage = img != null
? copyExpandCanvas(
img,
newWidth: newWidth,
newHeight: newHeight,
position: position,
backgroundColor: backgroundColor,
toImage: toImage,
)
: null;
}
}

0 comments on commit f6927d7

Please sign in to comment.