void on(item i) { switch(i) { case C : setcolor(CYAN); ellipse(64,64,0,360,60,60); line(125,30,64,64); line(64,64,125,78); setfillstyle(LINE_FILL, CYAN); floodfill(60,60,CYAN); break; case H : setcolor(BLUE); rectangle(148,20,236,108); line(168,0,192,54); line(192,54,216,0); line(168,128,192,74); line(192,74,216,128); setfillstyle(INTERLEAVE_FILL, BLUE); floodfill(192,64,BLUE); break; case E : setcolor(GREEN); rectangle(266,20,364,108); moveto(380,10); lineto(320,37); lineto(380,64); lineto(320,91); lineto(380,118); setfillstyle(HATCH_FILL, GREEN); floodfill(270,30,GREEN); break; case S1 : setcolor(YELLOW); moveto(510,10); lineto(390,50); lineto(510,50); lineto(390,100); break; case S2 : setcolor(LIGHTGRAY); moveto(639,1); lineto(520,55); lineto(639,55); lineto(520,125); break; case PLUS : setcolor(WHITE); setfillstyle(WIDE_DOT_FILL, RED); bar(293,150,352,350); bar(220,216,420,282); moveto(293,150); lineto(352,150); lineto(352,216); lineto(420,216); lineto(420,282); lineto(352,282); lineto(352,350); lineto(293,350); lineto(293,282); lineto(220,282); lineto(220,216); lineto(293,216); lineto(293,150); }; }
int main() { int gd=DETECT,gm; initgraph(&gd,&gm,""); int c=12; setbkcolor(0); //setlinestyle(0,1,2); int t; while(1) { settextstyle(2,0,5); outtextxy(100,10,"Press L,H ,T,P"); outtextxy(100,30,"Press 1 for Quit"); as: setcolor(13); ellipse(380,127,20,152,130,35); //////////////////////////////rear////////////////////////// line(490,109,560,142); line(560,142,569,142); line(569,142,582,102); line(582,102,620,92); line(593,132,617,125); line(617,124,627,96); line(620,92,628,97); line(472,86,602,96); line(501,113,575,121); line(443,77,475,80); line(443,77,432,93); line(475,80,472,85); //setcolor(4); line(593,132,593,137); line(593,137,600,141); line(600,141,600,185); line(600,185,608,192); line(608,192,608,234); line(608,234,586,253); line(586,253,577,248); ///////////////////////// mirror line(263,112,363,127); line(193,160,263,112); line(193,160,220,170); line(220,170,280,180); line(280,180,320,185); line(320,185,363,127); ////////////////////////////////sidemirror line(340,194,460,169); line(460,169,519,152); ellipse(512,144,300,30,10,10); ellipse(467,143,28,100,50,30); line(510,128,521,138); line(435,116,440,171); // setcolor(4); ////////////////////////////////////////cont// line(339,194,372,144); // line(372,140,386,128); ellipse(454,208,87,123,128,95); line(372,144,384,128); int b,x,y; ////////////////////////lower line(365,298,524,264); line(365,298,330,310); line(330,310,323,310); ///////////////////////////////bumper ellipse(162,221,135,190,90,40); line(96,193,140,174); line(140,174,160,168); line(160,168,192,161); //////////////////////front ellipse(75,246,95,190,18,18); line(57,251,57,286); //setcolor(4); ellipse(181,178,232,263,200,137); ellipse(195,180,256,286,200,137); ellipse(191,171,228,247,200,100); ellipse(231,198,234,275,200,80); //setcolor(9); //ellipse(195,170,256,286,200,137); //setcolor(12); ellipse(196,167,228,246,200,90); ellipse(231,184,234,276,200,80); ellipse(191,200,228,246,200,90); ellipse(228,218,234,276,200,80); ellipse(258,268,180,220,200,40); ellipse(178,296,244,355,16,10); ellipse(238,249,227,250,200,60); /////////////wheel1 ellipse(302,281,320,77,26,45); ellipse(290,277,65,162,40,45); ellipse(278,288,144,212,31,45); /////////////wheel2 //setcolor(5); ellipse(302+260,229,328,87,26,45); ellipse(290+280-7,277-50+2,90,162,40,45); ellipse(278+270,288-50,144,215,27,45); b=0; int v=0; ///////// ellipse(302+250+v,227+b,295,90,29,41); ellipse(302+234+v,231+b,245,306,50,40); //setlinestyle(3,0,3); ellipse(302+248+v,229+b,0,360,21,30); ellipse(302+247+v,229+b,0,360,8,10); setfillstyle(6,11); floodfill(302+248+v,230+b,13); line(546,201,546,257); line(554,201,554,257); setcolor(4); line(546+v,201+b,546+v,220+b); line(551+v,201+b-2,551+v,220+b); line(546+v,238+b,546+v,257+b); line(551+v,238+b+2,551+v,257+b+2); line(530+v,225+b,541+v,225+b); line(530+v,230+b,541+v,230); line(557+v,225+b,570+v,225+b); line(557+v,230+b,570+v,230+b); line(563+v,206+b,552+v,222+b); line(534+v,246+b,543+v,232+b); line(566+v,210+b,556+v,223+b); line(536+v,250+b,544+v,238+b); line(536+v,207+b,546+v,222+b); line(532+v,213+b,542+v,224+b); line(556+v,235+b,566+v,247+b); line(551+v,237+b,563+v,253+b); //////////////////////////////////////////////////// v=-260; b=56; ellipse(302+233+v,221+b,260,60,49,51); ellipse(302+234+v,231+b,245,306,50,40); setlinestyle(3,0,3); ellipse(302+243+v,224+b,0,360,28,35); line(249,328,269,328); ellipse(300+245+v,223+b,0,360,10,12); ellipse(285+249+v,239+b,210,260,30,33); floodfill(285+258+v,230+b,12); b=45; v=v-4; line(546+v,201+b,546+v,220+b+2); line(551+v,201+b,551+v,220+b+2); b=b+8; line(546+v,238+b,546+v,257+b+4); line(551+v,238+b,551+v,257+b+4); v=v-2; line(530+v-6,225+b,541+v,225+b); line(530+v-6,230+b,541+v,230+b); v=v+5; line(557+v,225+b,570+v+3,225+b); line(557+v-1,230+b,570+v+3,230+b); b=b-5; v=v-5; line(565+v+3,206+b,552+v+4,222+b-2); b=b+15; line(534+v,246+b,543+v+3,232+b-5); b=b-10; line(566+v+7,210+b-5,556+v+4,220+b); line(536+v-5,250+b,544+v-2,238+b-4); line(536+v,207+b-8,545+v,222+b-5); line(531+v,212+b-8,542+v,224+b-2); line(556+v,235+b,566+v+3,247+b+5); line(551+v,237+b,563+v+2,253+b+3); ///////////////////lights ellipse(199,250,144,345,18,8); line(185,245,206,230); setcolor(4); ellipse(223,234,340,110,8,5); line(230,237,217,252); line(206,230,220,229); setfillstyle(1,4); floodfill(200,240,12); ///////////////////////////////////// line(90,223,152,236); line(152,236,137,254); line(90,223,90,242); setfillstyle(10,9); floodfill(91,230,14); ellipse(240,270,104,136,100,60); ellipse(185,237,120,160,100,60); ellipse(80,221,357,134,10,10); line(152,236,168,228); /////////////////////////////////////////////// line(435,116,440,171); //////////////////////////////////////////hp line(134,185,220,210); line(134,185,196,160); line(214,212,318,185); /////////////////////////////////////////////////light setcolor(14); ellipse(166,247,99,330,8,8); ellipse(171,243,310,129,7,7); putpixel(174,250,13); putpixel(173,251,13); putpixel(164,239,13); putpixel(165,238,13); /////////////////////////////////////////road///////////////////// setcolor(13); line(1,430,639,300); line(1,445,639,315); line(1,210,93,194); line(1,195,194,158); line(1,170,639,71); line(1,170,229,135); line(520,90,639,71); line(478,86,639,56); int c=0; line(10,194+c,10,208+c); line(40,189+c,40,204+c); line(70,183+c,70,198+c); line(100,176+c,100,190+c); line(130,170+c,130,177+c); line(160,166+c,160,168+c); line(190,160+c,190,161+c); line(190+330,78+c,190+330,89+c); line(190+360,72+c,190+360,85+c); line(190+390,67+c,190+390,81+c); line(190+420,62+c,190+420,76+c); line(190+449,57+c,190+449,71+c); c=236; line(10,192+c,10,208+c); line(40,189+c-2,40,204+c-3); line(70,183+c-3,70,198+c-3); line(100,176+c-2,100,190+c-2); line(130,170+c-2,130,177+c+5); line(160,166+c-3,160,168+c+8); line(190,160+c-4,190,161+c+9); line(190+30,156+c-5,190+30,170+c-5); line(190+30+30,156+c-12,190+30+30,170+c-12); line(190+90,156+c-18,190+90,170+c-17); line(190+120,156+c-25,190+120,170+c-25); line(190+150,156+c-30,190+150,170+c-30); line(190+180,156+c-37,190+180,170+c-36); line(190+210,156+c-42,190+210,170+c-42); line(190+240,156+c-48,190+240,170+c-48); line(190+270,156+c-55,190+270,170+c-54); line(190+300,156+c-61,190+300,170+c-61); line(190+330,78+c+10,190+330,89+c+13); line(190+360,72+c+11,190+360,85+c+13); line(190+390,67+c+10,190+390,81+c+10); line(190+420,62+c+8,190+420,76+c+10); line(190+449,57+c+8,190+449,71+c+8); /////////////////road setcolor(12); /////////////////////////////1 line(1,310,25,306); line(6,318,30,315); line(1,310,6,318); line(25,306,30,314); int k,m; k=13*45+19; m=16*(-8); //2 setcolor(12); line(605,310-128,629,306-128); line(610,318-128,634,315-128); line(605,310-128,610,318-128); line(629,306-128,634,314-128); setcolor(12); //////////////////////////////////3 k=45; m=-8; line(46,302,70,298); line(51,310,75,307); line(46,302,51,310); line(70,298,75,306); setfillstyle(1,0); floodfill(64,303,12); setfillstyle(1,14); floodfill(14,314,12); floodfill(617,183,12); setfillstyle(1,0); floodfill(14,314,12); floodfill(617,183,12); setfillstyle(1,14); floodfill(64,303,12); t=getch(); if(t=='1') exit(0); if(t=='h') { //sound(710); delay(50); //nosound(); break; } if(t=='t') { while(!kbhit()) { setfillstyle(1,0); floodfill(536,213,13); floodfill(563,213,13); floodfill(561,244,13); floodfill(538,244,13); floodfill(274,295,13); floodfill(294,295,13); floodfill(274,265,13); floodfill(294,265,13); floodfill(548,250,13); floodfill(548,214,13); floodfill(533,228,13); floodfill(563,228,13); floodfill(262,281,13); floodfill(308,281,13); floodfill(284,251,13); floodfill(284,295,13); setfillstyle(1,12); floodfill(200,250,13); delay(10); setfillstyle(1,11); floodfill(170,250,13); floodfill(80,230,13); } setfillstyle(1,0); floodfill(200,250,13); delay(10); setfillstyle(1,11); floodfill(170,250,13); floodfill(80,230,13); } if(t=='l') { while(!kbhit()) { delay(120); setfillstyle(6,0); //////////////////////////ty floodfill(536,213,13); floodfill(563,213,13); floodfill(561,244,13); floodfill(538,244,13); floodfill(274,295,13); floodfill(294,295,13); floodfill(274,265,13); floodfill(294,265,13); setfillstyle(1,0); floodfill(64,303,12); ///////////////////////////////////road setfillstyle(9,0); /////////////////////color floodfill(81-40+5,419+7,13); floodfill(151-40,409+7,13); floodfill(211-40,397+7,13); floodfill(271-40,380+7,13); floodfill(331-40,368+7,13); floodfill(396-40,355+7,13); floodfill(450-40,345+7,13); floodfill(510-40,335+7,13); floodfill(570-40,325+7,13); floodfill(630-40,312+7,13); ////////////////////// floodfill(50,197,13); floodfill(110,177,13); floodfill(166,165,13); floodfill(527,86,13); floodfill(587,71,13); setfillstyle(6,14); //////////////////////////ty floodfill(548,250,13); floodfill(548,214,13); floodfill(533,228,13); floodfill(563,228,13); floodfill(262,281,13); floodfill(308,281,13); floodfill(284,251,13); floodfill(284,295,13); ////////////////////////////////////////road setfillstyle(9,10);///////////////////////////////////color floodfill(19,429,13); floodfill(81,419,13); floodfill(151,409,13); floodfill(211,397,13); floodfill(271,380,13); floodfill(331,368,13); floodfill(396,355,13); floodfill(450,345,13); floodfill(510,335,13); floodfill(570,325,13); floodfill(630,312,13); ////////////////////////////////////// floodfill(20,197,13); floodfill(80,187,13); floodfill(133,174,13); floodfill(517,86,13); floodfill(557,81,13); floodfill(627,70,13); setfillstyle(1,14); floodfill(14,314,12); floodfill(617,183,12); /////////////////////////////////////// setfillstyle(10,4); floodfill(302+248,230,13); floodfill(302+248+v,230+b,13); ///light setfillstyle(6,11); /////////// floodfill(200,250,13); floodfill(170,250,13); floodfill(80,230,13); delay(120); setfillstyle(6,0);/////////////////////ty floodfill(548,250,13); floodfill(548,214,13); floodfill(533,228,13); floodfill(563,228,13); floodfill(262,281,13); floodfill(308,281,13); floodfill(284,251,13); floodfill(284,295,13); /////////////////////////////////////road setfillstyle(9,0); ///////////////color floodfill(19,429,13); floodfill(81,419,13); floodfill(151,409,13); floodfill(211,397,13); floodfill(271,380,13); floodfill(331,368,13); floodfill(396,355,13); floodfill(450,345,13); floodfill(510,335,13); floodfill(570,325,13); floodfill(630,312,13); /////////////////////////////////////////////////////// floodfill(20,197,13); floodfill(80,187,13); floodfill(133,174,13); floodfill(517,86,13); floodfill(557,81,13); floodfill(627,70,13); ///////////////////////////// setfillstyle(1,0); floodfill(14,314,12); floodfill(617,183,12); setfillstyle(6,10); /////////////ty floodfill(536,213,13); floodfill(563,213,13); floodfill(561,244,13); floodfill(538,244,13); floodfill(274,295,13); floodfill(294,295,13); floodfill(274,265,13); floodfill(294,265,13); ////////////////////////////////////////////////road setfillstyle(9,14);/////////////////////////////////////////color floodfill(81-40+5,419+7,13); floodfill(151-40,409+7,13); floodfill(211-40,397+7,13); floodfill(271-40,380+7,13); floodfill(331-40,368+7,13); floodfill(396-40,355+7,13); floodfill(450-40,345+7,13); floodfill(510-40,335+7,13); floodfill(570-40,325+7,13); floodfill(630-40,312+7,13); ///////////////////////////////////////// floodfill(50,197,13); floodfill(110,177,13); floodfill(166,165,13); floodfill(527,86,13); floodfill(587,71,13); setfillstyle(1,14); floodfill(64,303,12); setfillstyle(9,4); floodfill(302+248,230,13); floodfill(302+248+v,230+b,13); delay(20); setfillstyle(1,14); floodfill(200,250,13); floodfill(170,250,13); floodfill(80,230,13); delay(20); setfillstyle(1,0); floodfill(200,250,13); floodfill(170,250,13); floodfill(80,230,13); } } if(t=='p') { int n=0; while(!kbhit()) { if(n<=60) n++; setcolor(0); rectangle(1+1,-10,90-1,-12+n); delay(14); setcolor(9); rectangle(1,-10,90,-10+n); if(n==60) { outtextxy(10,10,"L-LIGHTS"); outtextxy(10,20,"H-HORN"); outtextxy(10,30,"T-AllOY"); delay(400); } } setcolor(0); rectangle(1,-10,90,-10+n); rectangle(1,-10,90,-11+n); outtextxy(10,10,"L-LIGHTS"); outtextxy(10,20,"H-HORN"); outtextxy(10,30,"T-AllOY"); } } circle(300,100,3); //nosound(); getch(); }
void SdfRenderer::render(QPainter *painter, const QRectF &bounds) { current_size_x = static_cast<int>(bounds.width()); current_size_y = static_cast<int>(bounds.height()); mStartX = static_cast<int>(bounds.x()); mStartY = static_cast<int>(bounds.y()); this->painter = painter; QDomElement docElem = doc.documentElement(); QDomNode node = docElem.firstChild(); while(!node.isNull()) { QDomElement elem = node.toElement(); if(!elem.isNull()) { if (elem.tagName()=="line") { line(elem); } else if(elem.tagName()=="ellipse") { ellipse(elem); } else if (elem.tagName() == "arc") { arc(elem); } else if(elem.tagName()=="background") { background(elem); } else if(elem.tagName()=="text") { draw_text(elem); } else if (elem.tagName()=="rectangle") { rectangle(elem); } else if (elem.tagName()=="polygon") { polygon(elem); } else if (elem.tagName()=="point") { point(elem); } else if(elem.tagName()=="path") { path_draw(elem); } else if(elem.tagName()=="stylus") { stylus_draw(elem); } else if(elem.tagName()=="curve") { curve_draw(elem); } else if(elem.tagName()=="image") { image_draw(elem); } } node = node.nextSibling(); } this->painter = 0; }
//---------------------------------------------------------- void ofPath::ellipse(float x, float y, float width, float height){ ellipse(x,y,0.0f,width,height); }
main() { int driver = DETECT, mode; char c; int k1[] = { 0, 0, 20, 0, 20, 60, 30, 60, 30, 100, 0, 100, 0, 0 }; int k2[] = { 40, 0, 50, 0, 50, 60, 60, 60, 60, 100, 30, 100, 30, 60, 40, 60, 40, 0 }; int k3[] = { 70, 0, 90, 0, 90, 100, 60, 100, 60, 60, 70, 60, 70, 0 }; int k4[] = { 90, 0, 110, 0, 110, 60, 120, 60, 120, 100, 90, 100, 90, 0 }; int k5[] = { 130, 0, 140, 0, 140, 60, 150, 60, 150, 100, 120, 100, 120, 60, 130, 60, 130, 0 }; int k6[] = { 160, 0, 170, 0, 170, 60, 180, 60, 180, 100, 150, 100, 150, 60, 160, 60, 160, 0 }; int k7[] = { 190, 0, 210, 0, 210, 100, 180, 100, 180, 60, 190, 60, 190, 0 }; int k8[] = { 210, 0, 230, 0, 230, 60, 240, 60, 240, 100, 210, 100, 210, 0 }; int k9[] = { 250, 0, 260, 0, 260, 60, 270, 60, 270, 100, 240, 100, 240, 60, 250, 60, 250, 0 }; int k10[] = { 280, 0, 300, 0, 300, 100, 270, 100, 270, 60, 280, 60, 280, 0 }; int k11[] = { 300, 0, 330, 0, 330, 100, 300, 100, 300, 0 }; int k12[] = { 330, 0, 360, 0, 360, 100, 330, 100, 330, 0 }; initgraph(&driver, &mode, ""); int maxx = getmaxx(); int maxy = getmaxy(); for (long j = 0; j <= 300; j++) { putpixel(random(maxx), random(maxy), 4); delay(1); } setfillstyle(SOLID_FILL, BLACK); bar(89, 39, 571, 261); setlinestyle(SOLID_LINE, 3, 3); line(90, 50, 90, 250); //outline line(100, 40, 540, 40); line(100, 260, 540, 260); line(550, 250, 550, 50); arc(100, 50, 90, 180, 10); arc(100, 250, 180, 270, 10); arc(540, 250, 270, 360, 10); arc(540, 50, 0, 90, 10); circle(200, 90, 35); setfillstyle(SOLID_FILL, 9); floodfill(200, 90, WHITE); circle(482, 95, 42); setfillstyle(SOLID_FILL, 3); floodfill(482, 95, WHITE); setlinestyle(SOLID_LINE, 1, 1); rectangle(270, 60, 370, 130); setfillstyle(SOLID_FILL, 14); floodfill(290, 80, WHITE); rectangle(270, 130, 295, 140); setfillstyle(SOLID_FILL, 5); floodfill(280, 135, WHITE); rectangle(295, 130, 320, 140); setfillstyle(SOLID_FILL, 5); floodfill(300, 135, WHITE); rectangle(320, 130, 345, 140); setfillstyle(SOLID_FILL, 5); floodfill(330, 135, WHITE); rectangle(345, 130, 370, 140); setfillstyle(SOLID_FILL, 5); floodfill(350, 135, WHITE); rectangle(120, 60, 145, 70); setfillstyle(SOLID_FILL, 1); floodfill(130, 65, WHITE); rectangle(120, 90, 145, 100); setfillstyle(SOLID_FILL, 1); floodfill(130, 95, WHITE); ellipse(132, 125, 0, 360, 11, 8); setfillstyle(SOLID_FILL, RED); floodfill(132, 125, WHITE); circle(230, 130, 5); setfillstyle(SOLID_FILL, RED); floodfill(230, 130, WHITE); rectangle(387, 60, 427, 75); setfillstyle(SOLID_FILL, 10); floodfill(395, 70, WHITE); rectangle(385, 90, 403, 110); setfillstyle(SOLID_FILL, 6); floodfill(390, 100, WHITE); rectangle(411, 90, 430, 110); setfillstyle(SOLID_FILL, 6); floodfill(420, 100, WHITE); rectangle(387, 120, 427, 135); setfillstyle(SOLID_FILL, 10); floodfill(395, 130, WHITE); rectangle(150, 260, 510, 250); setfillstyle(SOLID_FILL, 8); floodfill(180, 255, WHITE); circle(500, 120, 6); setfillstyle(SOLID_FILL, 8); floodfill(500, 120, WHITE); setviewport(225, 300, 530, 410, 1); int poly1[] = { 0, 2, 12, 60, 22, 54, 18, 28, 35, 2, 0, 2 }; int poly2[] = { 10, 10, 23, 10, 14, 20, 10, 10 }; int poly3[] = { 50, 0, 60, 2, 60, 45, 50, 42, 50, 0 }; int poly4[] = { 71, 70, 83, 13, 105, 74, 87, 53, 71, 70 }; int poly5[] = { 85, 30, 90, 45, 83, 43, 85, 30 }; int poly6[] = { 110, 53, 120, 2, 130, 57, 148, 0, 135, 84, 132, 84, 118, 29, 110, 53 }; int poly7[] = { 177, 2, 200, 35, 180, 85, 160, 33, 177, 2 }; int poly8[] = { 178, 20, 190, 35, 179, 70, 166, 34, 178, 20 }; drawpoly(6, poly1); setfillstyle(SOLID_FILL, RED); fillpoly(6, poly1); drawpoly(4, poly2); setfillstyle(SOLID_FILL, BLACK); fillpoly(4, poly2); drawpoly(5, poly3); setfillstyle(SOLID_FILL, RED); fillpoly(5, poly3); drawpoly(5, poly4); setfillstyle(SOLID_FILL, RED); fillpoly(5, poly4); drawpoly(4, poly5); setfillstyle(SOLID_FILL, BLACK); fillpoly(4, poly5); drawpoly(8, poly6); setfillstyle(SOLID_FILL, RED); fillpoly(8, poly6); drawpoly(5, poly7); setfillstyle(SOLID_FILL, RED); fillpoly(5, poly7); drawpoly(5, poly8); setfillstyle(SOLID_FILL, BLACK); fillpoly(5, poly8); setviewport(150, 150, 510, 250, 1); pnobody(); c = getch(); do { switch (c) { case 'q': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k1); pno(261); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k1); break; } case 'w': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k2); pno(293); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k2); pnobody(); break; } case 'e': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k3); pno(329); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k3); pnobody(); break; } case 'r': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k4); pno(350); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k4); pnobody(); break; } case 't': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k5); pno(392); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k5); pnobody(); break; } case 'y': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k6); pno(440); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k6); pnobody(); break; } case 'u': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k7); pno(493); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k7); pnobody(); break; } case 'i': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k8); pno(523); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k8); pnobody(); break; } case 'o': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k9); pno(587); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k9); pnobody(); break; } case 'p': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k10); pno(659); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k10); pnobody(); break; } case '[': { setfillstyle(SOLID_FILL, GREEN); fillpoly(5, k11); pno(698); setfillstyle(SOLID_FILL, BLUE); fillpoly(5, k11); pnobody(); break; } case ']': { setfillstyle(SOLID_FILL, RED); fillpoly(5, k12); pno(784); setfillstyle(SOLID_FILL, BLUE); fillpoly(5, k12); pnobody(); break; } case '1': { setfillstyle(SOLID_FILL, YELLOW); bar(20, 0, 40, 60); pno(311); setfillstyle(SOLID_FILL, BLACK); bar(20, 0, 40, 60); pnobody(); break; } case '2': { setfillstyle(SOLID_FILL, WHITE); bar(50, 0, 70, 60); pno(370); setfillstyle(SOLID_FILL, BLACK); bar(50, 0, 70, 60); pnobody(); break; } case '4': { setfillstyle(SOLID_FILL, YELLOW); bar(110, 0, 130, 60); pno(415); setfillstyle(SOLID_FILL, BLACK); bar(110, 0, 130, 60); pnobody(); break; } case '5': { setfillstyle(SOLID_FILL, WHITE); bar(140, 0, 160, 60); pno(466); setfillstyle(SOLID_FILL, BLACK); bar(140, 0, 160, 60); pnobody(); break; } case '6': { setfillstyle(SOLID_FILL, YELLOW); bar(170, 0, 190, 60); pno(554); setfillstyle(SOLID_FILL, BLACK); bar(170, 0, 190, 60); pnobody(); break; } case '8': { setfillstyle(SOLID_FILL, WHITE); bar(230, 0, 250, 60); pno(662); setfillstyle(SOLID_FILL, BLACK); bar(230, 0, 250, 60); pnobody(); break; } case '9': { setfillstyle(SOLID_FILL, YELLOW); bar(260, 0, 280, 60); pno(740); setfillstyle(SOLID_FILL, BLACK); bar(260, 0, 280, 60); pnobody(); break; } case 'Q': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k1); pno(261); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k1); break; } case 'W': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k2); pno(293); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k2); pnobody(); break; } case 'E': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k3); pno(329); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k3); pnobody(); break; } case 'R': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k4); pno(350); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k4); pnobody(); break; } case 'T': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k5); pno(392); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k5); pnobody(); break; } case 'Y': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k6); pno(440); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k6); pnobody(); break; } case 'U': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k7); pno(493); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k7); pnobody(); break; } case 'I': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k8); pno(523); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k8); pnobody(); break; } case 'O': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k9); pno(587); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k9); pnobody(); break; } case 'P': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k10); pno(659); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k10); pnobody(); break; } case ' ': { break; } } c = getch(); } while (c != ' '); setviewport(0, 0, maxx, maxy, 1); cleardevice(); for (j = 0; j <= 1100; j++) { putpixel(random(maxx), random(maxy), 4); delay(1); } setcolor(4); outtextxy(270, 150, "C R E D I T S"); for (int i = 0; i <= 3; i++) { outtextxy(260, 155 + i, "_______________"); } delay(600); outtextxy(150, 200, " #Suvojit Manna:Concept & Design,Core Programing"); outtextxy(160, 205, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "); delay(600); outtextxy(165, 250, " #Prangshu Shyam:Graphical Assisstance"); outtextxy(180, 255, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "); delay(600); outtextxy(200, 300, " #Sourav Kundu:Final Compilation"); outtextxy(210, 305, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "); getch(); return 0; }
main() { int gd = DETECT,gm; int maxx,maxy,x,y,button,prevx,prevy,temp1,temp2,key,color; char ch = 'f' ; // default free-hand drawing initgraph(&gd,&gm,"C:\\TC\\BGI"); maxx = getmaxx(); maxy = getmaxy(); setcolor(BLUE); rectangle(0,0,maxx,maxy); setcolor(WHITE); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); outtextxy(maxx/2-180,maxy-28,"<a href="http://www.programmingsimplified.com"">www.programmingsimplified.com"</a>); draw_color_panel(); draw_shape_panel(); setviewport(1,1,maxx-1,maxy-1,1); restrictmouseptr(1,1,maxx-1,maxy-1); showmouseptr(); rectangle(2,2,518,427); setviewport(1,1,519,428,1); while(1) { if(kbhit()) { key = get_key(); if( key == 1 ) { closegraph(); exit(0); } } getmousepos(&button,&x,&y); if( button == 1 ) { if( x > 4 && x < 635 && y > 431 && y < 457 ) change_color( x, y ); else if ( x > 529 && x < 625 && y > 40 && y < 250 ) ch = change_shape( x, y ); temp1 = x ; temp2 = y ; if ( ch == 'f' ) { hidemouseptr(); while( button == 1 ) { line(temp1,temp2,x,y); temp1 = x; temp2 = y; getmousepos(&button,&x,&y); } showmouseptr(); } while( button == 1) getmousepos(&button,&x,&y); /* to avoid interference of mouse while drawing */ hidemouseptr(); if( ch == 'p') putpixel(x,y,getcolor()); else if ( ch == 'b' ) { setfillstyle(SOLID_FILL,getcolor()); bar(temp1,temp2,x,y); } else if ( ch == 'l') line(temp1,temp2,x,y); else if ( ch == 'e') ellipse(temp1,temp2,0,360,abs(x-temp1),abs(y-temp2)); else if ( ch == 'r' ) rectangle(temp1,temp2,x,y); else if ( ch == 'c' ) { ch = 'f'; // setting to freehand drawing clearviewport(); color = getcolor(); setcolor(WHITE); rectangle(2,2,518,427); setcolor(color); } showmouseptr(); } } }
int main() { int gd=DETECT,gm,i=0,x,y,area; initgraph(&gd,&gm,"tc:\bgi");//put your directory contains egavga.bgi rectangle(0,0,getmaxx(),getmaxy());//to find max x and y coordinate in the screen arc(240,120,40,140,70);//arc(x,y,stangle,endangle,radius); ellipse(165,80,10,280,20,20);//ellipse (x,y,stangle,endangle,xrad,yrad) ,ears ellipse(315,80,-100,170,20,20);//ears arc(235,120,163,215,70); arc(245,120,-35,17,70); ellipse(193,178,85,280,40,20); ellipse(283,178,-100,95,40,20); ellipse(238,199,180,0,39,50); ellipse(213,123,44,240,33,40); ellipse(262,123,-60,135,33,40); ellipse(210,123,0,360,13,20);//left eye ellipse(265,123,0,360,13,20);//right eye ellipse(210,133,0,360,10,10);//left eye ball ellipse(265,133,0,360,10,10);//right eye ball ellipse(210,133,0,360,3,3);//left eye ball ellipse(265,133,0,360,3,3);//right eye ball ellipse(238,160,0,360,10,13);//nose arc(240,125,228,312,68);//mouth arc(240,120,230,310,72);//mouth setfillstyle(1,4); floodfill(238,100,15);//floodfill(238,160,15);//nose setfillstyle(1,15); floodfill(210,113,15); floodfill(265,113,15); setfillstyle(1,9); floodfill(210,100,15); setfillstyle(1,1); floodfill(315,80,15); moveto(203,220); lineto(203,260); lineto(183,260); lineto(183,350); lineto(293,350); lineto(293,260); lineto(273,260); lineto(273,220); moveto(183,350); lineto(173,460); lineto(213,460); lineto(238,400); lineto(263,460); lineto(303,460); lineto(293,350); moveto(173,460); lineto(143,478); lineto(213,478); lineto(213,460); moveto(263,460); lineto(263,478); lineto(333,478); lineto(303,460); line(238,400,238,350); //right hand moveto(183,260); lineto(113,310); lineto(183,375); moveto(183,280); lineto(137,310); lineto(181,353); setfillstyle(2,13); floodfill(190,300,15); setfillstyle(1,5); floodfill(223,400,15); setfillstyle(1,5); floodfill(253,400,15); setfillstyle(1,6); floodfill(173,470,15); floodfill(303,470,15); //fingers secondleft(); ellipse(413.5,228,0,180,3.5,3.5); line(420,240,433,240); line(423,247,440,247); line(413,240,410,228); line(417,228,420,240); ellipse(433,243.5,-90,90,3.5,3.5); line(423,254,440,254); ellipse(440,250.5,-90,90,3.5,3.5); ellipse(430,257,-90,90,3,3); line(413,260,430,260); area=imagesize(409,224,444,261); buf=malloc(area); getimage(409,224,444,261,buf); while(!kbhit()) { if(i==0) { setfillstyle(1,15); setcolor(15); ellipse(210,133,0,360,10,10);//left eye ball ellipse(265,133,0,360,10,10);//right eye ball setcolor(0); ellipse(210,133,0,360,3,3);//left eye ball ellipse(265,133,0,360,3,3);//right eye ball floodfill(210,133,15); floodfill(265,133,15); setcolor(0); putimage(391,209,buf,1); firstleft(); setcolor(15); secondleft(); putimage(409,224,buf,0); i=1; } else { setfillstyle(1,0); setcolor(0); ellipse(210,133,0,360,10,10);//left eye ball ellipse(265,133,0,360,10,10);//right eye ball floodfill(210,133,0); floodfill(265,133,0); setcolor(15); ellipse(210,133,0,360,3,3);//left eye ball ellipse(265,133,0,360,3,3);//right eye ball floodfill(210,133,15); floodfill(265,133,15); setcolor(0); putimage(409,224,buf,1); secondleft(); setcolor(15); firstleft(); putimage(391,209,buf,0); i=0; } delay(300); } getch(); return 0; }
void game() { //GAME SCREEN setgraph(); setbkcolor(0); setcolor(RED); settextstyle(4,0,5); outtextxy(25,30,"CHOOSE YOUR TEAM :"); setcolor(1); settextstyle(0,0,2); outtextxy(25,100,"1. New York Knicks"); setcolor(2); outtextxy(25,130,"2. Boston Celtics"); setcolor(3); outtextxy(25,160,"3. Orlando Jazz"); setcolor(5); outtextxy(25,190,"4. Pheonix Suns"); setcolor(11); outtextxy(25,220,"5. New Orleans Hornets"); setcolor(12); outtextxy(25,250,"6. Miami Heat"); setcolor(14); outtextxy(25,280,"7. Los Angeles Lakers"); setcolor(15); outtextxy(25,310,"8. Chicago Bulls"); char e=getch(); cleardevice(); int col; settextstyle(0,0,2); switch (e) { case '1':col=1; setcolor(col); outtextxy(10,10,"New York Knicks"); break; case '2' :col=2; setcolor(col); outtextxy(10,10,"Boston Celtics"); break; case '3' :col=3; setcolor(col); outtextxy(10,10,"Orlando Jazz"); break; case '4' :col=5; setcolor(col); outtextxy(10,10,"Pheonix Suns"); break; case '5' :col=11; setcolor(col); outtextxy(10,10,"New Orleans Hornets"); break; case '6' :col=12; setcolor(col); outtextxy(10,10,"Miami Heat"); break; case '7' :col=14; setcolor(col); outtextxy(10,10,"Los Angeles Lakers"); break; case '8' :col=15; setcolor(col); outtextxy(10,10,"Chicago Bulls"); break; } int k=0; setfillstyle(1,6); bar(0,280,640,480);//COURT setfillstyle(1,YELLOW); bar(200,300,210,340); setfillstyle(1,GREEN); bar(200,340,210,350); setfillstyle(1,RED); bar(200,350,210,390); setcolor(15); line(320,280,320,480); ellipse(0,360,0,360,50,50); ellipse(320,360,0,360,50,30); ellipse(640,360,0,360,50,50); setfillstyle(1,RED); bar(0,230,640,280);//NBA settextstyle(0,0,2); setcolor(15); for(int i=80;i<=500;i+=80) outtextxy(i,255,"NBA"); setfillstyle(1,14); bar(600,120,610,360);//BASKET setcolor(15); for(i=10,k=0;i>0;i--,k+=5) ellipse(575,120+k,0,360,15+i,10);//BASKET bar(30,120,40,360);//BASKET setcolor(15); for(i=10,k=0;i>0;i--,k+=5) ellipse(65,120+k,0,360,15+i,10);//BASKET //PLAYER circle(145,240,12); setfillstyle(1,col); floodfill(145,240,15); rectangle(145,252,147,390); floodfill(146,260,15); line(146,260,165,295); line(165,295,178,295); setfillstyle(1,15); circle(50,437,30); circle(50,437,33); settextstyle(6,0,2); outtextxy(40,406,"EA"); outtextxy(25,426,"Sports"); rectangle(30,45,150,80); settextstyle(4,0,2); outtextxy(34,47,"SCORE: "); //game loop char str[5],quit; int m=0,g=1; for(int end=1;end>0,g<=10;end++) { int x=317,y=0; for(;;x+=y) { setcolor(15); circle(173,x,16); setfillstyle(1,15); floodfill(173,x,15); delay(120-10*g); circle(173,x,16); setfillstyle(1,6); floodfill(173,x,6); if(x>=385) y=-2; else if(x<=317) y=2; if(kbhit()) { char ch=getch(); if(ch=='x'||ch=='X'||ch==13) break; else if(ch==27) { cleardevice(); setbkcolor(BLUE); setcolor(GREEN); settextstyle(4,0,2); outtextxy(150,100,"GAME OVER"); outtextxy(150,150,"YOUR FINAL SCORE IS : "); itoa(m,str,10); outtextxy(150,200,str); delay(2000); outtextxy(150,250,"WANNA PLAY AGAIN ? (Y/N) : "); quit=getch(); if(quit=='y'||quit=='Y') game(); else if(quit=='n'||quit=='N') exit(0); } } } int t,o; if(x<340) t=13; else if(x<350) t=17; else t=19; o=t; int xx=160,yy=125,b=0; char v[2]; if(t==17) { arc(145,210,0,90,100); line(145,210,145,110); line(145,210,245,210); for(;xx>0;) { xx+=b; yy+=b; setcolor(RED); line(150,205,xx,yy); if(xx==200) delay(100); else delay(250); setcolor(0); line(150,205,xx,yy); if(xx==200) delay(100); else delay(250); if(xx==160) b=40; else if(xx==240) b=-40; if(kbhit()) { char ang=getch(); if(ang=='x'||ang=='X'||ang==13) { setfillstyle(1,0); bar(145,110,245,210); break; } else if(ang==27) { cleardevice(); setbkcolor(15); setcolor(RED); settextstyle(4,0,2); outtextxy(150,100,"GAME OVER"); outtextxy(150,150,"YOUR FINAL SCORE IS : "); itoa(m,str,10); outtextxy(150,200,str); delay(2000); outtextxy(150,250,"WANNA PLAY AGAIN ? (Y/N) : "); quit=getch(); if(quit=='y'||quit=='Y') game(); else if(quit=='n'||quit=='N') exit(0); } } } if(xx==240) t=13; else if(xx==200) t=17; else if(xx==160) t=19; o=t; } int p=145,q=200; for(int kk=0;q<210&&p<550;t-=1) { setcolor(15); p+=15; q-=t; circle(p,q,16); setfillstyle(1,15); floodfill(p,q,15); delay(100); circle(p,q,16); setfillstyle(1,0); floodfill(p,q,0); } if(o==17) { circle(575,195,16); setfillstyle(1,15); floodfill(575,195,15); delay(150); circle(575,195,16); setfillstyle(1,0); floodfill(575,195,0); circle(575,255,16); setfillstyle(1,15); floodfill(575,255,15); delay(150); circle(575,255,16); setfillstyle(1,RED); floodfill(575,255,RED); settextstyle(6,0,2); outtextxy(200,100,"2 POINTS !!"); delay(1000); setfillstyle(1,0); bar(190,90,450,150); setcolor(15); bar(120,50,148,75); m+=2; itoa(m,str,10); settextstyle(4,0,2); outtextxy(121,47,str); g++; } else { settextstyle(6,0,2); outtextxy(200,100,"MISSED SHOT..."); delay(1000); bar(190,90,480,150); } } cleardevice(); setbkcolor(BLUE); setcolor(2); outtextxy(150,50,"CONGRATS!! YOU COMPLETED ALL LEVELS"); outtextxy(150,100,"GAME OVER"); outtextxy(150,150,"YOUR FINAL SCORE IS : "); itoa(m,str,10); outtextxy(150,200,str); delay(2000); outtextxy(150,250,"WANNA PLAY AGAIN ? (Y/N) : "); quit=getch(); if(quit=='y'||quit=='Y') game(); else if(quit=='n'||quit=='N') exit(0); getch(); closegraph(); }
// Create a grayscale face image that has a standard size and contrast & brightness. // "srcImg" should be a copy of the whole color camera frame, so that it can draw the eye positions onto. // If 'doLeftAndRightSeparately' is true, it will process left & right sides seperately, // so that if there is a strong light on one side but not the other, it will still look OK. // Performs Face Preprocessing as a combination of: // - geometrical scaling, rotation and translation using Eye Detection, // - smoothing away image noise using a Bilateral Filter, // - standardize the brightness on both left and right sides of the face independently using separated Histogram Equalization, // - removal of background and hair using an Elliptical Mask. // Returns either a preprocessed face square image or NULL (ie: couldn't detect the face and 2 eyes). // If a face is found, it can store the rect coordinates into 'storeFaceRect' and 'storeLeftEye' & 'storeRightEye' if given, // and eye search regions into 'searchedLeftEye' & 'searchedRightEye' if given. Mat getPreprocessedFace(Mat &srcImg, int desiredFaceWidth, CascadeClassifier &faceCascade, CascadeClassifier &eyeCascade1, CascadeClassifier &eyeCascade2, bool doLeftAndRightSeparately, Rect *storeFaceRect, Point *storeLeftEye, Point *storeRightEye, Rect *searchedLeftEye, Rect *searchedRightEye) { // Use square faces. int desiredFaceHeight = desiredFaceWidth; // Mark the detected face region and eye search regions as invalid, in case they aren't detected. if (storeFaceRect) storeFaceRect->width = -1; if (storeLeftEye) storeLeftEye->x = -1; if (storeRightEye) storeRightEye->x= -1; if (searchedLeftEye) searchedLeftEye->width = -1; if (searchedRightEye) searchedRightEye->width = -1; // Find the largest face. Rect faceRect; detectLargestObject(srcImg, faceCascade, faceRect,SCALEDWIDTH); // Check if a face was detected. if (faceRect.width > 0) { // Give the face rect to the caller if desired. if (storeFaceRect) *storeFaceRect = faceRect; Mat faceImg = srcImg(faceRect); // Get the detected face image. // If the input image is not grayscale, then convert the BGR or BGRA color image to grayscale. Mat gray; if (faceImg.channels() == 3) { cvtColor(faceImg, gray, CV_BGR2GRAY); } else if (faceImg.channels() == 4) { cvtColor(faceImg, gray, CV_BGRA2GRAY); } else { // Access the input image directly, since it is already grayscale. gray = faceImg; } // Search for the 2 eyes at the full resolution, since eye detection needs max resolution possible! Point leftEye, rightEye; detectBothEyes(gray, eyeCascade1, eyeCascade2, leftEye, rightEye, searchedLeftEye, searchedRightEye); // Give the eye results to the caller if desired. if (storeLeftEye) *storeLeftEye = leftEye; if (storeRightEye) *storeRightEye = rightEye; // Check if both eyes were detected. if (leftEye.x >= 0 && rightEye.x >= 0) { // Make the face image the same size as the training images. // Since we found both eyes, lets rotate & scale & translate the face so that the 2 eyes // line up perfectly with ideal eye positions. This makes sure that eyes will be horizontal, // and not too far left or right of the face, etc. // Get the center between the 2 eyes. Point2f eyesCenter = Point2f( (leftEye.x + rightEye.x) * 0.5f, (leftEye.y + rightEye.y) * 0.5f ); // Get the angle between the 2 eyes. double dy = (rightEye.y - leftEye.y); double dx = (rightEye.x - leftEye.x); double len = sqrt(dx*dx + dy*dy); double angle = atan2(dy, dx) * 180.0/CV_PI; // Convert from radians to degrees. // Hand measurements shown that the left eye center should ideally be at roughly (0.19, 0.14) of a scaled face image. const double DESIRED_RIGHT_EYE_X = (1.0f - DESIRED_LEFT_EYE_X); // Get the amount we need to scale the image to be the desired fixed size we want. double desiredLen = (DESIRED_RIGHT_EYE_X - DESIRED_LEFT_EYE_X) * desiredFaceWidth; double scale = desiredLen / len; // Get the transformation matrix for rotating and scaling the face to the desired angle & size. Mat rot_mat = getRotationMatrix2D(eyesCenter, angle, scale); // Shift the center of the eyes to be the desired center between the eyes. rot_mat.at<double>(0, 2) += desiredFaceWidth * 0.5f - eyesCenter.x; rot_mat.at<double>(1, 2) += desiredFaceHeight * DESIRED_LEFT_EYE_Y - eyesCenter.y; // Rotate and scale and translate the image to the desired angle & size & position! // Note that we use 'w' for the height instead of 'h', because the input face has 1:1 aspect ratio. Mat warped = Mat(desiredFaceHeight, desiredFaceWidth, CV_8U, Scalar(128)); // Clear the output image to a default grey. warpAffine(gray, warped, rot_mat, warped.size()); //imshow("warped", warped); // Give the image a standard brightness and contrast, in case it was too dark or had low contrast. if (!doLeftAndRightSeparately) { // Do it on the whole face. equalizeHist(warped, warped); } else { // Do it seperately for the left and right sides of the face. equalizeLeftAndRightHalves(warped); } //imshow("equalized", warped); // Use the "Bilateral Filter" to reduce pixel noise by smoothing the image, but keeping the sharp edges in the face. Mat filtered = Mat(warped.size(), CV_8U); bilateralFilter(warped, filtered, 0, 20.0, 2.0); //imshow("filtered", filtered); // Filter out the corners of the face, since we mainly just care about the middle parts. // Draw a filled ellipse in the middle of the face-sized image. Mat mask = Mat(warped.size(), CV_8U, Scalar(0)); // Start with an empty mask. Point faceCenter = Point( desiredFaceWidth/2, cvRound(desiredFaceHeight * FACE_ELLIPSE_CY) ); Size size = Size( cvRound(desiredFaceWidth * FACE_ELLIPSE_W), cvRound(desiredFaceHeight * FACE_ELLIPSE_H) ); ellipse(mask, faceCenter, size, 0, 0, 360, Scalar(255), CV_FILLED); //imshow("mask", mask); // Use the mask, to remove outside pixels. Mat dstImg = Mat(warped.size(), CV_8U, Scalar(128)); // Clear the output image to a default gray. /* namedWindow("filtered"); imshow("filtered", filtered); namedWindow("dstImg"); imshow("dstImg", dstImg); namedWindow("mask"); imshow("mask", mask); */ // Apply the elliptical mask on the face. filtered.copyTo(dstImg, mask); // Copies non-masked pixels from filtered to dstImg. //imshow("dstImg", dstImg); return dstImg; } /* else { // Since no eyes were found, just do a generic image resize. resize(gray, tmpImg, Size(w,h)); } */ } return Mat(); }
/* Find cell soma */ bool findCellSoma( std::vector<cv::Point> nucleus_contour, cv::Mat cell_mask, cv::Mat *intersection, std::vector<cv::Point> *soma_contour ) { bool status = false; // Calculate the min bounding rectangle cv::RotatedRect min_area_rect = minAreaRect(cv::Mat(nucleus_contour)); cv::RotatedRect scaled_rect = minAreaRect(cv::Mat(nucleus_contour)); // Nucleus' region of influence cv::Mat roi_mask = cv::Mat::zeros(cell_mask.size(), CV_8UC1); scaled_rect.size.width = (float)(SOMA_FACTOR * scaled_rect.size.width); scaled_rect.size.height = (float)(SOMA_FACTOR * scaled_rect.size.height); ellipse(roi_mask, scaled_rect, 255, -1, 8); ellipse(roi_mask, min_area_rect, 0, -1, 8); int mask_score = countNonZero(roi_mask); // Soma present in ROI bitwise_and(roi_mask, cell_mask, *intersection); int intersection_score = countNonZero(*intersection); // Add the nucleus contour to intersection region ellipse(*intersection, min_area_rect, 255, -1, 8); // Add to the soma mask if coverage area exceeds a certain threshold float ratio = ((float) intersection_score) / mask_score; if (ratio >= SOMA_COVERAGE_RATIO) { // Segment cv::Mat soma_segmented; std::vector<std::vector<cv::Point>> contours_soma; std::vector<cv::Vec4i> hierarchy_soma; std::vector<HierarchyType> soma_contour_mask; std::vector<double> soma_contour_area; contourCalc( *intersection, 1.0, &soma_segmented, &contours_soma, &hierarchy_soma, &soma_contour_mask, &soma_contour_area ); double max_area = 0.0; for (size_t i = 0; i < contours_soma.size(); i++) { if (soma_contour_mask[i] != HierarchyType::PARENT_CNTR) continue; if (contours_soma[i].size() < 5) continue; if (soma_contour_area[i] < MIN_SOMA_SIZE) continue; // Find the largest permissible contour if (soma_contour_area[i] > max_area) { max_area = soma_contour_area[i]; *soma_contour = contours_soma[i]; status = true; } } } return status; }
//---------------------------------------------------------- void ofPath::ellipse(const ofPoint & p, float width, float height){ ellipse(p.x,p.y,p.z,width,height); }
void SvgElementVisitor::visit(clan::DomElement &e) { if (e.get_namespace_uri() != Svg::svg_ns) return; // To do: do a more efficient search for the correct handler auto local_name = e.get_local_name(); if (local_name == "a") a(e); else if (local_name == "altGlyph") altGlyph(e); else if (local_name == "altGlyphDef") altGlyphDef(e); else if (local_name == "altGlyphItem") altGlyphItem(e); else if (local_name == "animate") animate(e); else if (local_name == "animateColor") animateColor(e); else if (local_name == "animateMotion") animateMotion(e); else if (local_name == "animateTransform") animateTransform(e); else if (local_name == "circle") circle(e); else if (local_name == "clipPath") clipPath(e); else if (local_name == "color-profile") color_profile(e); else if (local_name == "cursor") cursor(e); else if (local_name == "defs") defs(e); else if (local_name == "desc") desc(e); else if (local_name == "ellipse") ellipse(e); else if (local_name == "feBlend") feBlend(e); else if (local_name == "feColorMatrix") feColorMatrix(e); else if (local_name == "feComponentTransfer") feComponentTransfer(e); else if (local_name == "feComposite") feComposite(e); else if (local_name == "feConvolveMatrix") feConvolveMatrix(e); else if (local_name == "feDiffuseLighting") feDiffuseLighting(e); else if (local_name == "feDisplacementMap") feDisplacementMap(e); else if (local_name == "feDistantLight") feDistantLight(e); else if (local_name == "feFlood") feFlood(e); else if (local_name == "feFuncA") feFuncA(e); else if (local_name == "feFuncB") feFuncB(e); else if (local_name == "feFuncG") feFuncG(e); else if (local_name == "feFuncR") feFuncR(e); else if (local_name == "feGaussianBlur") feGaussianBlur(e); else if (local_name == "feImage") feImage(e); else if (local_name == "feMerge") feMerge(e); else if (local_name == "feMergeNode") feMergeNode(e); else if (local_name == "feMorphology") feMorphology(e); else if (local_name == "feOffset") feOffset(e); else if (local_name == "fePointLight") fePointLight(e); else if (local_name == "feSpecularLighting") feSpecularLighting(e); else if (local_name == "feSpotLight") feSpotLight(e); else if (local_name == "feTile") feTile(e); else if (local_name == "feTurbulence") feTurbulence(e); else if (local_name == "filter") filter(e); else if (local_name == "font") font(e); else if (local_name == "font-face") font_face(e); else if (local_name == "font-face-format") font_face_format(e); else if (local_name == "font-face-name") font_face_name(e); else if (local_name == "font-face-src") font_face_src(e); else if (local_name == "font-face-uri") font_face_uri(e); else if (local_name == "foreignObject") foreignObject(e); else if (local_name == "g") g(e); else if (local_name == "glyph") glyph(e); else if (local_name == "glyphRef") glyphRef(e); else if (local_name == "hkern") hkern(e); else if (local_name == "image") image(e); else if (local_name == "line") line(e); else if (local_name == "linearGradient") linearGradient(e); else if (local_name == "marker") marker(e); else if (local_name == "mask") mask(e); else if (local_name == "metadata") metadata(e); else if (local_name == "missing-glyph") missing_glyph(e); else if (local_name == "mpath") mpath(e); else if (local_name == "path") path(e); else if (local_name == "pattern") pattern(e); else if (local_name == "polygon") polygon(e); else if (local_name == "polyline") polyline(e); else if (local_name == "radialGradient") radialGradient(e); else if (local_name == "rect") rect(e); else if (local_name == "script") script(e); else if (local_name == "set") set(e); else if (local_name == "stop") stop(e); else if (local_name == "style") style(e); else if (local_name == "svg") svg(e); else if (local_name == "switch") switch_(e); else if (local_name == "symbol") symbol(e); else if (local_name == "text") text(e); else if (local_name == "textPath") textPath(e); else if (local_name == "title") title(e); else if (local_name == "tref") tref(e); else if (local_name == "tspan") tspan(e); else if (local_name == "use") use(e); else if (local_name == "view") view(e); else if (local_name == "vkern") vkern(e); }
/* Trace une ellipse de centre (x, y) et de rayons rx et ry */ void Ellipse(int x, int y, int rx, int ry) { ellipse(fenetreCourante, x, y, rx, ry); }
/** * @brief Processed a search request. * @param request the request to proceed. */ u_int32_t ORBSearcher::searchImage(SearchRequest &request) { timeval t[5]; gettimeofday(&t[0], NULL); cout << "Loading the image and extracting the ORBs." << endl; Mat img; u_int32_t i_ret = ImageLoader::loadImage(request.imageData.size(), request.imageData.data(), img); if (i_ret != OK) return i_ret; vector<KeyPoint> keypoints; Mat descriptors; ORB(1000, 1.02, 100)(img, noArray(), keypoints, descriptors); gettimeofday(&t[1], NULL); cout << "time: " << getTimeDiff(t[0], t[1]) << " ms." << endl; cout << "Looking for the visual words. " << endl; unordered_map<u_int32_t, list<Hit> > imageReqHits; // key: visual word, value: the found angles for (unsigned i = 0; i < keypoints.size(); ++i) { #define NB_NEIGHBORS 1 vector<int> indices(NB_NEIGHBORS); vector<int> dists(NB_NEIGHBORS); wordIndex->knnSearch(descriptors.row(i), indices, dists, NB_NEIGHBORS); for (unsigned j = 0; j < indices.size(); ++j) { const unsigned i_wordId = indices[j]; if (imageReqHits.find(i_wordId) == imageReqHits.end()) { // Convert the angle to a 16 bit integer. Hit hit; hit.i_imageId = 0; hit.i_angle = keypoints[i].angle / 360 * (1 << 16); hit.x = keypoints[i].pt.x; hit.y = keypoints[i].pt.y; imageReqHits[i_wordId].push_back(hit); } } } cout << imageReqHits.size() << " visual words kept for the request." << endl; const unsigned i_nbTotalIndexedImages = index->getTotalNbIndexedImages(); cout << i_nbTotalIndexedImages << " images indexed in the index." << endl; unordered_map<u_int32_t, vector<Hit> > indexHits; // key: visual word id, values: index hits. index->getImagesWithVisualWords(imageReqHits, indexHits); gettimeofday(&t[2], NULL); cout << "time: " << getTimeDiff(t[1], t[2]) << " ms." << endl; cout << "Ranking the images." << endl; unordered_map<u_int32_t, float> weights; // key: image id, value: image score. for (unordered_map<u_int32_t, vector<Hit> >::const_iterator it = indexHits.begin(); it != indexHits.end(); ++it) { const vector<Hit> &hits = it->second; const float f_weight = log((float)i_nbTotalIndexedImages / hits.size()); for (vector<Hit>::const_iterator it2 = hits.begin(); it2 != hits.end(); ++it2) { /* TF-IDF according to the paper "Video Google: * A Text Retrieval Approach to Object Matching in Videos" */ unsigned i_totalNbWords = index->countTotalNbWord(it2->i_imageId); weights[it2->i_imageId] += f_weight / i_totalNbWords; } } priority_queue<SearchResult> rankedResults; for (tr1::unordered_map<unsigned, float>::const_iterator it = weights.begin(); it != weights.end(); ++it) rankedResults.push(SearchResult(it->second, it->first)); gettimeofday(&t[3], NULL); cout << "time: " << getTimeDiff(t[2], t[3]) << " ms." << endl; cout << "Reranking 300 among " << rankedResults.size() << " images." << endl; priority_queue<SearchResult> rerankedResults; reranker.rerank(imageReqHits, indexHits, rankedResults, rerankedResults, 300); gettimeofday(&t[4], NULL); cout << "time: " << getTimeDiff(t[3], t[4]) << " ms." << endl; cout << "Returning the results. " << endl; returnResults(rerankedResults, request, 100); #if 0 // Draw keypoints and ellipses. Mat img_res; drawKeypoints(img, cleanKeypoints, img_res, Scalar::all(-1), DrawMatchesFlags::DEFAULT); for (unsigned i = 0; i < ellipses.size(); ++i) ellipse( img_res, ellipses[i], Scalar(0, 0, 255), 1); // Show the image. imshow("Keypoints 1", img_res); #endif return SEARCH_RESULTS; }
void plot(char *flags) { int i, j, k; char *t; int32_t x, y; int ra, dec; int m; Point p, pts[10]; Record *r; Rectangle rect, r1; int dx, dy, nogrid, textlevel, nogrey, zenithup; Image *scr; char *name, buf[32]; double v; if(plotopen() < 0) return; nogrid = 0; nogrey = 0; textlevel = 1; dx = 512; dy = 512; zenithup = 0; for(;;){ if(t = alpha(flags, "nogrid")){ nogrid = 1; flags = t; continue; } if((t = alpha(flags, "zenith")) || (t = alpha(flags, "zenithup")) ){ zenithup = 1; flags = t; continue; } if((t = alpha(flags, "notext")) || (t = alpha(flags, "nolabel")) ){ textlevel = 0; flags = t; continue; } if((t = alpha(flags, "alltext")) || (t = alpha(flags, "alllabel")) ){ textlevel = 2; flags = t; continue; } if(t = alpha(flags, "dx")){ dx = strtol(t, &t, 0); if(dx < 100){ fprint(2, "dx %d too small (min 100) in plot\n", dx); return; } flags = skipbl(t); continue; } if(t = alpha(flags, "dy")){ dy = strtol(t, &t, 0); if(dy < 100){ fprint(2, "dy %d too small (min 100) in plot\n", dy); return; } flags = skipbl(t); continue; } if((t = alpha(flags, "nogrey")) || (t = alpha(flags, "nogray"))){ nogrey = 1; flags = skipbl(t); continue; } if(*flags){ fprint(2, "syntax error in plot\n"); return; } break; } flatten(); folded = 0; if(bbox(0, 0, 1) < 0) return; if(ramax-ramin<100 || decmax-decmin<100){ fprint(2, "plot too small\n"); return; } scr = allocimage(display, Rect(0, 0, dx, dy), RGB24, 0, DBlack); if(scr == nil){ fprint(2, "can't allocate image: %r\n"); return; } rect = scr->r; rect.min.x += 16; rect = insetrect(rect, 40); if(setmap(ramin, ramax, decmin, decmax, rect, zenithup) < 0){ fprint(2, "can't set up map coordinates\n"); return; } if(!nogrid){ for(x=ramin; ; ){ for(j=0; j<nelem(pts); j++){ /* use double to avoid overflow */ v = (double)j / (double)(nelem(pts)-1); v = decmin + v*(decmax-decmin); pts[j] = map(x, v); } bezspline(scr, pts, nelem(pts), Endsquare, Endsquare, 0, GREY, ZP); ra = x; if(folded){ ra -= 180*c; if(ra < 0) ra += 360*c; } p = pts[0]; p.x -= stringwidth(font, hm5(angle(ra)))/2; string(scr, p, GREY, ZP, font, hm5(angle(ra))); p = pts[nelem(pts)-1]; p.x -= stringwidth(font, hm5(angle(ra)))/2; p.y -= font->height; string(scr, p, GREY, ZP, font, hm5(angle(ra))); if(x == ramax) break; x += gridra(mapdec); if(x > ramax) x = ramax; } for(y=decmin; y<=decmax; y+=c){ for(j=0; j<nelem(pts); j++){ /* use double to avoid overflow */ v = (double)j / (double)(nelem(pts)-1); v = ramin + v*(ramax-ramin); pts[j] = map(v, y); } bezspline(scr, pts, nelem(pts), Endsquare, Endsquare, 0, GREY, ZP); p = pts[0]; p.x += 3; p.y -= font->height/2; string(scr, p, GREY, ZP, font, deg(angle(y))); p = pts[nelem(pts)-1]; p.x -= 3+stringwidth(font, deg(angle(y))); p.y -= font->height/2; string(scr, p, GREY, ZP, font, deg(angle(y))); } } /* reorder to get planets in front of stars */ tolast(nil); tolast("moon"); /* moon is in front of everything... */ tolast("shadow"); /* ... except the shadow */ for(i=0,r=rec; i<nrec; i++,r++){ dec = r->ngc.dec; ra = r->ngc.ra; if(folded){ ra -= 180*c; if(ra < 0) ra += 360*c; } if(textlevel){ name = nameof(r); if(name==nil && textlevel>1 && r->type==SAO){ snprint(buf, sizeof buf, "SAO%ld", r->index); name = buf; } if(name) drawname(scr, nogrey? display->white : alphagrey, name, ra, dec); } if(r->type == Planet){ drawplanet(scr, &r->planet, map(ra, dec)); continue; } if(r->type == SAO){ m = r->sao.mag; if(m == UNKNOWNMAG) m = r->sao.mpg; if(m == UNKNOWNMAG) continue; m = dsize(m); if(m < 3) fillellipse(scr, map(ra, dec), m, m, nogrey? display->white : lightgrey, ZP); else{ ellipse(scr, map(ra, dec), m+1, m+1, 0, display->black, ZP); fillellipse(scr, map(ra, dec), m, m, display->white, ZP); } continue; } if(r->type == Abell){ ellipse(scr, addpt(map(ra, dec), Pt(-3, 2)), 2, 1, 0, lightblue, ZP); ellipse(scr, addpt(map(ra, dec), Pt(3, 2)), 2, 1, 0, lightblue, ZP); ellipse(scr, addpt(map(ra, dec), Pt(0, -2)), 1, 2, 0, lightblue, ZP); continue; } switch(r->ngc.type){ case Galaxy: j = npixels(r->ngc.diam); if(j < 4) j = 4; if(j > 10) k = j/3; else k = j/2; ellipse(scr, map(ra, dec), j, k, 0, lightblue, ZP); break; case PlanetaryN: p = map(ra, dec); j = npixels(r->ngc.diam); if(j < 3) j = 3; ellipse(scr, p, j, j, 0, green, ZP); line(scr, Pt(p.x, p.y+j+1), Pt(p.x, p.y+j+4), Endsquare, Endsquare, 0, green, ZP); line(scr, Pt(p.x, p.y-(j+1)), Pt(p.x, p.y-(j+4)), Endsquare, Endsquare, 0, green, ZP); line(scr, Pt(p.x+j+1, p.y), Pt(p.x+j+4, p.y), Endsquare, Endsquare, 0, green, ZP); line(scr, Pt(p.x-(j+1), p.y), Pt(p.x-(j+4), p.y), Endsquare, Endsquare, 0, green, ZP); break; case DiffuseN: case NebularCl: p = map(ra, dec); j = npixels(r->ngc.diam); if(j < 4) j = 4; r1.min = Pt(p.x-j, p.y-j); r1.max = Pt(p.x+j, p.y+j); if(r->ngc.type != DiffuseN) draw(scr, r1, ocstipple, ocstipple, ZP); line(scr, Pt(p.x-j, p.y-j), Pt(p.x+j, p.y-j), Endsquare, Endsquare, 0, green, ZP); line(scr, Pt(p.x-j, p.y+j), Pt(p.x+j, p.y+j), Endsquare, Endsquare, 0, green, ZP); line(scr, Pt(p.x-j, p.y-j), Pt(p.x-j, p.y+j), Endsquare, Endsquare, 0, green, ZP); line(scr, Pt(p.x+j, p.y-j), Pt(p.x+j, p.y+j), Endsquare, Endsquare, 0, green, ZP); break; case OpenCl: p = map(ra, dec); j = npixels(r->ngc.diam); if(j < 4) j = 4; fillellipse(scr, p, j, j, ocstipple, ZP); break; case GlobularCl: j = npixels(r->ngc.diam); if(j < 4) j = 4; p = map(ra, dec); ellipse(scr, p, j, j, 0, lightgrey, ZP); line(scr, Pt(p.x-(j-1), p.y), Pt(p.x+j, p.y), Endsquare, Endsquare, 0, lightgrey, ZP); line(scr, Pt(p.x, p.y-(j-1)), Pt(p.x, p.y+j), Endsquare, Endsquare, 0, lightgrey, ZP); break; } } flushimage(display, 1); displayimage(scr); }
void main() { char a; float x=10,y,x1,y1,n=1.0; int m=3; int max=0,k; int count=1,score=0; char l[33],r[33]; FILE *f; char *o="Lives "; char *q="Score"; int gd=DETECT,gm,b; clrscr(); initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(GREEN); while(!kbhit()) { setcolor(BLUE); settextstyle(7,HORIZ_DIR,6); outtextxy(120,180,"CATCH THE EGG"); setcolor(WHITE); settextstyle(7,HORIZ_DIR,1); outtextxy(180,250,"PRESS ANY KEY TO START"); settextstyle(8,HORIZ_DIR,1); outtextxy(440,390,"C Project By"); outtextxy(440,410,"Abhinav"); outtextxy(440,430,"Nikhil"); outtextxy(440,450,"Nitish"); settextstyle(1,HORIZ_DIR,1); setcolor(WHITE); outtextxy(30,395,"Press Z to move left"); outtextxy(30,415,"Press M to move right"); outtextxy(30,435,"Press Q to QUIT"); delay(150); setcolor(BLACK); settextstyle(7,HORIZ_DIR,1); outtextxy(180,250,"PRESS ANY KEY TO START"); delay(150); } cleardevice(); setbkcolor(BLACK); y=440.0; while(a!='q'&& m!=-1) { sprintf(l,"%s %d",o,m); sprintf(r,"%s %d",q,score); x1=rand() % 400 + 10; y1=10; cleardevice(); while(y1<440 && a!='q') { setcolor(WHITE); settextstyle(9,HORIZ_DIR,1); outtextxy(450,20,l); outtextxy(450,50,r); setcolor(RED); setfillstyle(1,YELLOW); rectangle(x,y,x+20,y+15); floodfill(x+1,y+1,RED); b=getpixel(x+50,y+50); setcolor(WHITE); setfillstyle(1,WHITE); ellipse(x1,y1,0,360,4,15); floodfill(x1,y1,WHITE); setfillstyle(SOLID_FILL,b); setcolor(b); if(kbhit()) { a=getch(); if(a=='q')break; rectangle(x,y,x+20,y+15); floodfill(x+1,y+1,b); if(a=='m') if(x<getmaxx()) x+=15.0; else x=0; if(a=='z') if(x>0) x-=15.0; else x=getmaxx(); } setcolor(BLACK); setfillstyle(1,BLACK); ellipse(x1,y1,0,360,4,15); delay(5); floodfill(x1,y1,BLACK); if(y1-440>-5) { if(x1-x<30 && x1-x>-10) { setcolor(YELLOW); setfillstyle(1,YELLOW); ellipse(x1,y1,0,360,4,15); floodfill(x1,y1,YELLOW); setcolor(BLACK); setfillstyle(1,BLACK); ellipse(x1,y1,0,360,4,15); delay(200); floodfill(x1,y1,BLACK); score+=3; break; } else m--; break; } y1=y1+n; } if(count%4==0) { n+=0.2; } count++; } if(m==-1) { cleardevice(); setcolor(RED); settextstyle(6,HORIZ_DIR,6); outtextxy(220,200,"GAME OVER"); f=fopen("high.txt","a+"); putw(score,f); rewind(f); while(k!=EOF) { k=getw(f); if(k>max) max=k; } fclose(f); settextstyle(6,HORIZ_DIR,1); setcolor(WHITE); sprintf(r," Your Score %d",score); outtextxy(250,290,r); sprintf(r," High Score %d",max); outtextxy(250,330,r); delay(2000); } closegraph(); }
/*********************** husband's face *************************/ void husFace(int i) { //int gd=DETECT,gm; //initgraph(&gdriver,&gmode,"c:\Turboc3\bgi"); setcolor(GREEN); //setbkcolor(0); /*-------------------CHIN------------------------*/ ellipse(298-i,244-i,160,380,60,80); /*----------------- HAIR ------------------------*/ arc(300-i,219-i,400,140,80); ellipse(355-i,190-i,270,438,10,28); arc(359-i,188-i,169,265,30); ellipse(288-i,190-i,180,360,40,20); ellipse(239-i,193-i,96,370,8,25); /*---------------Eye Brows-------------------------*/ /*arc(282-i,255-i,89,130,40); arc(278-i,259-i,80,120,40); //arc(314-i,255-i,405,92,40); //arc(319-i,259-i,420,100,40); line(310-i,215-i,310,220); line(284-i,215-i,284,219); */ /*-------------------Eyes--------------------------*/ setfillstyle(SOLID_FILL,WHITE); ellipse(320-i,230-i,0,360,10,5); ellipse(275-i,230-i,0,360,10,5); fillellipse(320-i,230-i,10,5); fillellipse(275-i,230-i,10,5); setfillstyle(SOLID_FILL,BLACK); ellipse(320-i,230-i,0,360,4,4); ellipse(275-i,230-i,0,360,4,4); fillellipse(320-i,230-i,5,5); fillellipse(275-i,230-i,5,5); /*------------------Nose----------------------*/ ellipse(280-i,220-i,270,0,10,40); ellipse(315-i,220-i,180,270,10,40); ellipse(285-i,260-i,100,285,8,7); ellipse(310-i,260-i,255,70,8,7); circle(320-i,230-i,2); circle(275-i,230-i,2); arc(297-i,257-i,228,689,15); /*---------------------MOUTH--------------------*/ ellipse(298-i,290-i,0,360,30,7); //line(270-i,290-i,326,290); /*----------------------Ears--------------------*/ ellipse(234-i,240-i,0,330,4,20); ellipse(362-i,240-i,220,170,4,20); //getch(); //clearviewport(); //closegraph(); //restorecrtmode(); }
void menu() { clrscr(); setgraph(); setbkcolor(1); for(int i=0;i<635;i+=20) { setcolor(2); setfillstyle(1,2); circle(12+i,10,10); floodfill(12+i,10,2); } for(i=0;i<635;i+=20) { setcolor(2); setfillstyle(1,2); circle(12+i,468,10); floodfill(12+i,468,2); } settextstyle(8,0,3); for(i=420;i>30;i-=3) { setcolor(random(15)); outtextxy(230,i,"SeLeCtIoN MeNu"); delay(40); setcolor(1); outtextxy(230,i,"SeLeCtIoN MeNu"); } setcolor(14); outtextxy(230,30,"SeLeCtIoN MeNu"); line(220,60,440,60); for(i=0;i<200;i+=3) { setcolor(i); settextstyle(7,0,2); outtextxy(i,110," 1. NEW GAME"); outtextxy(i,160," 2. INSTRUCTIONS"); outtextxy(i,210," 3. EXIT"); delay(40); setcolor(1); outtextxy(i,110," 1. NEW GAME"); outtextxy(i,160," 2. INSTRUCTIONS"); outtextxy(i,210," 3. EXIT"); } int v; for(int h=0;;) { for(int i=0;i<635;i+=20) { setcolor(2); setfillstyle(1,2); circle(12+i,10,10); floodfill(12+i,10,2); } for(i=0;i<635;i+=20) { setcolor(2); setfillstyle(1,2); circle(12+i,468,10); floodfill(12+i,468,2); } i=200; setcolor(15); ellipse(310,180,0,360,140,100); setfillstyle(1,4); floodfill(310,180,15); setcolor(15); settextstyle(7,0,2); outtextxy(i,110," 1. NEW GAME"); outtextxy(i,160," 2. INSTRUCTIONS"); outtextxy(i,210," 3. EXIT"); setcolor(14); setfillstyle(1,14); circle(180,350,10); floodfill(180,350,14); setcolor(10); setfillstyle(1,10); circle(130,200,20); floodfill(130,200,10); setcolor(6); setfillstyle(1,6); circle(600,300,15); floodfill(600,300,6); setcolor(13); setfillstyle(1,13); circle(30,330,15); floodfill(30,330,13); setcolor(12); setfillstyle(1,12); circle(460,350,15); floodfill(460,350,12); setcolor(13); setfillstyle(1,13); circle(480,220,20); floodfill(480,220,13); setcolor(12); setfillstyle(1,12); circle(50,80,10); floodfill(50,80,12); setcolor(14); setfillstyle(1,14); circle(590,80,10); floodfill(590,80,14); if(h==300) v=1; else if(h==0) v=0; if(v==1) h-=10; else if(v==0) h+=10; setcolor(15); settextstyle(8,0,2); outtextxy(h,400,"Enter Your Choice (1,2 or 3)"); delay(150); setcolor(1); settextstyle(8,0,2); outtextxy(h,400,"Enter Your Choice (1,2 or 3)"); if(kbhit()) { char c=getch(); if(c=='1') { setcolor(4); rectangle(205,320,440,420); setcolor(14); rectangle(206,321,439,419); setcolor(15); settextstyle(2,0,6); outtextxy(210,340," 1. USER vs COMPUTER"); outtextxy(210,370," 2.PLAYER 1 vs PLAYER 2"); p= getch(); closegraph(); game(); } else if(c=='2') instructions(); else exit(0); } settextstyle(8,0,3); setcolor(14); outtextxy(230,30,"SeLeCtIoN MeNu"); line(220,60,440,60); } }
void Spot::display() { ellipse(x, y, radius*2, radius*2); }
int ImagingDrawArc(Imaging im, int x0, int y0, int x1, int y1, float start, float end, const void* ink, int op) { return ellipse(im, x0, y0, x1, y1, start, end, ink, 0, ARC, op); }
void main() { char c,ch,ch1; FILE *ssa; int gdriver=DETECT,gmode,errorcode,x,y; initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi"); setbkcolor(18); for(int k=0;k<25;k++) { setcolor(3); delay(40); ellipse(320,240,0,360,200+k,50); } settextstyle(GOTHIC_FONT,0,5); outtextxy(170,210,"MINESWEEPER"); getch(); setcolor(15); print:clearviewport(); settextstyle(TRIPLEX_FONT,0,2); setcolor(3); rectangle(80,130,570,240); rectangle(85,135,565,235); outtextxy(100,140," BEGINNER LEVEL1: 9X9 GRID 10 MINES"); outtextxy(100,170,"INTERMEDIATE LEVEL2:10X10 GRID 16 MINES"); outtextxy(100,200," ADVANCED LEVEL3:13X13 GRID 30 MINES"); settextstyle(DEFAULT_FONT,0,1); outtextxy(250,250,"ENTER THE LEVEL:"); outtextxy(100,380,"PRESS ESCAPE TO QUIT"); outtextxy(100,410,"PRESS F1 FOR HELP"); outtextxy(100,440,"PRESS F2 FOR CONTROLS"); c=getche(); clearviewport(); if (c=='1') { x=minx=140;y=miny=120;mines=flag1=10;grid=9; } else if(c=='2') { x=minx=120;y=miny=110;flag1=mines=16;grid=10; } else if(c=='3') { x=minx=60;y=miny=70;mines=flag1=30;grid=13; } else if(c==27) exit(1); else if(c==';'||c=='<') { clearviewport(); if(c==';') ssa=fopen("c:\\turboc3\\sp.txt","r"); if(c=='<') ssa=fopen("c:\\turboc3\\sp1.txt","r"); while((ch1=fgetc(ssa))!= EOF) printf("%c",ch1); printf("\nPRESS ANY KEY TO EXIT"); getch(); rewind(ssa); goto print; } else goto print; maxx=minx+(grid-1)*40; maxy=miny+(grid-1)*30; setbkcolor(15); setcolor(8);//box colour for(int i=0;i<grid;i++) for(int j=0;j<grid;j++) { rectangle(minx+i*40,miny+j*30,minx+(i+1)*40,miny+(j+1)*30); setfillstyle(SOLID_FILL,15); bar(minx+5+i*40,miny+5+j*30,minx+35+i*40,miny+25+j*30); rectangle(minx+5+i*40,miny+5+j*30,minx+35+i*40,miny+25+j*30); } settextstyle(TRIPLEX_FONT,0,5); setcolor(3); outtextxy(190,10,"MINESWEEPER"); settextstyle(DEFAULT_FONT,0,1); minegen(); do { ch=getche(); setcolor(8); //resets box colorto frame color if(ch=='f'||ch=='F') { setcolor(1); flag(x,y); } if(ch=='s'||ch=='S') { setcolor(4); open(x,y); } if(ch==27) exit(1); if((x==minx&&ch==75)||(y==maxy&&ch==80)||(x==maxx&&ch==77)||(y==miny&&ch==72)) setcolor(4); else rectangle(x+5,y+5,x+35,y+25); switch(ch) { case 72:if(y>miny) y=y-30; break; case 80:if(y<maxy) y=y+30; break; case 75:if(x>minx) x=x-40; break; case 77:if(x<maxx) x=x+40; break; } setcolor(4); rectangle(x+5,y+5,x+35,y+25); }while(1); }
int ImagingDrawChord(Imaging im, int x0, int y0, int x1, int y1, float start, float end, const void* ink, int fill, int op) { return ellipse(im, x0, y0, x1, y1, start, end, ink, fill, CHORD, op); }
//---------------------------------------------------------- void ofPath::ellipse(const glm::vec2 & p, float width, float height){ ellipse(p.x,p.y,0.0,width,height); }
int ImagingDrawEllipse(Imaging im, int x0, int y0, int x1, int y1, const void* ink, int fill, int op) { return ellipse(im, x0, y0, x1, y1, 0, 360, ink, fill, CHORD, op); }
// Custom method for drawing the object void Module::draw() { fill(255); ellipse(xOffset + x, yOffset + y, 6, 6); }
int ImagingDrawPieslice(Imaging im, int x0, int y0, int x1, int y1, float start, float end, const void* ink, int fill, int op) { return ellipse(im, x0, y0, x1, y1, start, end, ink, fill, PIESLICE, op); }
Flux_Pts ell_fill(Pt2dr c,REAL A,REAL B,REAL teta,bool front) { return new Flux_To_Surf_Not_Comp(ellipse(c,A,B,teta),front) ; }
void contourZ() { RooPlot* frame=new RooPlot(-1.,1.,0.,1.); // lookup the 2x2 covariance matrix elements for these variables //format: //RooEllipse *data = ellipse(frame,x1,x2,s1,s2,rho,"MEVH"); // Double_t x1= ;//par1->getVal(); // Double_t x2= ;//par2->getVal(); // Double_t s1= ;//par1->getError(); // Double_t s2= ;//par2->getError(); // Double_t rho= ;//correlation(parName1, parName2); // user recoroutines rew8 RooEllipse *dataCorr0_mcCorr0 = ellipse(frame,2.5843e-02,2.9928e-01,4.94e-02,6.84e-02,-0.04601,kMagenta); RooEllipse *dataCorr0_mcCorr1 = ellipse(frame,2.6015e-02,2.8708e-01,5.36e-02,8.32e-03,1,kMagenta+1); RooEllipse *dataCorr0_mcCorr2 = ellipse(frame,2.4431e-02,2.8670e-01,4.96e-02,6.83e-02,-0.04208,kMagenta+2); RooEllipse *dataCorr1_mcCorr1= ellipse(frame,-3.9355e-02,3.1596e-01,4.95e-02,6.89e-02,-0.03861,kMagenta-1); RooEllipse *dataCorr1_mcCorr2 = ellipse(frame,-4.1982e-02,3.0285e-01,4.96e-02,6.89e-02,-0.03564,kMagenta-2); // use genroutines rew9MC RooEllipse *markerMCGenLevAnalyticalCorr0= ellipse(frame,0.0429,0.2109,0.0064,0.0081,-0.0153,kGreen); RooEllipse *markerMCGenLevTemplatesCorr0 = ellipse(frame,3.5601e-02,2.1139e-01,2.84e-02,3.65e-02,-0.01906,kBlue); RooEllipse *markerMCGenLevAcceptanceTemplatesCorr0 = ellipse(frame,3.7072e-02,2.1021e-01,4.55e-02,6.04e-02,-0.0432,kGreen); RooEllipse *markerMCGenLevAnalyticalCorr1= ellipse(frame,0.0411548,0.21129,0.0170367,0.0216702,-0.026834,kGreen+1); RooEllipse *markerMCGenLevTemplatesCorr1 = ellipse(frame,3.5596e-02,2.1138e-01,2.84e-02,3.65e-02,-0.02005,kBlue+1); RooEllipse *markerMCGenLevAnalyticalCorr2= ellipse(frame,0.0433825,0.215755,0.0170178,0.0216462,-0.029015,kGreen+2); RooEllipse *markerMCGenLevTemplatesCorr2 = ellipse(frame,3.5595e-02,2.1138e-01,2.84e-02,3.65e-02,-0.01848,kBlue+2); // use recoroutines rew8 RooEllipse *markerMCRecoLevCorr0 = ellipse(frame,3.3757e-02,2.1184e-01,5.56e-02,7.42e-02,-0.03722,kRed); RooEllipse *markerMCRecoLevCorr1 = ellipse(frame,3.3989e-02,2.0861e-01,5.56e-02,7.43e-02,-0.03822,kRed+1); RooEllipse *markerMCRecoLevCorr2 = ellipse(frame,3.3716e-02,2.1108e-01,5.58e-02,7.45e-02,-0.0353,kRed+2); gROOT->SetStyle("Plain"); gStyle->SetOptTitle(0); gStyle->SetOptStat(0); TCanvas *c= new TCanvas("c","",600,600); frame->Draw(); frame->GetXaxis()->SetTitle("f_{L}-f_{R}"); frame->GetYaxis()->SetTitle("f_{0}"); frame->SetAxisRange(-0.1,0.1,"X"); frame->SetAxisRange(0.12,0.4,"Y"); TLegend* leg = new TLegend(0.1, 0.7, 0.5, 0.9); leg->AddEntry(dataCorr0_mcCorr0,"fit to 2010 data corr0 with MC reco templates corr0","l"); leg->AddEntry(dataCorr0_mcCorr1,"fit to 2010 data corr0 with MC reco templates corr1","l"); leg->AddEntry(dataCorr0_mcCorr1,"fit to 2010 data corr0 with MC reco templates corr2","l"); leg->AddEntry(dataCorr1_mcCorr1,"fit to 2010 data corr1 with MC reco templates corr1","l"); leg->AddEntry(dataCorr1_mcCorr2,"fit to 2010 data corr1 with MC reco templates corr2","l"); leg->AddEntry(markerMCGenLevAnalyticalCorr0,"gen level corr0, analytical fit, full stats","l"); leg->AddEntry(markerMCGenLevAnalyticalCorr1,"gen level corr1, analytical fit, full stats","l"); leg->AddEntry(markerMCGenLevAnalyticalCorr2,"gen level corr2, analytical fit, full stats","l"); leg->AddEntry(markerMCGenLevTemplatesCorr0,"gen level corr0, template fit, scaled 36/pb","l"); leg->AddEntry(markerMCGenLevTemplatesCorr1,"gen level corr1, template fit, scaled 36/pb","l"); leg->AddEntry(markerMCGenLevTemplatesCorr2,"gen level corr2, template fit, scaled 36/pb","l"); leg->AddEntry(markerMCGenLevAcceptanceTemplatesCorr0,"gen level, template fit with acceptance, scaled 36/pb","l"); leg->AddEntry(markerMCRecoLevCorr0,"reco level corr0, MC template fit, scaled 36/pb","l"); leg->AddEntry(markerMCRecoLevCorr1,"reco level corr1, MC template fit, scaled 36/pb","l"); leg->AddEntry(markerMCRecoLevCorr2,"reco level corr2, MC template fit, scaled 36/pb","l"); leg->Draw(); c->Update(); //contour2->Draw("SAME"); TCanvas *c2 = new TCanvas("2011_4_1","2011_4_1",600,600); RooPlot* frame2=new RooPlot(-1.,1.,0.,1.); RooEllipse *data41Corr = ellipse(frame2,2.9773e-02,2.2361e-01,1.88e-02,2.53e-02,-0.03088,kMagenta); RooEllipse *data41onlyMCCorr = ellipse(frame2,0.0371439,0.217617,0.018751,0.0252248,-0.03386,kMagenta+2); RooEllipse *MCRecoLevCorr = ellipse(frame2,3.4895e-02,2.0779e-01,2.20e-02,2.93e-02,-0.0491,kRed); RooEllipse *MCRecoLev = ellipse(frame2,0.0376024,0.229521,0.0187051,0.0252698,-0.03753,kRed+2); RooEllipse *MCGenLevAnalytical= ellipse(frame2,0.0332975,0.216766,0.00598647,0.00763462,-0.021725,kGreen); frame2->Draw(); frame2->GetXaxis()->SetTitle("f_{L}-f_{R}"); frame2->GetYaxis()->SetTitle("f_{0}"); frame2->SetAxisRange(-0.1,0.1,"X"); frame2->SetAxisRange(0.12,0.4,"Y"); TLegend* leg2 = new TLegend(0.1, 0.7, 0.5, 0.9); leg2->AddEntry(data41Corr,"fit to 2011 data up to 163817 corr with MC reco templates corr","l"); leg2->AddEntry(data41onlyMCCorr,"fit to 2011 data up to 163817 with MC reco templates corr","l"); leg2->AddEntry(MCRecoLevCorr,"mc reco level corr, MC template fit, scaled 240/pb","l"); leg2->AddEntry(MCRecoLev,"mc reco level, MC template fit, scaled 240/pb","l"); leg2->AddEntry(MCGenLevAnalytical,"mc gen level, analytical fit","l"); leg2->Draw(); c2->Update(); }
// Custom method for drawing the object void display() { fill(255); ellipse(xOffset + x, yOffset + y, 6, 6); }
GraphicWindow& GraphicWindow::operator<<(Circle c) { ellipse(c.get_center().get_x(), c.get_center().get_y(), c.get_radius(), c.get_radius()); return *this; }