objective c - drawing a Line in a couple of frames with Quartz 2d -


i objective c programmer. developing universal app. in app want use quartz draw square, not in 1 frame, rather frame frame. in code below there possibility. not good, because want draw rectangles, circles , other stuff. so, there better way draw such things.

-(void)drawrect:(cgrect)rect {     [self drawarect];     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextsetlinewidth(context, 20.0);     cgcolorspaceref colorspace = cgcolorspacecreatedevicergb();     cgfloat components[] = {0.0, 0.0, 1.0, 1.0};     cgcolorref color = cgcolorcreate(colorspace, components);     cgcontextsetstrokecolorwithcolor(context, color);     if (!firstlineready) {         cgcontextmovetopoint(context, 200, 200);         cgcontextaddlinetopoint(context, x, y);     }      if (firstlineready && !secondlineready) {         cgcontextmovetopoint(context, 200, 200);         cgcontextaddlinetopoint(context, 600, 200);         cgcontextmovetopoint(context, 600, 200);         cgcontextaddlinetopoint(context, x, y);     }      if (secondlineready && !thirdlineready) {         cgcontextmovetopoint(context, 200, 200);         cgcontextaddlinetopoint(context, 600, 200);         cgcontextmovetopoint(context, 600, 200);         cgcontextaddlinetopoint(context, 600, 600);         cgcontextmovetopoint(context, 600, 600);         cgcontextaddlinetopoint(context, x, y);     }      if (thirdlineready && ! fourthlineready) {         cgcontextmovetopoint(context, 200, 200);         cgcontextaddlinetopoint(context, 600, 200);         cgcontextmovetopoint(context, 600, 200);         cgcontextaddlinetopoint(context, 600, 600);         cgcontextmovetopoint(context, 600, 600);         cgcontextaddlinetopoint(context, 200, 600);         cgcontextmovetopoint(context, 200, 600);         cgcontextaddlinetopoint(context, x, y);     }      if (fourthlineready) {         cgcontextmovetopoint(context, 200, 200);         cgcontextaddlinetopoint(context, 600, 200);         cgcontextmovetopoint(context, 600, 200);         cgcontextaddlinetopoint(context, 600, 600);         cgcontextmovetopoint(context, 600, 600);         cgcontextaddlinetopoint(context, 200, 600);         cgcontextmovetopoint(context, 200, 600);         cgcontextaddlinetopoint(context, 200, 200);         [timer invalidate];             }      cgcontextstrokepath(context);     cgcolorspacerelease(colorspace);     cgcolorrelease(color); }  - (void) drawarect{      if (!firstlineready) {         x+=speed; y+=0;         if (x>=600) {             x=600;             firstlineready = yes;         }     }      if (firstlineready && !secondlineready ) {         x+=0; y+=speed;         if (y>=600) {             y=600;             secondlineready = yes;         }     }       if (firstlineready && secondlineready && !thirdlineready  ) {         x-=speed; y+=0;         if (x<=200) {             x=200;             thirdlineready = yes;         }     }      if (firstlineready && secondlineready && thirdlineready ) {         x+=0; y-=speed;         if (y<=200) {             y=200;             fourthlineready = yes;         }     } } 

is possible give cgcontextaddlinetopoint custom pattern pencil or biro?

oval cgrect arect= cgrectmake(80, 80, 160, 100);   cgcontextsetrgbstrokecolor(context, 0.6, 0.9, 0, 1.0);   cgcontextsetlinewidth(context, 3.0);   cgcontextaddellipseinrect(context, arect); //椭圆   cgcontextdrawpath(context, kcgpathstroke);   diamond cgcontextsetlinewidth(context, 2.0);  cgcontextsetstrokecolorwithcolor(context, [uicolor bluecolor].cgcolor);  cgcontextmovetopoint(context, 100, 100);  cgcontextaddlinetopoint(context, 150, 150);  cgcontextaddlinetopoint(context, 100, 200);  cgcontextaddlinetopoint(context, 50, 150);  cgcontextaddlinetopoint(context, 100, 100);  cgcontextstrokepath(context);   rectangle cgcontextsetlinewidth(context, 2.0);  cgcontextsetstrokecolorwithcolor(context, [uicolor bluecolor].cgcolor);  cgrect rectangle = cgrectmake(60,170,200,80);  cgcontextaddrect(context, rectangle);  cgcontextstrokepath(context);   or can opensource code github 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -