ios - how to make top edge of the waveform rounded -


i want create top edge , bottom edge of wave forms in rounded shape .

currently able these wave forms

enter image description here

the code below is

 - (uiimage*) drawimagefromsamples:(sint16*)samples                      maxvalue:(sint16)maxvalue                   samplecount:(nsinteger)samplecount {  cgsize imagesize = cgsizemake(samplecount * (_drawspaces ? 6 : 6), self.height); uigraphicsbeginimagecontextwithoptions(imagesize, no, 0); cgcontextref context = uigraphicsgetcurrentcontext();  cgcontextsetfillcolorwithcolor(context, self.backgroundcolor.cgcolor); cgcontextsetalpha(context, 1.0);  cgrect rect; rect.size = imagesize; rect.origin.x = 0; rect.origin.y = 0;  cgcolorref wavecolor = self.wavecolor.cgcolor;  cgcontextfillrect(context, rect);  cgcontextsetlinewidth(context, 2.0);  float channelcentery = imagesize.height / 2; float sampleadjustmentfactor = imagesize.height / (float)maxvalue;  (nsinteger = 0; < samplecount; i++) {     float val = *samples++;     val = val * sampleadjustmentfactor;     if ((int)val == 0)         val = 1.0; // draw dots instead emptyness     cgcontextmovetopoint(context, * (_drawspaces ? 6 : 6), channelcentery - val / 2.0);     cgcontextaddlinetopoint(context, * (_drawspaces ? 6 : 6), channelcentery + val / 2.0);     cgcontextsetstrokecolorwithcolor(context, wavecolor);     cgcontextstrokepath(context); }  uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext();  uigraphicsendimagecontext();  return newimage; } 

try this, cgcontextsetlinecap (context, kcglinecapround);

-(uiimage*) drawimagefromsamples:(sint16*)samples maxvalue:(sint16)maxvalue samplecount:(nsinteger)samplecount {      cgsize imagesize = cgsizemake(samplecount * (_drawspaces ? 6 : 6), self.height); uigraphicsbeginimagecontextwithoptions(imagesize, no, 0);         cgcontextref context = uigraphicsgetcurrentcontext();      cgcontextsetfillcolorwithcolor(context, self.backgroundcolor.cgcolor); cgcontextsetalpha(context, 1.0);      cgrect rect; rect.size = imagesize; rect.origin.x = 0; rect.origin.y = 0;      cgcolorref wavecolor = self.wavecolor.cgcolor;      cgcontextfillrect(context, rect);      cgcontextsetlinewidth(context, 2.0);  // start: line added code         cgcontextsetlinecap (context, kcglinecapround);         // end: line added code     float channelcentery = imagesize.height / 2; float sampleadjustmentfactor = imagesize.height / (float)maxvalue;      (nsinteger = 0; < samplecount; i++) { float val = *samples++; val = val * sampleadjustmentfactor; if ((int)val == 0) val = 1.0; // draw dots instead emptyness          cgcontextmovetopoint(context, * (_drawspaces ? 6 : 6), channelcentery - val / 2.0);         cgcontextaddlinetopoint(context, * (_drawspaces ? 6 : 6), channelcentery + val / 2.0);cgcontextsetstrokecolorwithcolor(context, wavecolor); cgcontextstrokepath(context); }          uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext();          uigraphicsendimagecontext();          return newimage;     } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -