Skip to content

Commit

Permalink
- Added load drawing function
Browse files Browse the repository at this point in the history
- Added function which returns the pathArray used for saving the drawing
  • Loading branch information
TripwireNL committed Oct 10, 2016
1 parent 96b3263 commit 381c3b4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ACEDrawingView/ACEDrawingView.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ typedef NS_ENUM(NSUInteger, ACEDrawingMode) {
- (BOOL)canRedo;
- (void)redoLatestStep;

// Save & load drawing
- (void)loadDrawing:(NSMutableArray *)pathArray;
- (NSMutableArray *) getPathArray;

/**
@discussion Discards the tool stack and renders them to prev_image, making the current state the 'start' state.
(Can be called before resize to make content more predictable)
Expand Down
37 changes: 37 additions & 0 deletions ACEDrawingView/ACEDrawingView.m
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,43 @@ - (void)hideTextToolHandles
}
}

- (NSMutableArray *) getPathArray {
return _pathArray;
}

- (void)loadDrawing:(NSMutableArray *)pathArray {

_pathArray = pathArray;

// init a context
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);


// erase the previous image
self.image = nil;

// load previous image (if returning to screen)

switch (self.drawMode) {
case ACEDrawingModeOriginalSize:
[[self.backgroundImage copy] drawAtPoint:CGPointZero];
break;
case ACEDrawingModeScale:
[[self.backgroundImage copy] drawInRect:self.bounds];
break;
}

// I need to redraw all the lines
for (id<ACEDrawingTool> tool in self.pathArray) {
[tool draw];
}

// store the image
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}


#pragma mark - Undo / Redo

- (BOOL)canUndo
Expand Down

0 comments on commit 381c3b4

Please sign in to comment.