fork download
  1. class Line
  2. {
  3. private:
  4. int x1, x2, y1, y2, algoID;
  5.  
  6. public :
  7. Line()
  8. {
  9.  
  10. }
  11. Line(int algoID,int x1, int x2, int y1, int y2)
  12. {
  13. this->algoID = algoID ;
  14. this->x1 = x1 ;
  15. this->x2 = x2 ;
  16. this->y1 = y1 ;
  17. this->y2 = y2 ;
  18. }
  19. int getX1()
  20. {
  21. return x1 ;
  22. }
  23. int getX2()
  24. {
  25. return x2 ;
  26. }
  27. int getY1()
  28. {
  29. return y1 ;
  30. }
  31. int getY2()
  32. {
  33. return y2 ;
  34. }
  35. int getM()
  36. {
  37. return algoID ;
  38. }
  39.  
  40. };
  41. class elipse
  42. {
  43. private:
  44. int xc , yc, a, b, algoID ;
  45. public :
  46. elipse()
  47. {
  48.  
  49. }
  50. elipse(int algoID,int xc, int x, int yc, int y)
  51. {
  52. this->algoID = algoID ;
  53. this->xc = xc ;
  54. this->a = x ;
  55. this->yc = yc ;
  56. this->b = y ;
  57. }
  58. int getXc()
  59. {
  60. return xc ;
  61. }
  62. int getA()
  63. {
  64. return a ;
  65. }
  66. int getYc()
  67. {
  68. return yc ;
  69. }
  70. int getB()
  71. {
  72. return b ;
  73. }
  74. int getM()
  75. {
  76. return algoID ;
  77. }
  78.  
  79. };
  80. class Circle
  81. {
  82. private:
  83. int xc , yc, x, y, algoID ;
  84. public:
  85. Circle()
  86. {
  87.  
  88. }
  89. Circle(int algoID,int xc, int x, int yc, int y)
  90. {
  91. this->algoID = algoID ;
  92. this->xc = xc ;
  93. this->x = x ;
  94. this->yc = yc ;
  95. this->y = y ;
  96. }
  97. int getXc()
  98. {
  99. return xc ;
  100. }
  101. int getX()
  102. {
  103. return x ;
  104. }
  105. int getYc()
  106. {
  107. return yc ;
  108. }
  109. int getY()
  110. {
  111. return y ;
  112. }
  113. int getM()
  114. {
  115. return algoID ;
  116. }
  117. };
  118. ///////////////////////////////////////////////////////////
  119. /* Declare Windows procedure */
  120. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  121.  
  122. /* Make the class name into a global variable */
  123. TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");
  124.  
  125. void swap (int &x1 , int &x2 , int &y1 , int &y2)
  126. {
  127. int temp = x1;
  128. x1 = x2;
  129. x2 = temp;
  130.  
  131. temp = y1;
  132. y1 = y2;
  133. y2 = temp;
  134. }
  135. void draw4Points(HDC hdc,int xc , int yc , int x , int y, COLORREF color )
  136. {
  137. SetPixel(hdc , xc + x , yc + y , color);
  138. SetPixel(hdc , xc - x , yc - y , color);
  139. SetPixel(hdc , xc + x , yc - y , color);
  140. SetPixel(hdc , xc - x , yc + y , color);
  141.  
  142. }
  143. void draw8Points(HDC hdc,int xc , int yc , int x , int y, COLORREF color )
  144. {
  145.  
  146. SetPixel(hdc , xc + x , yc + y , color);
  147. SetPixel(hdc , xc - x , yc - y , color);
  148. SetPixel(hdc , xc + x , yc - y , color);
  149. SetPixel(hdc , xc - x , yc + y , color);
  150. SetPixel(hdc , xc + y , yc + x , color);
  151. SetPixel(hdc , xc - y , yc - x , color);
  152. SetPixel(hdc , xc - y , yc + x , color);
  153. SetPixel(hdc , xc + y , yc - x , color);
  154. }
  155. void drawElipseCartesian(HDC hdc, int xc, int yc, int a, int b)
  156. {
  157. int x = 0 , y= b ;
  158. COLORREF color=RGB(255,80,0);
  159. draw4Points(hdc,xc,yc,x,y,color);
  160. while (x*b*b<=y*a*a)
  161. {
  162. x++;
  163. y=b*sqrt(1-((x*x)/(a*a)));
  164. draw4Points(hdc,xc,yc,x,y, color);
  165. }
  166. x=a , y =0 ;
  167. draw4Points(hdc,xc,yc,x,y, color);
  168. while (y*a*a<=x*b*b)
  169. {
  170. y++;
  171. x=a*sqrt(1-((y*y)/(b*b)));
  172. draw4Points(hdc,xc,yc,x,y, color);
  173. }
  174.  
  175. }
  176. void drawCircleDirect(HDC hdc, int xc, int yc, int x, int y)
  177. {
  178. COLORREF color=RGB(255,80,0);
  179. int R = sqrt((double)((x-xc)*(x-xc) + (y-yc)*(y-yc)));
  180. x = 0 ;
  181. y = R ;
  182. int R2 = R*R ;
  183. draw8Points(hdc, xc , yc , x , y , color);
  184. while(x < y)
  185. {
  186. x++ ;
  187. y = sqrt((double)(R2 - x*x));
  188. draw8Points(hdc, xc , yc , x , y , color);
  189. }
  190. }
  191.  
  192. void drawCirclePolar(HDC hdc, int xc, int yc, int xt, int yt)
  193. {
  194. COLORREF color=RGB(10,10,0);
  195. double x = xt , y = yt ;
  196. double r = sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc));
  197. x = r, y = 0;
  198. double dTh = 1.0/r;
  199. double cosdTh = cos(dTh);
  200. double sindTh = sin(dTh);
  201. draw8Points(hdc, xc , yc , x , y , color);
  202. while(x>y)
  203. {
  204. x = x*cosdTh - y*sindTh ;
  205. y = x*sindTh + y*cosdTh;
  206. draw8Points(hdc, xc , yc , x , y , color);
  207. }
  208. }
  209. void drawCircleParametric (HDC hdc, int xc, int yc, int x, int y)
  210. {
  211. COLORREF color=RGB(255,150,70);
  212. int r = sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc));
  213. x = r;
  214. y = 0;
  215. draw8Points(hdc, xc , yc , x , y , color);
  216.  
  217. double theta=0, dtheta=1.0/r;
  218. while (x>y)
  219. {
  220. theta += dtheta;
  221. x = round(r*cos(theta));
  222. y = round(r*sin(theta));
  223. draw8Points(hdc, xc , yc , x , y , color);
  224.  
  225. }
  226. }
  227. void drawCircleMidPoint (HDC hdc, int xc, int yc, int x, int y)
  228. {
  229. COLORREF color=RGB(10,10,200);
  230. int r = sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc));
  231. x = 0;
  232. y = r;
  233. draw8Points(hdc, xc , yc , x , y , color);
  234. int d = 1-r;
  235. while (x<y)
  236. {
  237. x++;
  238. if (d>=0)
  239. {
  240. y--;
  241. d+=( (2*(x-y)) +3 );
  242. }
  243. else
  244. {
  245. d+=( (2*(x)) +1 );
  246. }
  247. draw8Points(hdc, xc , yc , x , y , color);
  248. }
  249. }
  250. void drawlineCartesian(HDC hdc, int x1, int y1, int x2, int y2)
  251. {
  252. COLORREF color=RGB(255,255,0);
  253.  
  254. int dx = x2 - x1;
  255. int dy = y2 - y1;
  256. double m = (double)dy / (double)dx ; // slope
  257. double c = (y1 - (m*x1) ); // y-intercept
  258.  
  259. if ( abs(dx) >= abs (dy) ) // m<1
  260. {
  261. if (x2 < x1)
  262. {
  263. swap(x1 , x2 , y1 , y2);
  264. }
  265. SetPixel(hdc, x1, y1, color);
  266. double y = y1;
  267. while (x1 < x2)
  268. {
  269. x1++;
  270. y = ( (m*(double)x1) + c );
  271. SetPixel(hdc, x1, round(y), color);
  272. }
  273. }
  274. else if (abs(dx) < abs(dy)) // m>1
  275. {
  276. if (y2 < y1)
  277. {
  278. swap(x1 , x2 , y1 , y2);
  279. }
  280. SetPixel(hdc, x1, y1, color);
  281.  
  282. double x = x1;
  283. double d = ( x1 - ((1.0/m)*y1) );
  284.  
  285. while (y1 < y2)
  286. {
  287. y1++;
  288. x = ( ((1.0/m)*(double)y1) + d );
  289. SetPixel(hdc, round(x) , y1 , color);
  290. }
  291. }
  292. }
  293.  
  294. void drawlineDDA(HDC hdc, int x1, int y1, int x2, int y2)
  295. {
  296. COLORREF color=RGB(255,0,150);
  297.  
  298. int dx = x2 - x1;
  299. int dy = y2 - y1;
  300. double m; // slope
  301. double c = (y1 - (m*x1) ); // y-intercept
  302.  
  303. if ( abs(dx) >= abs (dy) ) // m<1
  304. {
  305. m = (double)dy / (double)dx ;
  306. if (x2 < x1)
  307. {
  308. swap(x1 , x2 , y1 , y2);
  309. }
  310. SetPixel(hdc, x1, y1, color);
  311. double y = y1;
  312. while (x1 < x2)
  313. {
  314. x1++;
  315. y += m;
  316. SetPixel(hdc, x1, round(y), color);
  317. }
  318. }
  319. else if (abs(dx) < abs(dy)) // m>1
  320. {
  321. m = (double)dx / (double)dy ;
  322. if (y2 < y1)
  323. {
  324. swap(x1 , x2 , y1 , y2);
  325. }
  326. SetPixel(hdc, x1, y1, color);
  327.  
  328. double x = x1;
  329. double d = ( x1 - (m*y1) );
  330.  
  331. while (y1 < y2)
  332. {
  333. y1++;
  334. x += m;
  335. SetPixel(hdc, round(x) , y1 , color);
  336. }
  337. }
  338. }
  339. void drawlineParametric(HDC hdc, int x1, int y1, int x2, int y2)
  340. {
  341. COLORREF color = RGB(0,0,0);
  342. int dx=x2-x1;
  343. int dy=y2-y1;
  344. int x=x1;
  345. int y=y1;
  346. float ro ;
  347.  
  348. if(dx > dy)
  349. ro = 1.0/dx ;
  350. else
  351. ro = 1.0 / dy ;
  352.  
  353. for (float i =0;i<1;i+=ro)
  354. {
  355.  
  356. x= x1 + int(i*dx);
  357. y= y1 + int(i*dy);
  358.  
  359. SetPixel(hdc,x,y,color);
  360. }
  361. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: illegal start of type
    private:
           ^
Main.java:3: error: ';' expected
    private:
            ^
Main.java:4: error: <identifier> expected
        int x1, x2, y1, y2, algoID;
              ^
Main.java:6: error: illegal start of type
    public :
           ^
Main.java:6: error: ';' expected
    public :
            ^
Main.java:7: error: illegal start of type
    Line()
        ^
Main.java:7: error: <identifier> expected
    Line()
         ^
Main.java:7: error: ';' expected
    Line()
          ^
Main.java:11: error: class, interface, or enum expected
    Line(int algoID,int x1, int x2, int y1, int y2)
    ^
Main.java:14: error: class, interface, or enum expected
        this->x1 = x1 ;
        ^
Main.java:15: error: class, interface, or enum expected
        this->x2 = x2 ;
        ^
Main.java:16: error: class, interface, or enum expected
        this->y1 = y1 ;
        ^
Main.java:17: error: class, interface, or enum expected
        this->y2 = y2 ;
        ^
Main.java:18: error: class, interface, or enum expected
    }
    ^
