我正在做一个需要像Sketchpad一样快速绘制的应用程序,但它需要在某些边界内。这些边界不是几何形状,但我将它们放在二维矩阵上。例如:
00000000000000000000
00000000111001111000
00000001111111001000
00000111110001001000
00001111110000000000
00001111110000001100
00000111111000111000
00000011111111110000
00000000111111100000
00000000001111100000
00000000000000000000
不完全是那个,而是作为一个例子。
使用CoreGraphics进行绘制时,它并不尊重边界并从图中抽出。
这是我正在使用的代码
BOOL containsPoint = [self.currentFilledImageGraphics isTransparentAt:(int)imagePoint.x y:(int)imagePoint.y];
if (containsPoint) {
_mouseSwiped = YES;
UIGraphicsBeginImageContext(self.frame.size);
[self.tempPaintImageView.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), _lastPoint.x, _lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), UIPoint.x, UIPoint.y);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), _brush );
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), _red, _green, _blue, _opacity);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),self.blendMode);
CGContextStrokePath(UIGraphicsGetCurrentContext());
self.tempPaintImageView.image = UIGraphicsGetImageFromCurrentImageContext();
[self.tempPaintImageView setAlpha:_opacity];
UIGraphicsEndImageContext();
}
_lastPoint = UIPoint;
请帮帮我!!!!!