summaryrefslogtreecommitdiff
path: root/html/download/simple.c
blob: ba5faf9795293367878873870101af818ae6748d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
/*

  Simple Draw Application

  Shows the same picture on several canvas. Used to quick test the CD library and
  to demonstrate the use of CD library functions.

  This module uses only the CD library, there is another module to initialize the Window and its menus.

*/


#include "cd.h"
#include "cdnative.h"
#include "cdcgm.h"
#include "cddgn.h"
#include "cddxf.h"
#include "cdclipbd.h"
#include "cdemf.h"
#include "cdimage.h"
#include "cdirgb.h"
#include "cdmf.h"
#include "cdprint.h"
#include "cdps.h"
#include "cdwmf.h"

#include "simple.h"

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>

/* A small pattern and stipple size */
#define SIZE 20

/* Global variables */

cdCanvas *myCanvas = NULL;        /* The window drawing canvas */
cdContext* simple_drv = NULL;     /* The window driver */
char* simple_data = NULL;         /* The window driver data */

int clipping;                     /* Clipping flag, same as the CD */
int write_mode;                   /* Write Mode flag, same as the CD */

long pattern[SIZE*SIZE];          /* Pattern buffer */
unsigned char stipple[SIZE*SIZE]; /* Stipple buffer */
unsigned char red[100*100];       /* Red image buffer */
unsigned char green[100*100];     /* Green image buffer */
unsigned char blue[100*100];      /* Blue image buffer */
unsigned char alpha[100*100];     /* Alpha image buffer */


/* Prototype of the function that makes the drawing independent of canvas. */
void SimpleDraw(void);


void SimpleCreateCanvas(cdContext* drv, char* data)
{
  int c, l;

  simple_drv = drv;
  simple_data = data;

  /* creates the canvas based in an existing window */
  myCanvas = cdCreateCanvas(drv, data);
  clipping = CD_CLIPOFF;
  write_mode = CD_REPLACE;

  /* initialize the pattern buffer with a grey degrade */
  for (l = 0; l < SIZE; l++)
    for (c = 0; c < SIZE; c++)
    {
      unsigned char gray = (unsigned char)((l * 255) / (SIZE - 1));
      pattern[l*20 + c] = cdEncodeColor(gray, gray, gray);
    }

  /* initialize the stipple buffer with cross pattern */
  for (l = 0; l < SIZE; l++)
    for (c = 0; c < SIZE; c++)
      stipple[l*SIZE + c] = (c % 4) == 0? 1: 0;

  /* initialize the alpha image buffer with a degrade from transparent to opaque */
  for (l = 0; l < 100; l++)
    for (c = 0; c < 100; c++)
      alpha[l*100 + c] = (unsigned char)c;
}

int SimplePlayClipboard(void)
{
  /* interprets the contents of the clipboard */
  int w, h;
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdGetCanvasSize(&w, &h, 0, 0);
  cdPlay(CD_CLIPBOARD, 100, w-100, 100, h-100, NULL);
  return 0;
}

int SimplePlayCGMBin(void)
{
  /* interprets the contents of the CGM file */
  int w, h;
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdGetCanvasSize(&w, &h, 0, 0);
  cdPlay(CD_CGM, 100, w-100, 100, h-100, "simple_b.cgm");
  return 0;
}


int SimplePlayCGMText(void)
{
  /* interprets the contents of the CGM file */
  int w, h;
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdGetCanvasSize(&w, &h, 0, 0);
  cdPlay(CD_CGM, 100, w-100, 100, h-100, "simple_t.cgm");
  return 0;
}


int SimplePlayMetafile(void)
{
  int w, h;
  /* interprets the contents of the CD Metafile */
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdGetCanvasSize(&w, &h, 0, 0);
  cdPlay(CD_METAFILE, 100, w-100, 100, h-100, "simple.cdmf");
  return 0;
}

int SimplePlayWMF(void)
{
  int w, h;
  /* interprets the contents of the WMF file */
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdGetCanvasSize(&w, &h, 0, 0);
  cdPlay(CD_WMF, 100, w-100, 100, h-100, "simple.wmf");
  return 0;
}