Main.java:22: error: class, interface, or enum expected
    }
    ^
Main.java:26: error: class, interface, or enum expected
    }
    ^
Main.java:30: error: class, interface, or enum expected
    }
    ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
Main.java:38: error: class, interface, or enum expected
    }
    ^
Main.java:43: error: illegal start of type
    private:
           ^
Main.java:43: error: ';' expected
    private:
            ^
Main.java:44: error: <identifier> expected
     int xc , yc, a, b, algoID ;
           ^
Main.java:45: error: illegal start of type
    public :
           ^
Main.java:45: error: ';' expected
    public :
            ^
Main.java:46: error: illegal start of type
        elipse()
              ^
Main.java:46: error: <identifier> expected
        elipse()
               ^
Main.java:46: error: ';' expected
        elipse()
                ^
Main.java:50: error: class, interface, or enum expected
        elipse(int algoID,int xc, int x, int yc, int y)
        ^
Main.java:53: error: class, interface, or enum expected
            this->xc = xc ;
            ^
Main.java:54: error: class, interface, or enum expected
            this->a = x ;
            ^
Main.java:55: error: class, interface, or enum expected
            this->yc = yc ;
            ^
Main.java:56: error: class, interface, or enum expected
            this->b = y ;
            ^
Main.java:57: error: class, interface, or enum expected
        }
        ^
