Skip to content

Instantly share code, notes, and snippets.

@hirokim
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save hirokim/afb97b61188b51986741 to your computer and use it in GitHub Desktop.

Select an option

Save hirokim/afb97b61188b51986741 to your computer and use it in GitHub Desktop.
線を描画するときにブラシ効果
- (void)drawLine:(UIBezierPath*)path
{
// 非表示の描画領域を生成
UIGraphicsBeginImageContextWithOptions(self.canvas.frame.size, NO, 0.0);
// 描画領域に、前回までに描画した画像を、描画
[lastDrawImage drawAtPoint:CGPointZero];
// ブラシを指定して色をセット
UIColor *brushPattern = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"mask"]];
[brushPattern setStroke];
// 線を引く
[path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
// 描画した画像をcanvasにセットして、画面に表示
self.canvas.image = UIGraphicsGetImageFromCurrentImageContext();
// 描画を終了
UIGraphicsEndImageContext();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment