ios - Drawing a polygon with one color for stroke, and a different one for fill? -


i'm having trouble drawing lines stroked color , filling insides (they make polygon) one.

uicolor *housebordercolor = [uicolor colorwithred:(170/255.0) green:(138/255.0) blue:(99/255.0) alpha:1]; cgcontextsetstrokecolorwithcolor(context, housebordercolor.cgcolor); cgcontextsetlinewidth(context, 3);  // draw polygon cgcontextmovetopoint(context, 20, viewheight-19.5); cgcontextaddlinetopoint(context, 200, viewheight-19.5); // base cgcontextaddlinetopoint(context, 300, viewheight-119.5); // right border cgcontextaddlinetopoint(context, 120, viewheight-119.5); cgcontextaddlinetopoint(context, 20, viewheight-19.5);  // fill cgcontextsetrgbfillcolor(context, (248/255.0), (222/255.0), (173/255.0), 1); //cgcontextfillpath(context);  // stroke cgcontextstrokepath(context); 

with cgcontextstrokepath commented out, result:

enter image description here

but if uncomment cgcontextstrokepath , fill out polygon, color overflows strokes:

enter image description here

how achieve result (without having redo whole drawing procedure twice):

enter image description here

you can use

cgcontextdrawpath(context, kcgpathfillstroke); 

instead of

cgcontextfillpath(context); cgcontextstrokepath(context); 

the problem both cgcontextfillpath() , cgcontextstrokepath(context) clear current path, first operation succeeds, , second operation draws nothing. cgcontextdrawpath() combines fill , stroke without clearing path in between.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -