objective c - iOS, How to draw a rough line, for fun apps? -
i'm trying draw rough line, normal straight line looks odd in app. i'm using fun font etc , straight line doesn't work.
when rough, mean want add noise or texture it.
i've tried adding image texture options i've tried use uniform tiled approach looks georometricly sound.
i need either add scatter effect draw texture image in shape of line or sort of random approach add noise.
i know draw rough line in imaging app , use that, i'm not sure colouring , size @ stage , i'd rather use dynamic.
i've spend far long on issue , lot if time googling , can't find can use, if have solution please provide or point me @ example code.
thanks.
this best solution i've found, it's uniform...
#import "drawtexturedline.h" @implementation drawtexturedline - (void)drawrect:(cgrect)rect { cgcontextref context = uigraphicsgetcurrentcontext(); [self patternmake2:rect context:context]; } void pattern2callback (void *info, cgcontextref context) { uiimage *image = [uiimage imagenamed:@"particle.png"]; cgimageref imageref = [image cgimage]; cgcontextdrawimage(context, cgrectmake(0, 0, 50, 25), imageref); } - (void)patternmake2:(cgrect)rect context:(cgcontextref)context { static const cgpatterncallbacks callbacks = { 0, &pattern2callback, null }; cgcolorspaceref patternspace = cgcolorspacecreatepattern(null); cgcontextsetfillcolorspace(context, patternspace); cgcolorspacerelease(patternspace); cgsize patternsize = cgsizemake(25/2.0, 25); cgpatternref pattern = cgpatterncreate(null, self.bounds, cgaffinetransformidentity, patternsize.width, patternsize.height, kcgpathfillstroke, true, &callbacks); cgfloat alpha = 1; cgcontextsetfillpattern(context, pattern, &alpha); cgpatternrelease(pattern); cgcontextfillrect(context, rect); //cgcontextrestoregstate(context); } @end
not quite answering question draw lines in paint package , include app , use code set colour of lines.
https://coffeeshopped.com/2010/09/iphone-how-to-dynamically-color-a-uiimage
if use sprite kit becomes easier change colors of images
[skaction colorizewithcolor:[self randomcolor] colorblendfactor:1.0 duration:0]];
Comments
Post a Comment