Skip to content

Commit

Permalink
- Saving and loading basic functionality now works! Focussing on the …
Browse files Browse the repository at this point in the history
…slicing now :)
  • Loading branch information
TripwireNL committed Feb 28, 2017
1 parent 381c3b4 commit 105c363
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 15 deletions.
3 changes: 1 addition & 2 deletions ACEDrawingView/ACEDrawingToolState.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ + (instancetype)stateForTool:(id<ACEDrawingTool>)tool
return [ACEDrawingToolState stateForTool:tool capturePosition:NO];
}

+ (instancetype)stateForTool:(id<ACEDrawingTool>)tool capturePosition:(BOOL)capture
{
+ (instancetype)stateForTool:(id<ACEDrawingTool>)tool capturePosition:(BOOL)capture {
ACEDrawingToolState *state = [ACEDrawingToolState new];
state.tool = tool;

Expand Down
3 changes: 2 additions & 1 deletion ACEDrawingView/ACEDrawingTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#endif


@protocol ACEDrawingTool <NSObject>
@protocol ACEDrawingTool <NSObject, NSCoding>

@property (nonatomic, strong) UIColor *lineColor;
@property (nonatomic, assign) CGFloat lineAlpha;
Expand Down Expand Up @@ -71,6 +71,7 @@
}

- (CGRect)addPathPreviousPreviousPoint:(CGPoint)p2Point withPreviousPoint:(CGPoint)p1Point withCurrentPoint:(CGPoint)cpoint;
- (NSData *)savePenToolData;

@end

Expand Down
3 changes: 1 addition & 2 deletions ACEDrawingView/ACEDrawingTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ @implementation ACEDrawingPenTool
- (id)init
{
self = [super init];
if (self != nil) {
if (self) {
self.lineCapStyle = kCGLineCapRound;
path = CGPathCreateMutable();
}
Expand Down Expand Up @@ -570,7 +570,6 @@ - (void)draw
if (self.fill) {
CGContextSetFillColorWithColor(context, self.lineColor.CGColor);
CGContextFillEllipseInRect(UIGraphicsGetCurrentContext(), rectToFill);

} else {
CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);
CGContextSetLineWidth(context, self.lineWidth);
Expand Down
3 changes: 2 additions & 1 deletion ACEDrawingView/ACEDrawingView.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ - (void)setCustomDrawTool:(id<ACEDrawingTool>)customDrawTool
switch (self.drawTool) {
case ACEDrawingToolTypePen:
{
return ACE_AUTORELEASE([ACEDrawingPenTool new]);
ACEDrawingPenTool *tool = ACE_AUTORELEASE([ACEDrawingPenTool new]);
return tool;
}

case ACEDrawingToolTypeLine:
Expand Down
30 changes: 27 additions & 3 deletions ACEDrawingViewDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = ACE;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = "Stefano Acerbetti";
TargetAttributes = {
50F58C4B1D7F0F4B0050A4A0 = {
Expand Down Expand Up @@ -482,22 +482,34 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -511,14 +523,26 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 105c363

@jackywongcw
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Tripwire999 ,
I've spent half the day looking at your commits, figuring how to save the drawings.
As per this post, you managed to do save and load the draw paths, but I couldn't do it.

There's a method you added to AceDrawingTools.h, +- (NSData *)savePenToolData;, is this the method that saves the pathArray?

I'm using swift in my project, and have a linker to this framework.
Here's how my view works:
A viewcontroller (viewA), with a uiview(drawingView) casted to AceDrawingView.
viewA has the delegates set up and everything. I'm able to draw, highlight etc.

What I want now is to have a uibutton to save the "drawings", so when the user come back to viewA, it'll auto load the saved "drawings".

Can you lend me a hand on this?

Thank you for your time.

Please sign in to comment.