Main.java:61: error: class, interface, or enum expected
        }
        ^
Main.java:65: error: class, interface, or enum expected
        }
        ^
Main.java:69: error: class, interface, or enum expected
        }
        ^
Main.java:73: error: class, interface, or enum expected
        }
        ^
Main.java:77: error: class, interface, or enum expected
        }
        ^
Main.java:82: error: illegal start of type
    private:
           ^
Main.java:82: error: ';' expected
    private:
            ^
Main.java:83: error: <identifier> expected
        int xc , yc, x, y, algoID ;
              ^
Main.java:84: error: illegal start of type
    public:
          ^
Main.java:84: error: ';' expected
    public:
           ^
Main.java:85: error: illegal start of type
        Circle()
              ^
Main.java:85: error: <identifier> expected
        Circle()
               ^
Main.java:85: error: ';' expected
        Circle()
                ^
Main.java:89: error: class, interface, or enum expected
        Circle(int algoID,int xc, int x, int yc, int y)
        ^
Main.java:92: error: class, interface, or enum expected
            this->xc = xc ;
            ^
Main.java:93: error: class, interface, or enum expected
            this->x = x ;
            ^
Main.java:94: error: class, interface, or enum expected
            this->yc = yc ;
            ^
Main.java:95: error: class, interface, or enum expected
            this->y = y ;
            ^
Main.java:96: error: class, interface, or enum expected
        }
        ^
Main.java:100: error: class, interface, or enum expected
        }
        ^
Main.java:104: error: class, interface, or enum expected
        }
        ^
Main.java:108: error: class, interface, or enum expected
        }
        ^
Main.java:112: error: class, interface, or enum expected
        }
        ^
Main.java:116: error: class, interface, or enum expected
        }
        ^
Main.java:120: error: class, interface, or enum expected
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
^
Main.java:123: error: class, interface, or enum expected
TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");
^
Main.java:125: error: class, interface, or enum expected
void swap (int &x1 , int &x2 , int &y1 , int &y2)
^
Main.java:128: error: class, interface, or enum expected
    x1 = x2;
    ^
Main.java:129: error: class, interface, or enum expected
    x2 = temp;
    ^
Main.java:131: error: class, interface, or enum expected
    temp = y1;
    ^
Main.java:132: error: class, interface, or enum expected
    y1 = y2;
    ^
Main.java:133: error: class, interface, or enum expected
    y2 = temp;
    ^
Main.java:134: error: class, interface, or enum expected
}
^
Main.java:138: error: class, interface, or enum expected
    SetPixel(hdc , xc - x , yc - y , color);
    ^
Main.java:139: error: class, interface, or enum expected
    SetPixel(hdc , xc + x , yc - y , color);
    ^
