ios - Touch drawing opacity -


i trying make drawing app has control on opacity of brush when tried lower opacity result - picture. used core graphics. how fix problem?

some code:

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { mouseswiped = no; uitouch *touch = [touches anyobject]; lastpoint = [touch locationinview:self.imageviewproperty];}  - (void) touchesmoved:(nsset *)touches withevent:(uievent *)event { mouseswiped = yes; uitouch *touch = [touches anyobject]; cgpoint currentpoint = [touch locationinview:self.imageviewproperty];  uigraphicsbeginimagecontext(self.imageviewproperty.frame.size); [self.imageviewproperty.image drawinrect:cgrectmake(0, 0, self.imageviewproperty.frame.size.width, self.imageviewproperty.frame.size.height)]; cgcontextmovetopoint(uigraphicsgetcurrentcontext(), lastpoint.x, lastpoint.y); cgcontextaddlinetopoint(uigraphicsgetcurrentcontext(), currentpoint.x, currentpoint.y); cgcontextsetlinecap(uigraphicsgetcurrentcontext(), kcglinecapround); cgcontextsetlinewidth(uigraphicsgetcurrentcontext(), 10); cgcontextsetrgbstrokecolor(uigraphicsgetcurrentcontext(), redcolorvalue, greencolorvalue, bluecolorvalue, alphavalue); cgcontextsetblendmode(uigraphicsgetcurrentcontext(), kcgblendmodenormal); cgcontextstrokepath(uigraphicsgetcurrentcontext()); self.imageviewproperty.image = uigraphicsgetimagefromcurrentimagecontext(); [self.imageviewproperty setalpha:1.0f]; uigraphicsendimagecontext(); lastpoint = currentpoint;}  - (void)touchesended:(nsset *)touches withevent:(uievent *)event {  if(!mouseswiped) {     uigraphicsbeginimagecontext(self.view.frame.size);     [self.imageviewproperty.image drawinrect:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];     cgcontextsetlinecap(uigraphicsgetcurrentcontext(), kcglinecapround);     cgcontextsetlinewidth(uigraphicsgetcurrentcontext(), 10);     cgcontextsetrgbstrokecolor(uigraphicsgetcurrentcontext(), redcolorvalue, greencolorvalue, bluecolorvalue, alphavalue);     cgcontextmovetopoint(uigraphicsgetcurrentcontext(), lastpoint.x, lastpoint.y);     cgcontextaddlinetopoint(uigraphicsgetcurrentcontext(), lastpoint.x, lastpoint.y);     cgcontextstrokepath(uigraphicsgetcurrentcontext());     cgcontextflush(uigraphicsgetcurrentcontext());     self.imageviewproperty.image = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext(); }  uigraphicsbeginimagecontext(self.mainimageproperty.frame.size); [self.mainimageproperty.image drawinrect:cgrectmake(0, 0, self.mainimageproperty.frame.size.width, self.mainimageproperty.frame.size.height)                                blendmode:kcgblendmodenormal                                    alpha:1.0]; self.mainimageproperty.image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();} 


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -