Last active
August 29, 2015 14:11
-
-
Save hirokim/afb97b61188b51986741 to your computer and use it in GitHub Desktop.
線を描画するときにブラシ効果
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (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