Main.java:140: error: class, interface, or enum expected
    SetPixel(hdc , xc - x , yc + y , color);
    ^
Main.java:142: error: class, interface, or enum expected
}
^
Main.java:147: error: class, interface, or enum expected
    SetPixel(hdc , xc - x , yc - y , color);
    ^
Main.java:148: error: class, interface, or enum expected
    SetPixel(hdc , xc + x , yc - y , color);
    ^
Main.java:149: error: class, interface, or enum expected
    SetPixel(hdc , xc - x , yc + y , color);
    ^
Main.java:150: error: class, interface, or enum expected
    SetPixel(hdc , xc + y , yc + x , color);
    ^
Main.java:151: error: class, interface, or enum expected
    SetPixel(hdc , xc - y , yc - x , color);
    ^
Main.java:152: error: class, interface, or enum expected
    SetPixel(hdc , xc - y , yc + x , color);
    ^
Main.java:153: error: class, interface, or enum expected
    SetPixel(hdc , xc + y , yc - x , color);
    ^
Main.java:154: error: class, interface, or enum expected
}
^
Main.java:158: error: class, interface, or enum expected
    COLORREF color=RGB(255,80,0);
    ^
Main.java:159: error: class, interface, or enum expected
    draw4Points(hdc,xc,yc,x,y,color);
    ^
Main.java:160: error: class, interface, or enum expected
    while (x*b*b<=y*a*a)
    ^
Main.java:163: error: class, interface, or enum expected
        y=b*sqrt(1-((x*x)/(a*a)));
        ^
Main.java:164: error: class, interface, or enum expected
        draw4Points(hdc,xc,yc,x,y, color);
        ^
Main.java:165: error: class, interface, or enum expected
    }
    ^
Main.java:167: error: class, interface, or enum expected
    draw4Points(hdc,xc,yc,x,y, color);
    ^
Main.java:168: error: class, interface, or enum expected
    while (y*a*a<=x*b*b)
    ^
Main.java:171: error: class, interface, or enum expected
        x=a*sqrt(1-((y*y)/(b*b)));
        ^
Main.java:172: error: class, interface, or enum expected
        draw4Points(hdc,xc,yc,x,y, color);
        ^
Main.java:173: error: class, interface, or enum expected
    }
    ^
Main.java:179: error: class, interface, or enum expected
    int R = sqrt((double)((x-xc)*(x-xc) + (y-yc)*(y-yc)));
    ^
Main.java:180: error: class, interface, or enum expected
    x = 0 ;
    ^
Main.java:181: error: class, interface, or enum expected
    y = R ;
    ^
Main.java:182: error: class, interface, or enum expected
    int R2 = R*R ;
    ^
Main.java:183: error: class, interface, or enum expected
    draw8Points(hdc, xc ,  yc ,  x ,  y , color);
    ^
Main.java:184: error: class, interface, or enum expected
    while(x < y)
    ^
Main.java:187: error: class, interface, or enum expected
        y = sqrt((double)(R2 - x*x));
        ^
Main.java:188: error: class, interface, or enum expected
        draw8Points(hdc, xc ,  yc ,  x ,  y , color);
        ^
Main.java:189: error: class, interface, or enum expected
    }
    ^
Main.java:195: error: class, interface, or enum expected
    double x = xt , y = yt ;
    ^
Main.java:196: error: class, interface, or enum expected
    double r = sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc));
    ^
100 errors
stdout
Standard output is empty