diff options
Diffstat (limited to 'platform/ios/Classes/MuInkView.m')
-rw-r--r-- | platform/ios/Classes/MuInkView.m | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/platform/ios/Classes/MuInkView.m b/platform/ios/Classes/MuInkView.m deleted file mode 100644 index 75799941..00000000 --- a/platform/ios/Classes/MuInkView.m +++ /dev/null @@ -1,82 +0,0 @@ -#include "common.h" -#import "MuInkView.h" - -@implementation MuInkView -{ - CGSize pageSize; - NSMutableArray *curves; - UIColor *color; -} - -- (instancetype) initWithPageSize:(CGSize)_pageSize -{ - self = [super initWithFrame:CGRectMake(0, 0, 100, 100)]; - if (self) { - [self setOpaque:NO]; - pageSize = _pageSize; - color = [[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0] retain]; - curves = [[NSMutableArray array] retain]; - UIPanGestureRecognizer *rec = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onDrag:)]; - [self addGestureRecognizer:rec]; - [rec release]; - } - return self; -} - -@synthesize curves; - --(void)dealloc -{ - [curves release]; - [color release]; - [super dealloc]; -} - --(void) onDrag:(UIPanGestureRecognizer *)rec -{ - CGSize scale = fitPageToScreen(pageSize, self.bounds.size); - CGPoint p = [rec locationInView:self]; - p.x /= scale.width; - p.y /= scale.height; - - if (rec.state == UIGestureRecognizerStateBegan) - [curves addObject:[NSMutableArray array]]; - - NSMutableArray *curve = curves.lastObject; - [curve addObject:[NSValue valueWithCGPoint:p]]; - - [self setNeedsDisplay]; -} - -- (void)drawRect:(CGRect)rect -{ - CGSize scale = fitPageToScreen(pageSize, self.bounds.size); - CGContextRef cref = UIGraphicsGetCurrentContext(); - CGContextScaleCTM(cref, scale.width, scale.height); - - [color set]; - CGContextSetLineWidth(cref, 5.0); - - for (NSArray *curve in curves) - { - if (curve.count >= 2) - { - CGPoint pt = [curve[0] CGPointValue]; - CGContextBeginPath(cref); - CGContextMoveToPoint(cref, pt.x, pt.y); - CGPoint lpt = pt; - - for (int i = 1; i < curve.count; i++) - { - pt = [curve[i] CGPointValue]; - CGContextAddQuadCurveToPoint(cref, lpt.x, lpt.y, (pt.x + lpt.x)/2, (pt.y + lpt.y)/2); - lpt = pt; - } - - CGContextAddLineToPoint(cref, pt.x, pt.y); - CGContextStrokePath(cref); - } - } -} - -@end |