ios - How to mix two colors at the point of intersection of paths in Coregraphics? -
i need mix 2 colors on drawing smooth curves in image view, in - mixing of red , blue should give purple (red+yellow = orange,yellow+blue=green) @ point of intersection of 2 colors. tried using blending modes of coregraphics did not work. can me out?
-(void)touchesmoved:(nsset<uitouch *> *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; self.prepreviouspoint = self.previouspoint; self.previouspoint = [touch previouslocationinview:self]; cgpoint currentpoint = [touch locationinview:self]; cgpoint mid1 = [self calculatemidpointforpoint:self.previouspoint andpoint:self.prepreviouspoint]; cgpoint mid2 = [self calculatemidpointforpoint:currentpoint andpoint:self.previouspoint]; uigraphicsbeginimagecontext(self.drawimageview.frame.size); cgcontextref context = uigraphicsgetcurrentcontext(); [currentcolor setstroke]; cgcontextsetblendmode(context, kcgblendmodemultiply); cgcontextsetallowsantialiasing(uigraphicsgetcurrentcontext(), true); cgcontextsetshouldantialias(uigraphicsgetcurrentcontext(), true); [self.drawimageview.image drawinrect:cgrectmake(0, 0, self.drawimageview.frame.size.width, self.drawimageview.frame.size.height)]; cgcontextmovetopoint(context, mid1.x, mid1.y); // // use quadcurve key cgcontextaddquadcurvetopoint(context, self.previouspoint.x, self.previouspoint.y, mid2.x, mid2.y); cgcontextsetlinecap(context, kcglinecapround); cgcontextsetlinewidth(context, self.linewidth); cgcontextstrokepath(context); self.drawimageview.image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); }
Comments
Post a Comment