int SimplePlayEMF(void)
{
  int w, h;
  /* interprets the contents of the EMF file */
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdGetCanvasSize(&w, &h, 0, 0);
  cdPlay(CD_EMF, 100, w-100, 100, h-100, "simple.emf");
  return 0;
}

int SimpleDrawWindow(void)
{
  /* draws in the window */
  cdActivate(myCanvas);
  SimpleDraw();
  return 0;
}

int SimpleDrawCGMText(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "simple_t.cgm %gx%g 1 -t", (double)w, (double)h);

  /* draws in the CGM file */
  tmpCanvas = cdCreateCanvas(CD_CGM, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawCGMBin(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "simple_b.cgm %gx%g", (double)w, (double)h);

  /* draws in the CGM file */
  tmpCanvas = cdCreateCanvas(CD_CGM, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawDXF(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "simple.dxf %gx%g", (double)w, (double)h);

  /* draws in the DXF file */
  tmpCanvas = cdCreateCanvas(CD_DXF, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawDGN(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "simple.dgn %gx%g", (double)w, (double)h);

  /* draws in the DGN file */
  tmpCanvas = cdCreateCanvas(CD_DGN, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawEMF(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "simple.emf %dx%d", w, h);

  /* draws in the EMF file */
  tmpCanvas = cdCreateCanvas(CD_EMF, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawMetafile(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "simple.cdmf %gx%g", (double)w, (double)h);

  /* draws in the CD Metafile */
  tmpCanvas = cdCreateCanvas(CD_METAFILE, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawPS(void)
{
  /* draws in the PS file */
  cdCanvas* tmpCanvas = cdCreateCanvas(CD_PS, "simple.ps");
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawEPS(void)
{
  /* draws in the EPS file */
  cdCanvas* tmpCanvas = cdCreateCanvas(CD_PS, "simple.eps -e");
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawWMF(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "simple.wmf %dx%d", w, h);

  /* draws in the WMF file */
  tmpCanvas = cdCreateCanvas(CD_WMF, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawPrint(void)
{
  /* draws in the Printer canvas */
  cdCanvas* tmpCanvas = cdCreateCanvas(CD_PRINTER, "simple");
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawPrintDialog(void)
{
  /* draws in the Printer canvas, but first shows the printer dialog */
  cdCanvas* tmpCanvas = cdCreateCanvas(CD_PRINTER, "simple -d");
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawClipboardBitmap(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "%dx%d -b", w, h);

  /* draws in the CLipboard canvas as a bitmap */
  tmpCanvas = cdCreateCanvas(CD_CLIPBOARD, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawClipboardMetafile(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "%dx%d -m", w, h);

  /* draws in the CLipboard canvas as a metafile */
  tmpCanvas = cdCreateCanvas(CD_CLIPBOARD, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleDrawClipboardWMFEMF(void)
{
  char StrData[100];
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);
  sprintf(StrData, "%dx%d", w, h);

  /* draws in the CLipboard canvas as a metafile */
  tmpCanvas = cdCreateCanvas(CD_CLIPBOARD, StrData);
  if (tmpCanvas == NULL) return 0;
  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);
  return 0;
}

int SimpleReplace(void)
{
  write_mode = CD_REPLACE;
  cdActivate(myCanvas);
  SimpleDraw();
  return 0;
}

int SimpleXor(void)
{
  write_mode = CD_XOR;
  cdActivate(myCanvas);
  SimpleDraw();
  return 0;
}

int SimpleNotXor(void)
{
  write_mode = CD_NOT_XOR;
  cdActivate(myCanvas);
  SimpleDraw();
  return 0;
}

int SimpleClippingOff(void)
{
  clipping = CD_CLIPOFF;
  cdActivate(myCanvas);
  SimpleDraw();
  return 0;
}

int SimpleClippingArea(void)
{
  clipping = CD_CLIPAREA;
  cdActivate(myCanvas);
  SimpleDraw();
  return 0;
}

int SimpleClippingPolygon(void)
{
  clipping = CD_CLIPPOLYGON;
  cdActivate(myCanvas);
  SimpleDraw();
  return 0;
}

int SimpleDrawImage(void)
{
  void* myImage;
  int w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);

  myImage = cdCreateImage(w, h);
  if (myImage == NULL) return 0;

  /* draws in the Server Image canvas */
  tmpCanvas = cdCreateCanvas(CD_IMAGE, myImage);
  if (tmpCanvas == NULL)
  {
    cdKillImage(myImage);
    return 0;
  }

  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);

  /* transfer the contents of the image to the window canvas */
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdPutImage(myImage, 0, 0);

  cdKillImage(myImage);
  return 0;
}

int SimpleDrawImageRGB(void)
{
  char StrData[100];
  unsigned char *r, *g, *b;
  int size, w, h;
  cdCanvas* tmpCanvas;
  cdActivate(myCanvas);
  cdGetCanvasSize(&w, &h, 0, 0);

  size = w * h;
  r = (unsigned char*)malloc(size);
  if (r == NULL) return 0;
  
  g = (unsigned char*)malloc(size);
  if (g == NULL)
  {
    free(g);
    return 0;
  }

  b = (unsigned char*)malloc(size);
  if (b == NULL) 
  {
    free(r);
    free(g);
    return 0;
  }

  sprintf(StrData, "%dx%d %p %p %p", w, h, r, g, b);

  /* draws in the Client Image canvas */
  tmpCanvas = cdCreateCanvas(CD_IMAGERGB, StrData);
  if (tmpCanvas == NULL)
  {
    free(r);
    free(g);
    free(b);
    return 0;
  }

  cdActivate(tmpCanvas);
  SimpleDraw();
  cdKillCanvas(tmpCanvas);

  /* transfer the contents of the image to the window canvas */
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();
  cdPutImageRGB(w, h, r, g, b, 0, 0, w, h);

  free(r);
  free(g);
  free(b);
  return 0;
}

int SimpleDrawSimulate(void)
{
  cdActivate(myCanvas);
  cdBackground(CD_WHITE);
  cdClear();

  cdSimulate(CD_SIM_ALL);

  SimpleDraw();

  cdSimulate(CD_SIM_NONE);
  
  return 0;
}

void SimpleKillCanvas(void)
{
  if (myCanvas != NULL)
  {
    cdKillCanvas(myCanvas);
    myCanvas = NULL;
  }
}


static void SimpleDraw(void)
{
  int w, h;

  cdGetCanvasSize(&w, &h, 0, 0);

  switch(clipping)
  {
  case CD_CLIPOFF:
    cdClip(CD_CLIPOFF);
    break;
  case CD_CLIPAREA:
    /* Defines the clipping area equals the canvas area minus a 100 pixels margin. */
    cdClipArea(100, w - 100, 100, h - 100);
    cdClip(CD_CLIPAREA);
    break;
  case CD_CLIPPOLYGON:
    cdBegin(CD_CLIP);
    cdVertex(100, 100);
    cdVertex(w - 100, 100);
    cdVertex(w / 2, h - 100);
    cdEnd();
    cdClip(CD_CLIPPOLYGON);
    break;
  }

  switch(write_mode)
  {
  case CD_REPLACE:
    cdWriteMode(CD_REPLACE);
    break;
  case CD_XOR:
    cdWriteMode(CD_XOR);
    break;
  case CD_NOT_XOR:
    cdWriteMode(CD_NOT_XOR);
    break;
  }

  /* Clear the background to be white */
  cdInteriorStyle(CD_SOLID);
  cdBackground(CD_WHITE);
  cdClear();
                            
  cdForeground(CD_RED);
  cdLineWidth(1);
  cdLineStyle(CD_DASHED);
  cdLine(0, 0, w, h);

  cdForeground(CD_BLUE);
  cdLineWidth(10);
  cdLineStyle(CD_DOTTED);
  cdLine(0, h, w, 0);

  cdLineStyle(CD_CONTINUOUS);
  cdLineWidth(1);

  cdForeground(CD_GREEN);
  cdArc(100, 100, 100, 100, 0, 180);
  cdSector(w - 100, 100, 100, 100, 0, 180);

  cdForeground(CD_YELLOW);
  cdBox(w/2 - 100, w/2 + 100, h/2 - 100, h/2 + 100); 

  /* transparent text */
  cdForeground(CD_BLUE);
  cdBackOpacity(CD_TRANSPARENT); 
  cdTextAlignment(CD_CENTER);
  cdFont(CD_TIMES_ROMAN, CD_BOLD, 24);
  cdText(w/2, h/2, "Simple Draw");

  /* draws all the mark type possibilities */
  cdForeground(CD_RED);
  cdMarkSize(30);
  cdMarkType(CD_PLUS);
  cdMark(200, 200);
  cdMarkType(CD_CIRCLE);
  cdMark(w - 200, 200);
  cdMarkType(CD_HOLLOW_CIRCLE);
  cdMark(200, h - 200);
  cdMarkType(CD_DIAMOND);
  cdMark(w - 200, h - 200);

  /* draws all the line style possibilities */
  cdLineWidth(1);
  cdLineStyle(CD_CONTINUOUS);
  cdLine(0, 10, w, 10);
  cdLineStyle(CD_DASHED);
  cdLine(0, 20, w, 20);
  cdLineStyle(CD_DASH_DOT);
  cdLine(0, 30, w, 30);
  cdLineStyle(CD_DASH_DOT_DOT);
  cdLine(0, 40, w, 40);

  /* draws all the hatch style possibilities */
  cdInteriorStyle(CD_HATCH);
  cdHatch(CD_VERTICAL); 
  cdBox(0, 50, h - 60, h);
  cdHatch(CD_FDIAGONAL); 
  cdBox(50, 100, h - 60, h);
  cdHatch(CD_BDIAGONAL); 
  cdBox(100, 150, h - 60, h);
  cdHatch(CD_CROSS); 
  cdBox(150, 200, h - 60, h);
  cdHatch(CD_HORIZONTAL); 
  cdBox(200, 250, h - 60, h);
  cdHatch(CD_DIAGCROSS); 
  cdBox(250, 300, h - 60, h);

  /* closed polygon */
  cdBegin(CD_CLOSED_LINES);
  cdVertex(w/2, h - 100); 
  cdVertex(w/2 + 50, h - 150); 
  cdVertex(w/2, h - 200); 
  cdVertex(w/2 - 50, h - 150); 
  cdEnd();

  /* hatch filled polygon */
  cdInteriorStyle(CD_HATCH);
  cdHatch(CD_DIAGCROSS); 

  cdBegin(CD_FILL);
  cdVertex(100, h/2); 
  cdVertex(150, h/2 + 50); 
  cdVertex(200, h/2); 
  cdVertex(150, h/2 - 50); 
  cdEnd();

  /* pattern filled polygon */
  cdInteriorStyle(CD_PATTERN);
  cdPattern(SIZE, SIZE, pattern);

  cdBegin(CD_FILL);
  cdVertex(w - 100, h/2); 
  cdVertex(w - 150, h/2 + 50); 
  cdVertex(w - 200, h/2); 
  cdVertex(w - 150, h/2 - 50); 
  cdEnd();
  
  /* stipple filled polygon */
  cdInteriorStyle(CD_STIPPLE);
  cdStipple(SIZE, SIZE, stipple);

  cdBegin(CD_FILL);
  cdVertex(w/2, 100); 
  cdVertex(w/2 + 50, 150); 
  cdVertex(w/2, 200); 
  cdVertex(w/2 - 50, 150); 
  cdEnd();


  /* always clear the image buffer contents */
  memset(red, 0xFF, 100*100);
  memset(green, 0xFF, 100*100);
  memset(blue, 0xFF, 100*100);

  cdGetImageRGB(red, green, blue, w - 200, 100, 100, 100);
  cdPutImageRGB(100, 100, red, green, blue, 100, h - 200, 100, 100);
  cdPutImageRGBA(100, 100, red, green, blue, alpha, w - 300, h - 300, 200, 200);
}