Facebook
From zidan, 2 Months ago, written in C++.
Embed
Download Paste or View Raw
Hits: 209
  1. #include "iGraphics.h"
  2. #include <iostream>
  3. #include<math.h>
  4. #include<string.h>
  5. using namespace std;
  6.  
  7. #define screenwidth 1400
  8. #define screenheight 700
  9.  
  10.  
  11. char promptMsg[][200]={"prompt//PENTOOL.bmp","prompt//ERASERTOOL.bmp","prompt//CIRCLETOOL.bmp"
  12.                         ,"prompt//RECTTOOL.bmp","prompt//LINETOOL.bmp","prompt//GRABTOOL.bmp"
  13.                         ,"prompt//SAVEMSG.bmp","prompt//NOTSAVEMSG.bmp","prompt//TEXTBOXTOOL.bmp"
  14.                         ,"prompt//LOADMSG.bmp","prompt//SAVEINS.bmp"};
  15.  
  16. char fontarray[][200]={"GLUT_BITMAP_9_BY_15","GLUT_BITMAP_8_BY_13",
  17.                        "GLUT_BITMAP_TIMES_ROMAN_10","GLUT_BITMAP_TIMES_ROMAN_24",
  18.                            "GLUT_BITMAP_HELVETICA_10","GLUT_BITMAP_HELVETICA_12",
  19.                                               "GLUT_BITMAP_HELVETICA_18"};
  20.  
  21.  
  22. char opening[200][200]={
  23.    "OPENING\\open (1).bmp",
  24.    "OPENING\\open (2).bmp",
  25.    "OPENING\\open (3).bmp",
  26.    "OPENING\\open (4).bmp",
  27.    "OPENING\\open (5).bmp",
  28.    "OPENING\\open (6).bmp",
  29.    "OPENING\\open (7).bmp",
  30.    "OPENING\\open (8).bmp",
  31.    "OPENING\\open (9).bmp",
  32.    "OPENING\\open (10).bmp",
  33.    "OPENING\\open (11).bmp",
  34.    "OPENING\\open (12).bmp",
  35.    "OPENING\\open (13).bmp",
  36.    "OPENING\\open (14).bmp",
  37.    "OPENING\\open (15).bmp",
  38.    "OPENING\\open (16).bmp",
  39.    "OPENING\\open (17).bmp",
  40.    "OPENING\\open (18).bmp",
  41.    "OPENING\\open (19).bmp",
  42.    "OPENING\\open (20).bmp",
  43.    "OPENING\\open (21).bmp",
  44.    "OPENING\\open (22).bmp",
  45.    "OPENING\\open (23).bmp",
  46.    "OPENING\\open (24).bmp",
  47.    "OPENING\\open (25).bmp",
  48.    "OPENING\\open (26).bmp",
  49.    "OPENING\\open (27).bmp",
  50.    "OPENING\\open (28).bmp",
  51.    "OPENING\\open (29).bmp",
  52.    "OPENING\\open (30).bmp",
  53.    "OPENING\\open (31).bmp",
  54.    "OPENING\\open (32).bmp",
  55.    "OPENING\\open (33).bmp",
  56.    "OPENING\\open (34).bmp",
  57.    "OPENING\\open (35).bmp",
  58.    "OPENING\\open (36).bmp",
  59.    "OPENING\\open (37).bmp",
  60.    "OPENING\\open (38).bmp",
  61.    "OPENING\\open (39).bmp",
  62.    "OPENING\\open (40).bmp",
  63.    "OPENING\\open (41).bmp",
  64.    "OPENING\\open (42).bmp",
  65.    "OPENING\\open (43).bmp",
  66.    "OPENING\\open (44).bmp",
  67.    "OPENING\\open (45).bmp",
  68.    "OPENING\\open (46).bmp",
  69.    "OPENING\\open (47).bmp",
  70.    "OPENING\\open (48).bmp",
  71.    "OPENING\\open (49).bmp",
  72.    "OPENING\\open (50).bmp",
  73.    "OPENING\\open (51).bmp",
  74.    "OPENING\\open (52).bmp",
  75.    "OPENING\\open (53).bmp",
  76.    "OPENING\\open (54).bmp",
  77.    "OPENING\\open (55).bmp",
  78.    "OPENING\\open (56).bmp",
  79.    "OPENING\\open (57).bmp",
  80.    "OPENING\\open (58).bmp",
  81.    "OPENING\\open (59).bmp",
  82.    "OPENING\\open (60).bmp",
  83.    "OPENING\\open (61).bmp",
  84.    "OPENING\\open (62).bmp",
  85.    "OPENING\\open (63).bmp",
  86.    "OPENING\\open (64).bmp",
  87.    "OPENING\\open (65).bmp",
  88.    "OPENING\\open (66).bmp",
  89.    "OPENING\\open (67).bmp",
  90.    "OPENING\\open (68).bmp",
  91.    "OPENING\\open (69).bmp",
  92.    "OPENING\\open (70).bmp",
  93.    "OPENING\\open (71).bmp",
  94.    "OPENING\\open (72).bmp",
  95.    "OPENING\\open (73).bmp",
  96.    "OPENING\\open (74).bmp",
  97.    "OPENING\\open (75).bmp",
  98.    "OPENING\\open (76).bmp",
  99.    "OPENING\\open (77).bmp",
  100.    "OPENING\\open (78).bmp",
  101.    "OPENING\\open (79).bmp",
  102.    "OPENING\\open (80).bmp",
  103.    "OPENING\\open (81).bmp",
  104.    "OPENING\\open (82).bmp",
  105.    "OPENING\\open (83).bmp",
  106.    "OPENING\\open (84).bmp",
  107.    "OPENING\\open (85).bmp",
  108.    "OPENING\\open (86).bmp",
  109.    "OPENING\\open (87).bmp",
  110.    "OPENING\\open (88).bmp",
  111.    "OPENING\\open (89).bmp",
  112.    "OPENING\\open (90).bmp",
  113.    "OPENING\\open (91).bmp",
  114.    "OPENING\\open (92).bmp",
  115.    "OPENING\\open (93).bmp",
  116.    "OPENING\\open (94).bmp",
  117.    "OPENING\\open (95).bmp",
  118.    "OPENING\\open (96).bmp",
  119.    "OPENING\\open (97).bmp",
  120.    "OPENING\\open (98).bmp",
  121.    "OPENING\\open (99).bmp",
  122.    "OPENING\\open (100).bmp",
  123.    "OPENING\\open (101).bmp",
  124.    "OPENING\\open (102).bmp",
  125.    "OPENING\\open (103).bmp",
  126.    "OPENING\\open (104).bmp",
  127.    "OPENING\\open (105).bmp",
  128.    "OPENING\\open (106).bmp",
  129.    "OPENING\\open (107).bmp",
  130.    "OPENING\\open (108).bmp",
  131.    "OPENING\\open (109).bmp",
  132.    "OPENING\\open (110).bmp",
  133.    "OPENING\\open (111).bmp",
  134.    "OPENING\\open (112).bmp",
  135.    "OPENING\\open (113).bmp",
  136.    "OPENING\\open (114).bmp",
  137.    "OPENING\\open (115).bmp",
  138.    "OPENING\\open (116).bmp",
  139.    "OPENING\\open (117).bmp",
  140.    "OPENING\\open (118).bmp",
  141.    "OPENING\\open (119).bmp",
  142.    "OPENING\\open (120).bmp",
  143.    "OPENING\\open (121).bmp",
  144.    "OPENING\\open (122).bmp",
  145.    "OPENING\\open (123).bmp",
  146.    "OPENING\\open (124).bmp",
  147.    "OPENING\\open (125).bmp",
  148.    "OPENING\\open (126).bmp",
  149.    "OPENING\\open (127).bmp",
  150.    "OPENING\\open (128).bmp",
  151.    "OPENING\\open (129).bmp",
  152.    "OPENING\\open (130).bmp",
  153.    "OPENING\\open (131).bmp",
  154.    "OPENING\\open (132).bmp",
  155.    "OPENING\\open (133).bmp",
  156.    "OPENING\\open (134).bmp",
  157.    "OPENING\\open (135).bmp",
  158.    "OPENING\\open (136).bmp",
  159.    "OPENING\\open (137).bmp",
  160.    "OPENING\\open (138).bmp",
  161.    "OPENING\\open (139).bmp",
  162.    "OPENING\\open (140).bmp",
  163.    "OPENING\\open (141).bmp",
  164.    "OPENING\\open (142).bmp",
  165.    "OPENING\\open (143).bmp",
  166.    "OPENING\\open (144).bmp",
  167.    "OPENING\\open (145).bmp",
  168.    "OPENING\\open (146).bmp",
  169.    "OPENING\\open (147).bmp",
  170.    "OPENING\\open (148).bmp",
  171.    "OPENING\\open (149).bmp",
  172.    "OPENING\\open (150).bmp"
  173.  
  174. } ;
  175.  
  176. char HOMEPAGE[200][200]={
  177.     "HOMEPAGE\\H (1).bmp",
  178.    "HOMEPAGE\\H (2).bmp",
  179.    "HOMEPAGE\\H (3).bmp",
  180.    "HOMEPAGE\\H (4).bmp",
  181.    "HOMEPAGE\\H (5).bmp",
  182.    "HOMEPAGE\\H (6).bmp",
  183.    "HOMEPAGE\\H (7).bmp",
  184.    "HOMEPAGE\\H (8).bmp",
  185.    "HOMEPAGE\\H (9).bmp",
  186.    "HOMEPAGE\\H (10).bmp",
  187.    "HOMEPAGE\\H (11).bmp",
  188.    "HOMEPAGE\\H (12).bmp",
  189.    "HOMEPAGE\\H (13).bmp",
  190.    "HOMEPAGE\\H (14).bmp",
  191.    "HOMEPAGE\\H (15).bmp",
  192.    "HOMEPAGE\\H (16).bmp",
  193.    "HOMEPAGE\\H (17).bmp",
  194.    "HOMEPAGE\\H (18).bmp",
  195.    "HOMEPAGE\\H (19).bmp",
  196.    "HOMEPAGE\\H (20).bmp",
  197.    "HOMEPAGE\\H (21).bmp",
  198.    "HOMEPAGE\\H (22).bmp",
  199.    "HOMEPAGE\\H (23).bmp",
  200.    "HOMEPAGE\\H (24).bmp",
  201.    "HOMEPAGE\\H (25).bmp",
  202.    "HOMEPAGE\\H (26).bmp",
  203.    "HOMEPAGE\\H (27).bmp",
  204.    "HOMEPAGE\\H (28).bmp",
  205.    "HOMEPAGE\\H (29).bmp",
  206.    "HOMEPAGE\\H (30).bmp",
  207.    "HOMEPAGE\\H (31).bmp",
  208.    "HOMEPAGE\\H (32).bmp",
  209.    "HOMEPAGE\\H (33).bmp",
  210.    "HOMEPAGE\\H (34).bmp",
  211.    "HOMEPAGE\\H (35).bmp",
  212.    "HOMEPAGE\\H (36).bmp",
  213.    "HOMEPAGE\\H (37).bmp",
  214.    "HOMEPAGE\\H (38).bmp",
  215.    "HOMEPAGE\\H (39).bmp",
  216.    "HOMEPAGE\\H (40).bmp",
  217.    "HOMEPAGE\\H (41).bmp",
  218.    "HOMEPAGE\\H (42).bmp",
  219.    "HOMEPAGE\\H (43).bmp",
  220.    "HOMEPAGE\\H (44).bmp",
  221.    "HOMEPAGE\\H (45).bmp",
  222.    "HOMEPAGE\\H (46).bmp",
  223.    "HOMEPAGE\\H (47).bmp",
  224.    "HOMEPAGE\\H (48).bmp",
  225.    "HOMEPAGE\\H (49).bmp",
  226.    "HOMEPAGE\\H (50).bmp",
  227.    "HOMEPAGE\\H (51).bmp",
  228.    "HOMEPAGE\\H (52).bmp",
  229.    "HOMEPAGE\\H (53).bmp",
  230.    "HOMEPAGE\\H (54).bmp",
  231.    "HOMEPAGE\\H (55).bmp",
  232.    "HOMEPAGE\\H (56).bmp",
  233.    "HOMEPAGE\\H (57).bmp",
  234.    "HOMEPAGE\\H (58).bmp",
  235.    "HOMEPAGE\\H (59).bmp",
  236.    "HOMEPAGE\\H (60).bmp",
  237.    "HOMEPAGE\\H (61).bmp",
  238.    "HOMEPAGE\\H (62).bmp",
  239.    "HOMEPAGE\\H (63).bmp",
  240.    "HOMEPAGE\\H (64).bmp",
  241.    "HOMEPAGE\\H (65).bmp",
  242.    "HOMEPAGE\\H (66).bmp",
  243.    "HOMEPAGE\\H (67).bmp",
  244.    "HOMEPAGE\\H (68).bmp",
  245.    "HOMEPAGE\\H (69).bmp",
  246.    "HOMEPAGE\\H (70).bmp",
  247.    "HOMEPAGE\\H (71).bmp",
  248.    "HOMEPAGE\\H (72).bmp",
  249.    "HOMEPAGE\\H (73).bmp",
  250.    "HOMEPAGE\\H (74).bmp",
  251.    "HOMEPAGE\\H (75).bmp",
  252.    "HOMEPAGE\\H (76).bmp",
  253.    "HOMEPAGE\\H (77).bmp",
  254.    "HOMEPAGE\\H (78).bmp",
  255.    "HOMEPAGE\\H (79).bmp",
  256.    "HOMEPAGE\\H (80).bmp",
  257.    "HOMEPAGE\\H (81).bmp",
  258.    "HOMEPAGE\\H (82).bmp",
  259.    "HOMEPAGE\\H (83).bmp",
  260.    "HOMEPAGE\\H (84).bmp",
  261.    "HOMEPAGE\\H (85).bmp",
  262.    "HOMEPAGE\\H (86).bmp",
  263.    "HOMEPAGE\\H (87).bmp",
  264.    "HOMEPAGE\\H (88).bmp",
  265.    "HOMEPAGE\\H (89).bmp",
  266.    "HOMEPAGE\\H (90).bmp",
  267.    "HOMEPAGE\\H (91).bmp",
  268.    "HOMEPAGE\\H (92).bmp",
  269.    "HOMEPAGE\\H (93).bmp",
  270.    "HOMEPAGE\\H (94).bmp",
  271.    "HOMEPAGE\\H (95).bmp",
  272.    "HOMEPAGE\\H (96).bmp",
  273.    "HOMEPAGE\\H (97).bmp",
  274.    "HOMEPAGE\\H (98).bmp",
  275.    "HOMEPAGE\\H (99).bmp",
  276.    "HOMEPAGE\\H (100).bmp",
  277.    "HOMEPAGE\\H (101).bmp",
  278.    "HOMEPAGE\\H (102).bmp",
  279.    "HOMEPAGE\\H (103).bmp",
  280.    "HOMEPAGE\\H (104).bmp",
  281.    "HOMEPAGE\\H (105).bmp",
  282.    "HOMEPAGE\\H (106).bmp",
  283.    "HOMEPAGE\\H (107).bmp",
  284.    "HOMEPAGE\\H (108).bmp",
  285.    "HOMEPAGE\\H (109).bmp",
  286.    "HOMEPAGE\\H (110).bmp",
  287.    "HOMEPAGE\\H (111).bmp",
  288.    "HOMEPAGE\\H (112).bmp",
  289.    "HOMEPAGE\\H (113).bmp",
  290.    "HOMEPAGE\\H (114).bmp",
  291.    "HOMEPAGE\\H (115).bmp",
  292.    "HOMEPAGE\\H (116).bmp",
  293.    "HOMEPAGE\\H (117).bmp",
  294.    "HOMEPAGE\\H (118).bmp",
  295.    "HOMEPAGE\\H (119).bmp",
  296.    "HOMEPAGE\\H (120).bmp",
  297.    "HOMEPAGE\\H (121).bmp",
  298.    "HOMEPAGE\\H (122).bmp",
  299.    "HOMEPAGE\\H (123).bmp",
  300.    "HOMEPAGE\\H (124).bmp",
  301.    "HOMEPAGE\\H (125).bmp",
  302.    "HOMEPAGE\\H (126).bmp",
  303.    "HOMEPAGE\\H (127).bmp",
  304.    "HOMEPAGE\\H (128).bmp",
  305.    "HOMEPAGE\\H (129).bmp",
  306.    "HOMEPAGE\\H (130).bmp",
  307.    "HOMEPAGE\\H (131).bmp",
  308.    "HOMEPAGE\\H (132).bmp",
  309.    "HOMEPAGE\\H (133).bmp",
  310.    "HOMEPAGE\\H (134).bmp",
  311.    "HOMEPAGE\\H (135).bmp",
  312.    "HOMEPAGE\\H (136).bmp",
  313.    "HOMEPAGE\\H (137).bmp",
  314.    "HOMEPAGE\\H (138).bmp",
  315.    "HOMEPAGE\\H (139).bmp",
  316.    "HOMEPAGE\\H (140).bmp",
  317.    "HOMEPAGE\\H (141).bmp",
  318.    "HOMEPAGE\\H (142).bmp",
  319.    "HOMEPAGE\\H (143).bmp",
  320.    "HOMEPAGE\\H (144).bmp",
  321.    "HOMEPAGE\\H (145).bmp",
  322.    "HOMEPAGE\\H (146).bmp",
  323.    "HOMEPAGE\\H (147).bmp",
  324.    "HOMEPAGE\\H (148).bmp",
  325.    "HOMEPAGE\\H (149).bmp",
  326.    "HOMEPAGE\\H (150).bmp"
  327.  
  328.  
  329. };
  330. double ofsett_x=0.0,ofsett_y=0.0;
  331. int startpanx=0, startpany=0;
  332. double scalex=1,scaley=1;
  333. int moving =0;
  334. int curr_c_filled=0;
  335. int curr_r_filled=0;
  336. int filledrectcnt=0;
  337. int slider_y=800;
  338. int modes=6;
  339.  
  340.  
  341. int border=100;
  342.  
  343. int promptMsgNo;
  344. int showPrompt=0;
  345. int save_cnt=0;
  346. int showcircleoptn=0;
  347. int showsaveins=0;
  348. int showrectoptn=0;
  349. int opnindx=0;
  350. int hmindx=0;
  351. char save_filename[100],save_names[100][100];
  352. int intermidiate;
  353. int entrydone;
  354. int total_pts = 0;
  355. int curr_pts_size =10;
  356. int curr_r, curr_b, curr_g;
  357. int tools=0;
  358. int circleCnt = 0;
  359. int x_cir1,y_cir1;
  360. int circle_tool=0;
  361. int tempcount=0;
  362. int textcnt=0;
  363. int len=0;
  364. int linecnt=0;
  365. int box_len=10;
  366.  
  367.  
  368.  
  369. int t_x,t_y,t_r,t_g,t_b,t_size;
  370.  
  371. int r_x,r_y,r_dx,r_dy,r_r,r_g,r_b;
  372.  
  373. int txt_x,txt_y,txt_r,txt_g,txt_b,txt_text;
  374.  
  375. int l_x,l_y,l_x1,l_y1,l_r,l_g,l_b;
  376.  
  377.  
  378.  
  379. typedef struct
  380. {
  381.     int x, y, r, g, b, size;
  382. } pts;
  383.  
  384. typedef struct
  385. {
  386.     int x, y, r, g, b,size,isfilled;
  387. } circle;
  388. typedef struct
  389. {
  390.     int x,y,r,g,b,dx,dy,isfilled;
  391. }filledRect;
  392. typedef struct
  393. {
  394.     int r,g,b,x,y;
  395.     char text[100];
  396. }textBox;
  397. typedef struct
  398. {
  399.     int x,y,r,g,b,size;
  400.  
  401. }circletemp;
  402.  
  403. typedef struct
  404. {
  405.  
  406.     int x1,y1,x2,y2,r,g,b;
  407. }line ;
  408.  
  409.  
  410.  
  411.  
  412.  
  413. pts *PointsArr = (pts *)malloc(9999999 * sizeof(pts));
  414.  
  415. line * lineArr = (line *) malloc (100 * sizeof(line));
  416. int * linesAt = (int *) malloc (100 * sizeof(int));
  417.  
  418. circle *CircleArr = (circle *)malloc(1000 * sizeof(circle));
  419. int *CirclesAt = (int *)malloc(100 * sizeof(int));
  420.  
  421. filledRect * filledRectArr = (filledRect *) malloc (1000 * sizeof(filledRect));
  422. int * filledRectsAt = (int *) malloc (100* sizeof(int));
  423.  
  424. textBox * textBoxArr= (textBox *) malloc (20 * sizeof (textBox));
  425. int * textsAt = (int *) malloc (20* sizeof (int));
  426.  
  427. // filledcircle * filledcircleArr=(pts *)malloc(1000 * sizeof(filledcircle));
  428. // int *filledcircleAt=(int *)malloc(100 *sizeof(int));
  429.  
  430.  
  431. void init();
  432. void undo();
  433. void erase();
  434.  
  435. void worldtoscreen(double fworldx, double fworldy,int &nscreenx;, int &nscreeny;){
  436.     nscreenx=(int)(fworldx-ofsett_x)*scalex;
  437.     nscreeny=(int)(fworldy-ofsett_y)*scaley;
  438.  
  439.  
  440. }
  441. void screentoworld(int nscreenx ,int nscreeny,double &fworldx;, double &fworldy;){
  442.     fworldx=(double)(nscreenx)/scalex+ofsett_x;
  443.     fworldy=(double)(nscreeny)/scaley+ofsett_y;
  444. }
  445.  
  446.  
  447.  
  448.  
  449. void savefile&#40;const char save_filename[]&#41; {
  450.     FILE *to_write = fopen&#40;save_filename, "wb"&#41;;
  451.     if (to_write == NULL) {
  452.         promptMsgNo = 2;
  453.         return;  // Exit function if unable to open file
  454.     }
  455.  
  456.     if (fwrite(&total;_pts, sizeof(int), 1, to_write) != 1 ||
  457.         fwrite(&textcnt;, sizeof(int), 1, to_write) != 1 ||
  458.         fwrite(&circleCnt;, sizeof(int), 1, to_write) != 1 ||
  459.         fwrite(&linecnt;, sizeof(int), 1, to_write) != 1 ||
  460.         fwrite(&filledrectcnt;, sizeof(int), 1, to_write) != 1 ||
  461.         fwrite(textsAt, sizeof(int), textcnt, to_write) != textcnt ||
  462.         fwrite(CirclesAt, sizeof(int), circleCnt, to_write) != circleCnt ||
  463.         fwrite(filledRectsAt, sizeof(int), filledrectcnt, to_write) != filledrectcnt ||
  464.         fwrite(PointsArr, sizeof(pts), total_pts, to_write) != total_pts ||
  465.         fwrite(lineArr, sizeof(line), linecnt, to_write) != linecnt ||
  466.         fwrite(filledRectArr, sizeof(filledRect), filledrectcnt, to_write) != filledrectcnt ||
  467.         fwrite(CircleArr, sizeof(circle), circleCnt, to_write) != circleCnt) {
  468.         promptMsgNo = 2;
  469.         fclose(to_write);  // Close file before exiting
  470.         return;
  471.     }
  472.  
  473.     fclose(to_write);  // Close file after writing
  474.  
  475.     // Open the save list file
  476.     FILE *save_list = fopen&#40;"saves", "a+"&#41;;
  477.     if (save_list == NULL) {
  478.         promptMsgNo = 2;
  479.         return;
  480.     }
  481.  
  482.     // Check if the save filename already exists in the saves file
  483.     bool exists = false;
  484.     char read[100];
  485.     while (fgets(read, 100, save_list)) {
  486.         if (strcmp(read, save_filename) == 0) {
  487.             exists = true;
  488.             break;
  489.         }
  490.     }
  491.  
  492.     if (!exists) {
  493.         fwrite(save_filename, sizeof(char), strlen(save_filename), save_list);
  494.     fwrite("\n", sizeof(char), 1, save_list);
  495.        
  496.     }
  497.  
  498.  
  499.  
  500.     fclose(save_list);
  501.     tools=21;  // Close the saves file
  502.  
  503.     showPrompt = 1;  
  504. }
  505.  
  506.  
  507. void loadFile&#40;char save_name[]&#41; {
  508.     promptMsgNo = 9;
  509.     FILE *from_save = fopen&#40;save_name, "rb"&#41;;
  510.     if (from_save == NULL) {
  511.         showPrompt = 1;
  512.         promptMsgNo = 10;
  513.         modes = 1;
  514.         return;
  515.     }
  516.     if (fread(&total;_pts, sizeof(int), 1, from_save) != 1 ||
  517.         fread(&textcnt;, sizeof(int), 1, from_save) != 1 ||
  518.         fread(&circleCnt;, sizeof(int), 1, from_save) != 1 ||
  519.         fread(&linecnt;, sizeof(int), 1, from_save) != 1 ||
  520.         fread(&filledrectcnt;, sizeof(int), 1, from_save) != 1 ||
  521.         fread(textsAt, sizeof(int), textcnt, from_save) != textcnt ||
  522.         fread(CirclesAt, sizeof(int), circleCnt, from_save) != circleCnt ||
  523.         fread(filledRectsAt, sizeof(int), filledrectcnt, from_save) != filledrectcnt ||
  524.         fread(PointsArr, sizeof(pts), total_pts, from_save) != total_pts ||
  525.         fread(lineArr, sizeof(line), linecnt, from_save) != linecnt ||
  526.         fread(filledRectArr, sizeof(filledRect), filledrectcnt, from_save) != filledrectcnt ||
  527.         fread(CircleArr, sizeof(circle), circleCnt, from_save) != circleCnt) {
  528.         modes = 1;
  529.         fclose(from_save);
  530.         return;
  531.     }
  532.     fclose(from_save);
  533. }
  534.  
  535.  
  536. void readList() {
  537.     FILE *save_list = fopen&#40;"saves", "r"&#41;;
  538.     if (save_list == NULL) {
  539.         modes = 1;
  540.         showPrompt = 1;
  541.         promptMsgNo = 11;
  542.         return;
  543.     }
  544.  
  545.     // Count the number of lines (saved files)
  546.     while (!feof(save_list)) {
  547.         char c = fgetc(save_list);
  548.         if (c == '\n') {
  549.             save_cnt++;
  550.         }
  551.     }
  552.  
  553.    
  554.     rewind(save_list);
  555.  
  556.     for (int i = 0; i < save_cnt; i++) {
  557.         fgets(save_names[i], 200, save_list);
  558.  
  559.         size_t len = strlen(save_names[i]);
  560.         if (len > 0 && save_names[i][len - 1] == '\n') {
  561.             save_names[i][len - 1] = '\0';
  562.         }
  563.     }
  564.  
  565.     fclose(save_list);
  566. }
  567.  
  568.  
  569.  
  570.  
  571.  
  572. void drawobjs()
  573. {
  574.     for (int i = 0, q = 0,  p=0, t=0, w=0; i < total_pts; i++)
  575.     {
  576.  
  577.         if(i==textsAt[t]){
  578.               int pixel_x,pixel_y;
  579.              
  580.               iSetColor(textBoxArr[t].r,textBoxArr[t].g,textBoxArr[t].b);
  581.               worldtoscreen(textBoxArr[t].x,textBoxArr[t].y,pixel_x,pixel_y);
  582.               iText(pixel_x,pixel_y,textBoxArr[t].text,GLUT_BITMAP_TIMES_ROMAN_24);
  583.               t++;
  584.            
  585.  
  586.  
  587.         }
  588.          else if (i == CirclesAt[q])
  589.  
  590.         {   int pixel_x,pixel_y,pixel_r;
  591.              worldtoscreen(CircleArr[q].x, CircleArr[q].y,pixel_x,pixel_y);
  592.             iSetColor(CircleArr[q].r, CircleArr[q].g, CircleArr[q].b);
  593.             pixel_r=(int)(CircleArr[q].size*scalex)00;
  594.             if(CircleArr[q].isfilled)
  595.             iFilledCircle(pixel_x,pixel_y, CircleArr[q].size, 1000);
  596.             else
  597.             iCircle(pixel_x,pixel_y, pixel_r, 1000);
  598.             q++;
  599.            printf("%d %d %d\n",pixel_x,pixel_y,pixel_r);
  600.            
  601.         }
  602.          else if(i ==  filledRectsAt[p]){
  603.              int pixel_x,pixel_y;
  604.              int pixel_dx,pixel_dy;
  605.              worldtoscreen(filledRectArr[p].x, filledRectArr[p].y,pixel_x,pixel_y);
  606.              //worldtoscreen(filledRectArr[p].dx, filledRectArr[p].dy,pixel_dx,pixel_dy);
  607.              pixel_dx=filledRectArr[p].dx*scalex;
  608.              pixel_dy=filledRectArr[p].dy*scaley;
  609.             iSetColor(filledRectArr[p].r,filledRectArr[p].g,filledRectArr[p].b);
  610.             //rintf(" %d %d %d %d\n",filledRectArr[].x,CircleArr[q].y,CircleArr[q].size);
  611.             if(filledRectArr[p].isfilled)
  612.             iFilledRectangle(pixel_x,pixel_y,pixel_dx,pixel_dy);
  613.             else
  614.             iRectangle(pixel_x,pixel_y,pixel_dx,pixel_dy);
  615.             p++;
  616.             //printf("%d %d %d %d \n",pixel_x,pixel_y,filledRectArr[p].dx, filledRectArr[p].dy);
  617.         }
  618.         else if(i==linesAt[w]){
  619.  
  620.                  int pixel_x1,pixel_y1,pixel_x2,pixel_y2;
  621.                  worldtoscreen(lineArr[w].x1, lineArr[w].y1,pixel_x1,pixel_y1);
  622.                  worldtoscreen( lineArr[w].x2, lineArr[w].y2,pixel_x2,pixel_y2);
  623.                 iSetColor(lineArr[w].r, lineArr[w].g, lineArr[w].b);
  624.                 iLine(pixel_x1,pixel_y1,pixel_x2,pixel_y2);
  625.                 w++;
  626.                // printf("%d %d %d %d\n",lineArr[w].x1, lineArr[w].y1, lineArr[w].x2, lineArr[w].y2);
  627.               //printf("%d %d %d %d \n",pixel_x,pixel_y,pixel_x1,pixel_y1);
  628.  
  629.            
  630.  
  631.  
  632.         }
  633.         else
  634.         {    int pixel_x,pixel_y;
  635.              worldtoscreen(PointsArr[i].x, PointsArr[i].y,pixel_x,pixel_y);
  636.            
  637.             iSetColor(PointsArr[i].r, PointsArr[i].g, PointsArr[i].b);
  638.        
  639.             iFilledCircle(pixel_x,pixel_y, PointsArr[i].size);
  640.         }
  641.     }
  642. }
  643.  
  644. void iDraw()
  645. {
  646.     if(modes==1){
  647.        
  648.    
  649.     iShowBMP(0,0,HOMEPAGE[hmindx]);
  650.    
  651.     }
  652.  
  653.  
  654. if(modes==2){
  655.     iClear();
  656.     iSetColor(255, 255, 255);
  657.     iFilledRectangle(0, 0, 1400, 700);
  658.     drawobjs();
  659.     if (tools ==2){
  660.          int pixel_x,pixel_y;
  661.          worldtoscreen(t_x, t_y,pixel_x,pixel_y);
  662.          iSetColor(t_r,t_g, t_b);
  663.         iCircle(pixel_x,pixel_y, t_size, 1000);
  664.        
  665.        
  666.         }
  667.      if(tools==3){
  668.         int pixel_x,pixel_y,pixel_dx=0,pixel_dy=0;
  669.         worldtoscreen(r_x,r_y,pixel_x,pixel_y);
  670.         worldtoscreen(r_dx,r_dy,pixel_dx,pixel_dy);
  671.         iSetColor(r_r, r_g, r_b);
  672.         //iFilledRectangle(pixel_x,pixel_y,r_dx,r_dy);
  673.      }  
  674.     if(tools==13 || tools==14){
  675.         int pixel_x,pixel_y;
  676.         worldtoscreen(txt_x,txt_y,pixel_x,pixel_y);
  677.         iSetColor(0,0,0);
  678.         iRectangle(pixel_x,pixel_y-5,box_len,25);
  679.  
  680.     }
  681.     iSetColor(255, 255, 255);
  682.     iFilledRectangle(0, 0, 130, 700);
  683.     iShowBMP(10, 20, "image//4.bmp");
  684.     iShowBMP(60+15, 35, "image//eraser.bmp");
  685.     iShowBMP(67+10, 180, "image//pen.bmp");
  686.     if(tools==1) iShowBMP(105+10, 100, "image//size.bmp");
  687.     iShowBMP(67+10, 230, "image//textbox.bmp");
  688.     iShowBMP(67+10, 285, "image//grab tool.bmp");
  689.     iShowBMP(80,325,"image//line.bmp");
  690.     iShowBMP(1224,621,"image//savelogo2.bmp");
  691.     iShowBMP(1285,626,"image//back.bmp");
  692.     iShowBMP(80,370,"image\\deselect.bmp");
  693.     iSetColor(0, 0, 0);
  694.     //iFilledCircle(87, 100, 15, 1000);
  695.     iShowBMP(66+10, 130, "image//rectangle image.bmp");
  696.     iShowBMP(67+10, 85, "image//circle.bmp");
  697.    
  698.     if(tools==1)iShowBMP(67, 180, "image//slider.bmp");
  699.     if(tools==6)iShowBMP(67, 280, "image//slider.bmp");
  700.     if(tools==100)iShowBMP(67, 230, "image//slider.bmp");
  701.     if(tools==3)iShowBMP(67, 130, "image//slider.bmp");
  702.     if(tools==2)iShowBMP(67, 87, "image//slider.bmp");
  703.     if(showcircleoptn==1)iShowBMP(126,36,"image\\circleoptn.bmp");
  704.     if(tools==7)iShowBMP(67, 35, "image//slider.bmp");
  705.     if(tools==20)iShowBMP(470, 206, "image//savelogo.bmp");
  706.     if(tools==20)iText(501,375,save_filename,GLUT_BITMAP_TIMES_ROMAN_24);
  707.     if(tools==20)iShowBMP(485,580,promptMsg[10]);
  708.     if(tools==13 || tools==14)iShowBMP(67, 230, "image//slider.bmp");
  709.     if(tools==16 || tools==17)iShowBMP(67, 320, "image//slider.bmp");
  710.     iShowBMP(1157,621,"image\\undo.bmp");
  711.     if(showrectoptn==1)iShowBMP(126,75,"image\\rectoptn.bmp");
  712.     if(tools==0)iShowBMP(67,375,"image//slider.bmp");
  713.     iSetColor(0,0,0);
  714.     iFilledCircle(35,650,25,100000);
  715.     iSetColor(curr_r,curr_g,curr_b);
  716.     iFilledCircle(35,650,20,100000);
  717.  
  718.     if(showPrompt){
  719.         iSetColor(0,0,0);
  720.         if(tools==1)iShowBMP(485,590,promptMsg[0]);
  721.          if(tools==7)iShowBMP(485,590,promptMsg[1]);
  722.           if(tools==2)iShowBMP(485,590,promptMsg[2]);
  723.            if(tools==3)iShowBMP(485,590,promptMsg[3]);
  724.          if(tools==16 || tools==17)iShowBMP(485,590,promptMsg[4]);
  725.          if(tools==6 || tools==10)iShowBMP(485,590,promptMsg[5]);
  726.          if(tools==13 || tools==14)iShowBMP(480,572,promptMsg[8]);
  727.           if(tools==21)iShowBMP(485,590,promptMsg[6]);
  728.  
  729.          
  730.  
  731.  
  732.     }
  733.    
  734.    // iRectangle(66, 130, 40, 40);
  735.     }
  736.     if(modes==3){
  737.          iClear();
  738.     // iSetColor(255, 255, 255);
  739.     // iFilledRectangle(0, 0, 1400, 700);
  740.     //   iShowBMP(800,0,"image//logo.bmp");
  741.     // iShowBMP(70,90,"image//savelist.bmp");
  742.      iShowBMP(0,0,"image\\LOADPAGE.bmp");
  743.      iShowBMP(1260,630,"image\\back.bmp");
  744.  
  745.     for(int i=0;i>border_x)
  746.     {
  747.         iMouseMove(mx, my);
  748.     }
  749.    
  750.     if (tools != 1 && button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
  751.     {
  752.         if ((mx >= 67 && mx <= 67 + 50) && (my >= 180 && my <= 180 + 50))
  753.         {
  754.             tools = 1,showPrompt=1;
  755.         }
  756.     }
  757.      if (tools != 2 && butt GLUT_LEFT_BUTTON && state == GLUT_DOWN)
  758.     {
  759.         if ((mx >= 67 && mx <= 67 + 40) && (my >= 85 && my <= 85 + 40))
  760.         {tools = 22,showcircleoptn=1;return;}
  761.     }
  762.      if (tools != 3 && butt GLUT_LEFT_BUTTON && state == GLUT_DOWN){
  763.         if((mx>=66 && mx<=66+40) && (my>=130 && my<=130+40))
  764.        { tools=33,showrectoptn=1;return;}
  765.     }
  766.      if(tools!=0 && butt GLUT_LEFT_BUTTON && state == GLUT_DOWN){
  767.     if((mx>=80&& mx<=123) && (my>=372 && my<=409)){
  768.           tools=0;return;
  769.     }
  770.     }
  771.      if (butt GLUT_LEFT_BUTTON && state == GLUT_DOWN)
  772.     {
  773.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 && my <= 10 + 56))
  774.         {
  775.             curr_r = 0, curr_b = 0, curr_g = 255;
  776.         }
  777.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 56 && my <= 10 + 2 * 56))
  778.         {
  779.             curr_r = 0, curr_b = 255, curr_g = 0;
  780.         }
  781.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 2 * 56 && my <= 10 + 3 * 56))
  782.         {
  783.             curr_r = 102, curr_b = 204, curr_g = 0;
  784.         }
  785.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 3 * 56 && my <= 10 + 4 * 56))
  786.         {
  787.             curr_r = 255, curr_b =255, curr_g = 0;
  788.         }
  789.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 4 * 56 && my <= 10 + 5 * 56))
  790.         {
  791.             curr_r = 255, curr_b = 0, curr_g = 0;
  792.         }
  793.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 5 * 56 && my <= 10 + 6 * 56))
  794.         {
  795.             curr_r = 255, curr_b = 3, curr_g = 45;
  796.         }
  797.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 6 * 56 && my <= 10 + 7 * 56))
  798.         {
  799.             curr_r = 255, curr_b = 0, curr_g = 100;
  800.         }
  801.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 7 * 56 && my <= 10 + 8 * 56))
  802.         {
  803.             curr_r = 255, curr_b = 0, curr_g = 168;
  804.         }
  805.         if ((mx >= 10 && mx <= 10 + 50) && (my >= 10 + 8 * 56 && my <= 10 + 9 * 56))
  806.         {
  807.             curr_r = 255, curr_b = 0, curr_g = 255;
  808.         }
  809.         if ((mx >= 67 && mx <= 67+40) && (my >= 280 && my <= 280+40)&&tools;!=6)
  810.         {
  811.            tools=6,showPrompt=1;return;
  812.         }
  813.         if ((mx >= 60 && mx <= 110) && (my >= 20 && my <= 70)&&tools;!=7)
  814.         {
  815.            tools=7,showPrompt=1;return;
  816.         }if ((mx >= 120 && mx <=(522))  && (my >= 417 && my <= 481)&& modes==1)
  817.         {
  818.            modes=2,showPrompt=1;return;
  819.         }if ((mx >= 83 && mx <=(117))  && (my >= 237 && my <= 264)&& tools!=13)
  820.         {
  821.            tools=13,showPrompt=1;return;
  822.         }
  823.         if ((mx >= 163 && mx <=(189))  && (my >= 260 && my <= 282)&& tools==1)
  824.         {
  825.            curr_pts_size=20;return;
  826.         }if ((mx >= 167 && mx <=(189))  && (my >= 193 && my <= 213)&& tools==1)
  827.         {
  828.            curr_pts_size=10;return;
  829.         }if ((mx >= 81 && mx <=(114))  && (my >= 329 && my <= 357))
  830.         {
  831.            tools=16,showPrompt=1;return;
  832.         }
  833.         }if ((mx >= 172 && mx <=(187))  && (my >= 138 && my <= 149)&& tools==1)
  834.         {
  835.            curr_pts_size=5;return;
  836.         }
  837.         if ((mx >= 1224 && mx <=(1276))  && (my >= 624 && my <= 675)&& modes==2)
  838.         {
  839.            tools=20,showPrompt=1;return;
  840.         }
  841.         if ((mx >= 668 && mx <=(749))  && (my >= 278 && my <= 301)&& modes==2 && tools==20 && moving%2==0)
  842.         {
  843.            savefile&#40;save_filename&#41;;return;
  844.         }
  845.         if ((mx >= 120 && mx <=(521))  && (my >= 260 && my <=338 )&& modes==1)
  846.  
  847.         {
  848.           readList();
  849.            modes=3;
  850.            return;
  851.         }if ((mx >= 1287 && mx <=(1376))  && (my >= 635 && my <= 662)&& modes==2 )
  852.         {
  853.            modes=1;
  854.            freemem();
  855.            init();
  856.            erase();
  857.    
  858.            return;
  859.         }
  860.         if((mx >= 168 && mx <=(214))  && (my >= 124 && my <= 149)&&  showcircleoptn==1  ){
  861.             curr_c_filled=0;
  862.             showcircleoptn=0;
  863.             tools=2;
  864.             showPrompt=1;
  865.            
  866.         }
  867.         if((mx >= 173 && mx <=(209))  && (my >= 57 && my <= 93)&&  showcircleoptn==1 ){
  868.             curr_c_filled=1;
  869.             showcircleoptn=0;
  870.             showPrompt=1;
  871.             tools=2;
  872.            
  873.         }
  874.         if((mx >= 171 && mx <=(211))  && (my >= 166 && my <= 209)&&  showrectoptn==1 ){
  875.             curr_r_filled=0;
  876.             showrectoptn=0;
  877.             showPrompt=1;
  878.             tools=3;
  879.         }
  880.         if((mx >= 171 && mx <=(212))  && (my >= 94 && my <= 133)&&  showrectoptn==1 ){
  881.             curr_r_filled=1;
  882.             showrectoptn=0;
  883.             showPrompt=1;
  884.             tools=3;
  885.         }
  886.         if((mx >= 1156 && mx <=(1200))  && (my >= 635 && my <= 665)&&  modes==2 && moving%2==0){
  887.             undo();
  888.            
  889.         }
  890.        
  891.         if(modes==3){
  892.        
  893.         if ((mx >= 1260 && mx <=(1356))  && (my >= 637 && my <= 669) )
  894.         {
  895.            modes=1;
  896.            init();
  897.            hmindx=0;
  898.            return;
  899.         }
  900.         }
  901.  
  902.      if (tools == 2 && butt GLUT_LEFT_BUTTON && state == GLUT_DOWN )
  903.     {
  904.        
  905.         CirclesAt[circleCnt] = total_pts++;
  906.        
  907.         CircleArr[circleCnt].x = world_x;
  908.         CircleArr[circleCnt].y = world_y;
  909.         CircleArr[circleCnt].r = curr_r;
  910.         CircleArr[circleCnt].g = curr_g;
  911.         CircleArr[circleCnt].b = curr_b;
  912.         CircleArr[circleCnt].isfilled=curr_c_filled;
  913.    
  914.         t_x = CircleArr[circleCnt].x;
  915.         t_y = CircleArr[circleCnt].y;
  916.         t_r = curr_r;
  917.         t_g = curr_g;
  918.         t_b = curr_b;
  919.    
  920.     }
  921.      if (tools == 2 && butt GLUT_LEFT_BUTTON && state == GLUT_UP  )
  922.     {
  923.         CircleArr[circleCnt].size=sqrt((mx-CircleArr[circleCnt].x)*(mx-CircleArr[circleCnt].x)-(my-CircleArr[circleCnt].y)*(my-CircleArr[circleCnt].y));
  924.         circleCnt++;
  925.         t_size=0;
  926.         t_x=0;
  927.         t_y=0;
  928.         t_r=255;
  929.         t_g=255;
  930.         t_b=255;
  931.        
  932.  
  933.     }
  934.      if (tools == 3 && butt GLUT_LEFT_BUTTON  && state == GLUT_DOWN && mx>border_x )
  935.     {
  936.        
  937.         filledRectsAt[filledrectcnt]=total_pts++;
  938.         filledRectArr[filledrectcnt].x=world_x;
  939.         filledRectArr[filledrectcnt].y=world_y;
  940.         filledRectArr[filledrectcnt].r=curr_r;
  941.         filledRectArr[filledrectcnt].g=curr_g;
  942.         filledRectArr[filledrectcnt].b=curr_b;
  943.         filledRectArr[filledrectcnt].isfilled=curr_r_filled;
  944.  
  945.         r_x=world_x;
  946.         r_y=world_y;
  947.         r_r=curr_r;
  948.         r_b=curr_b;
  949.         r_g=curr_g;
  950.     }
  951.          if (tools == 3 && button == GLUT_LEFT_BUTTON && state == GLUT_UP && mx>border_x) {    
  952.             double world_x, world_y;
  953.             screentoworld(mx,my,world_x,world_y);      
  954.  
  955.                 filledRectArr[filledrectcnt].dx=abs(world_x-filledRectArr[filledrectcnt].x);
  956.                 filledRectArr[filledrectcnt].dy=abs(world_y-filledRectArr[filledrectcnt].y);
  957.                 filledrectcnt++;
  958.             }
  959.  
  960.            
  961.    
  962.     if(tools==6){
  963.         double prev_mx,prev_my;
  964.         screentoworld(mx,my,prev_mx,prev_my);
  965.     if(tools==10){
  966.  
  967.         double after_mx,after_my;
  968.         screentoworld(mx,my,after_mx,after_my);
  969.         printf("%d %d \n",ofsett_x,ofsett_y);
  970.  
  971.        ofsett_x +=(prev_mx-after_mx);
  972.          ofsett_y +=(prev_my-after_my);
  973.            printf("%d %d \n",ofsett_x,ofsett_y);
  974.  
  975.  
  976.     }}
  977.     if(tools==13 && button==GLUT_LEFT_BUTTON && state==GLUT_DOWN && mx>border_x ){
  978.      
  979.          textsAt[textcnt]=total_pts++;
  980.          textBoxArr[textcnt].x=world_x;
  981.          textBoxArr[textcnt].y=world_y;
  982.          textBoxArr[textcnt].r=curr_r;
  983.          textBoxArr[textcnt].g=curr_g;
  984.          textBoxArr[textcnt].b=curr_b;
  985.  
  986.  
  987.          txt_x=textBoxArr[textcnt].x;
  988.          txt_y=textBoxArr[textcnt].y;
  989.          txt_r=curr_r;
  990.          txt_g=curr_g;
  991.          txt_b=curr_b;
  992.          tools=14;
  993.  
  994.        
  995.     }
  996.     if(tools==16 && button==GLUT_LEFT_BUTTON && state==GLUT_DOWN && mx>border_x){
  997.  
  998.        double world_x1,world_y1;
  999.        screentoworld(mx,my,world_x1,world_y1);
  1000.        
  1001.         lineArr[linecnt].x1=world_x1;
  1002.         lineArr[linecnt].y1=world_y1;
  1003.         lineArr[linecnt].r=curr_r;
  1004.         lineArr[linecnt].g=curr_g;
  1005.         lineArr[linecnt].b=curr_b;
  1006.         tools=17;
  1007.    
  1008.     }
  1009.         if(tools==17 && button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN && mx>border_x){
  1010.             double world_x2,world_y2;
  1011.        screentoworld(mx,my,world_x2,world_y2);
  1012.  
  1013.  
  1014.             lineArr[linecnt].x2=world_x2;
  1015.             lineArr[linecnt].y2=world_y2;
  1016.             linesAt[linecnt]=total_pts++;
  1017.             linecnt++;
  1018.             tools=16;
  1019.         }
  1020.  
  1021.         if(modes==3){
  1022.             if(mx>=120 && mx<= 25 && butt GLUT_LEFT_BUTTON && state == GLUT_DOWN){
  1023.                 int indx=(537-my)/48;
  1024.                 if(indx>= 1287 && mx <=(1376))  && (my >= 635 && my <= 662) ){
  1025.                
  1026.                 init();
  1027.                 freemem();
  1028.                 modes=1;
  1029.                
  1030.                
  1031.             }
  1032.  
  1033.         }}
  1034.  
  1035.        
  1036.     }
  1037.  
  1038.  
  1039.  
  1040. void iKeyboard(unsigned char key)
  1041.  
  1042. {   if(modes==6){
  1043.     modes=1;
  1044.     hmindx=0;
  1045. }
  1046.    
  1047.     if(key=='q' && tools!=13 &&tools;!=14 && tools!=20){
  1048.        
  1049.         scalex*=1.01;
  1050.         scaley*=1.01;
  1051.         tools=10;
  1052.  
  1053.     }
  1054.     if(key=='a' && tools!=13 &&tools;!=14 && tools!=20){
  1055.        
  1056.         scalex*=0.9;
  1057.         scaley*=0.9;
  1058.         tools=10;
  1059.         }
  1060.     if(tools==14 && modes==2){
  1061.        
  1062.        if (tools == 14 && modes == 2) {
  1063.     if (key == 13) {
  1064.         textBoxArr[textcnt++].text[len] = '\0';
  1065.         tools = 13;
  1066.         len = 0;
  1067.         box_len=10;
  1068.     } else {
  1069.         if (key == 8 && len > 0) {
  1070.             textBoxArr[textcnt].text[--len] = '\0';
  1071.              box_len-=10;
  1072.         } else {
  1073.             textBoxArr[textcnt].text[len++] = key;
  1074.             box_len+=10;
  1075.         }
  1076.     }
  1077. }
  1078.  
  1079.  
  1080.     }
  1081.     if(tools==20 && modes==2){
  1082.         if(key==13){
  1083.             save_filename[len]='\0';
  1084.             entrydone=1;
  1085.         }
  1086.         else{
  1087.             if(key==8 && len>0){
  1088.                 save_filename[--len]='\0';
  1089.             }
  1090.             else{
  1091.                 save_filename[len++]=key;
  1092.  
  1093.             }
  1094.         }
  1095.     }
  1096.    
  1097.  
  1098. }
  1099.  
  1100. void iSpecialKeyboard(unsigned char key)
  1101. {
  1102.    
  1103.    
  1104. }
  1105. void freemem(){
  1106.     free(PointsArr);
  1107.     free(textBoxArr);
  1108.     free(textsAt);
  1109.     free(CircleArr);
  1110.     free(CirclesAt);
  1111.     free(lineArr);
  1112.     free(linesAt);
  1113.     free(filledRectArr);
  1114.     free(filledRectsAt);
  1115.    
  1116. }
  1117.  
  1118. void undo(){
  1119.     if(filledRectsAt[filledrectcnt]==total_pts){
  1120.          filledRectArr[filledrectcnt].x=0;
  1121.         filledRectArr[filledrectcnt].y=0;
  1122.         filledRectArr[filledrectcnt].r=0;
  1123.         filledRectArr[filledrectcnt].g=0;
  1124.         filledRectArr[filledrectcnt].b=0;
  1125.         filledRectArr[filledrectcnt].isfilled=0;
  1126.         filledRectArr[filledrectcnt].dx=0;
  1127.         filledRectArr[filledrectcnt].dy=0;
  1128.         filledrectcnt--;
  1129.         total_pts--;
  1130.  
  1131.     }
  1132.     else if(CirclesAt[circleCnt]==total_pts){
  1133.        
  1134.         CircleArr[circleCnt].x = 0;
  1135.         CircleArr[circleCnt].y = 0;
  1136.         CircleArr[circleCnt].r = 0;
  1137.         CircleArr[circleCnt].g = 0;
  1138.         CircleArr[circleCnt].b = 0;
  1139.         CircleArr[circleCnt].size=0;
  1140.        circleCnt--;
  1141.        total_pts--;
  1142.        
  1143.     }
  1144.      else if(linesAt[linecnt]==total_pts){
  1145.          lineArr[linecnt].x1=0;
  1146.         lineArr[linecnt].y1=0;
  1147.         lineArr[linecnt].r=0;
  1148.         lineArr[linecnt].g=0;
  1149.         lineArr[linecnt].b=0;
  1150.          lineArr[linecnt].x2=0;
  1151.        lineArr[linecnt].y2=0;
  1152.         linecnt--;
  1153.         total_pts--;
  1154.     }
  1155.     else if(textsAt[textcnt]==total_pts){
  1156.         textBoxArr[textcnt].x=0;
  1157.          textBoxArr[textcnt].y=0;
  1158.          textBoxArr[textcnt].r=0;
  1159.          textBoxArr[textcnt].g=0;
  1160.          textBoxArr[textcnt].b=0;
  1161.         textBoxArr[textcnt].text[len--]='\0';
  1162.         textcnt--;
  1163.         total_pts--;
  1164.     }
  1165.     else{
  1166.         PointsArr[total_pts].x = 0;
  1167.         PointsArr[total_pts].y = 0;
  1168.         PointsArr[total_pts].r = 255;
  1169.         PointsArr[total_pts].g = 255;
  1170.         PointsArr[total_pts].b = 255;
  1171.         PointsArr[total_pts].size=0;
  1172.  
  1173.        total_pts--;
  1174.     }
  1175. }
  1176.  
  1177. void init(){
  1178.  ofsett_x=0.0,ofsett_y=0.0;
  1179.  startpanx=0, startpany=0;
  1180.  scalex=1,scaley=1;
  1181.  moving =0;
  1182.  curr_c_filled=0;
  1183.  curr_r_filled=0;
  1184.  filledrectcnt=0;
  1185. // slider_y=800;
  1186.  
  1187.  promptMsgNo=0;
  1188.  showPrompt=0;
  1189.  save_cnt=0;
  1190.  showcircleoptn=0;
  1191.  showsaveins=0;
  1192.  showrectoptn=0;
  1193. save_filename[100],save_names[100][100];
  1194.  
  1195.  total_pts = 0;
  1196.  curr_pts_size =10;
  1197.  curr_r=0, curr_b=0, curr_g=0;
  1198.  tools=0;
  1199.  circleCnt = 0;
  1200.  textcnt=0;
  1201.  len=0;
  1202.  linecnt=0;
  1203.  box_len=0;
  1204.  
  1205. }
  1206. void animation(){
  1207.     if(opnindx<149) opnindx++;
  1208.     else opnindx = 109;
  1209.    
  1210. }
  1211.  
  1212. void animation2(){
  1213.     if(hmindx<149) hmindx++;
  1214.    
  1215. }
  1216. void erase(){pts *PointsArr = (pts *)malloc(9999999 * sizeof(pts));
  1217.  
  1218. line * lineArr = (line *) malloc (100 * sizeof(line));
  1219. int * linesAt = (int *) malloc (100 * sizeof(int));
  1220.  
  1221. circle *CircleArr = (circle *)malloc(1000 * sizeof(circle));
  1222. int *CirclesAt = (int *)malloc(100 * sizeof(int));
  1223.  
  1224. filledRect * filledRectArr = (filledRect *) malloc (1000 * sizeof(filledRect));
  1225. int * filledRectsAt = (int *) malloc (100* sizeof(int));
  1226.  
  1227. textBox * textBoxArr= (textBox *) malloc (20 * sizeof (textBox));
  1228. int * textsAt = (int *) malloc (20* sizeof (int));
  1229.  
  1230. }
  1231.  
  1232. int main()
  1233. {
  1234.  
  1235.     iSetTimer(5,animation);
  1236.     iSetTimer(9,animation2);
  1237.     iInitialize(screenwidth, screenheight, "Whitebaord");
  1238.     return 0;
  1239. }
  1240.