aboutsummaryrefslogtreecommitdiff
path: root/modules/pdp_form.c
blob: e0016c857a3a942876195315e50d16eb2db19886 (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
/*
 *   PiDiP module
 *   Copyright (c) by Yves Degoyon (ydegoyon@free.fr)
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*  This object is a geometric forms generator object for PDP
 *  It uses imlib2 for all graphical operations
 */

/*  Listening to :
 *  Culturcide - Bruce
 *  This Heat - Independence
 */

#include "pdp.h"
#include "yuv.h"
#include <math.h>
#include <ctype.h>
#include <Imlib2.h>  // imlib2 is required


/* forms type */
enum _form_type
{
   IMLIB_LINE,
   IMLIB_RECTANGLE,
   IMLIB_ELLIPSE
};
typedef enum _form_type t_form_type;

typedef struct _form
{
    t_form_type type;
    int n1,n2,n3,n4; // numerical coordinates or rays
    int r,g,b;
} t_form;


#define DEFAULT_CAPACITY 10

static char   *pdp_form_version = "pdp_form: version 0.1 : forms rendering object written by ydegoyon@free.fr ";

typedef struct pdp_form_struct
{
    t_object x_obj;
    t_float x_f;

    int x_packet0;
    int x_packet1;
    int x_dropped;
    int x_queue_id;

    t_outlet *x_outlet0;
    int x_vwidth;
    int x_vheight;
    int x_vsize;

    t_form *x_forms;
    int x_nbforms;
    int x_current;
    int x_capacity;
    t_float x_alpha;

        /* imlib data */
    Imlib_Image x_image;

} t_pdp_form;

        /* add a line */
static void pdp_form_line(t_pdp_form *x, t_symbol *s, int argc, t_atom *argv)
{
   if ( x->x_nbforms >= x->x_capacity )
   {
      post( "pdp_form : sorry, maximum capacity has been reached... try resize" );
      return;
   } 
   
   if ( argc < 4 )
   {
      post( "pdp_form : error in the number of arguments ( minimum is 4 )", argc );
      return;
   }
   if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || 
        argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ) {
      post( "pdp_form : add : wrong arguments" );
      return;
   }

   x->x_forms[x->x_nbforms].type = IMLIB_LINE;
   x->x_forms[x->x_nbforms].n1 = (int)argv[0].a_w.w_float;
   x->x_forms[x->x_nbforms].n2 = (int)argv[1].a_w.w_float;
   x->x_forms[x->x_nbforms].n3 = (int)argv[2].a_w.w_float;
   x->x_forms[x->x_nbforms].n4 = (int)argv[3].a_w.w_float;

   if ( (argc>=5) && (argv[4].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].r = (int)argv[4].a_w.w_float;
   }
   if ( (argc>=6) && (argv[5].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].g = (int)argv[5].a_w.w_float;
   }
   if ( (argc>=7) && (argv[6].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].b = (int)argv[6].a_w.w_float;
   }
   
   post( "pdp_form : added line [%d,%d,%d,%d] @ %d (r=%d g=%d b=%d)", 
                x->x_forms[x->x_nbforms].n1, x->x_forms[x->x_nbforms].n2,
                x->x_forms[x->x_nbforms].n3, x->x_forms[x->x_nbforms].n4, x->x_nbforms,
                x->x_forms[x->x_nbforms].r, x->x_forms[x->x_nbforms].g, x->x_forms[x->x_nbforms].b );

   if ( x->x_current == -1 ) x->x_current = x->x_nbforms;
   x->x_nbforms++;
   
}

        /* add a rectangle */
static void pdp_form_rectangle(t_pdp_form *x, t_symbol *s, int argc, t_atom *argv)
{
   if ( x->x_nbforms >= x->x_capacity )
   {
      post( "pdp_form : sorry, maximum capacity has been reached... try resize" );
      return;
   } 
   
   if ( argc < 4 )
   {
      post( "pdp_form : error in the number of arguments ( minimum is 4 )", argc );
      return;
   }
   if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT || 
        argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ) {
      post( "pdp_form : add : wrong arguments" );
      return;
   }

   x->x_forms[x->x_nbforms].type = IMLIB_RECTANGLE;
   x->x_forms[x->x_nbforms].n1 = (int)argv[0].a_w.w_float;
   x->x_forms[x->x_nbforms].n2 = (int)argv[1].a_w.w_float;
   x->x_forms[x->x_nbforms].n3 = (int)argv[2].a_w.w_float;
   x->x_forms[x->x_nbforms].n4 = (int)argv[3].a_w.w_float;

   if ( (argc>=5) && (argv[4].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].r = (int)argv[4].a_w.w_float;
   }
   if ( (argc>=6) && (argv[5].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].g = (int)argv[5].a_w.w_float;
   }
   if ( (argc>=7) && (argv[6].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].b = (int)argv[6].a_w.w_float;
   }
   
   post( "pdp_form : added rectangle [%d,%d,%d,%d] @ %d (r=%d g=%d b=%d)", 
                x->x_forms[x->x_nbforms].n1, x->x_forms[x->x_nbforms].n2,
                x->x_forms[x->x_nbforms].n3, x->x_forms[x->x_nbforms].n4, x->x_nbforms,
                x->x_forms[x->x_nbforms].r, x->x_forms[x->x_nbforms].g, x->x_forms[x->x_nbforms].b );

   if ( x->x_current == -1 ) x->x_current = x->x_nbforms;
   x->x_nbforms++;
   
}

        /* add an ellipse */
static void pdp_form_ellipse(t_pdp_form *x, t_symbol *s, int argc, t_atom *argv)
{
   if ( x->x_nbforms >= x->x_capacity )
   {
      post( "pdp_form : sorry, maximum capacity has been reached... try resize" );
      return;
   } 
   
   if ( argc < 4 )
   {
      post( "pdp_form : error in the number of arguments ( minimum is 4 )", argc );
      return;
   }
   if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT ||
        argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ) {
      post( "pdp_form : add : wrong arguments" );
      return;
   }

   x->x_forms[x->x_nbforms].type = IMLIB_ELLIPSE;
   x->x_forms[x->x_nbforms].n1 = (int)argv[0].a_w.w_float;
   x->x_forms[x->x_nbforms].n2 = (int)argv[1].a_w.w_float;
   x->x_forms[x->x_nbforms].n3 = (int)argv[2].a_w.w_float;
   x->x_forms[x->x_nbforms].n4 = (int)argv[3].a_w.w_float;

   if ( (argc>=5) && (argv[4].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].r = (int)argv[4].a_w.w_float;
   }
   if ( (argc>=6) && (argv[5].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].g = (int)argv[5].a_w.w_float;
   }
   if ( (argc>=7) && (argv[6].a_type == A_FLOAT) )
   {
      x->x_forms[x->x_nbforms].b = (int)argv[6].a_w.w_float;
   }
   
   post( "pdp_form : added ellipse [%d,%d,%d,%d] @ %d (r=%d g=%d b=%d)", 
                x->x_forms[x->x_nbforms].n1, x->x_forms[x->x_nbforms].n2,
                x->x_forms[x->x_nbforms].n3, x->x_forms[x->x_nbforms].n4, x->x_nbforms,
                x->x_forms[x->x_nbforms].r, x->x_forms[x->x_nbforms].g, x->x_forms[x->x_nbforms].b );

   if ( x->x_current == -1 ) x->x_current = x->x_nbforms;
   x->x_nbforms++;
   
}

static void pdp_form_current(t_pdp_form *x, t_floatarg fcurrent )
{
    if ( ( fcurrent >= 0 ) && ( fcurrent < x->x_nbforms ) )
    {
       // post( "pdp_form : current item set to %d", x->x_current );
       x->x_current = fcurrent;
    }
}

static void pdp_form_x1(t_pdp_form *x, t_floatarg fx )
{
    if ( ( x->x_current  >= 0 ) && ( x->x_current  < x->x_nbforms ) )
    {
       x->x_forms[x->x_current].n1 = fx;
    }
}

static void pdp_form_y1(t_pdp_form *x, t_floatarg fy )
{
    if ( ( x->x_current  >= 0 ) && ( x->x_current  < x->x_nbforms ) )
    {
       x->x_forms[x->x_current].n2 = fy;
    }
}

static void pdp_form_x2(t_pdp_form *x, t_floatarg fx )
{
    if ( ( x->x_current  >= 0 ) && ( x->x_current  < x->x_nbforms ) )
    {
       x->x_forms[x->x_current].n3 = fx;
    }
}

static void pdp_form_y2(t_pdp_form *x, t_floatarg fy )
{
    if ( ( x->x_current  >= 0 ) && ( x->x_current  < x->x_nbforms ) )
    {
       x->x_forms[x->x_current].n4 = fy;
    }
}

static void pdp_form_r(t_pdp_form *x, t_floatarg fr )
{
    if ( ( x->x_current  >= 0 ) && ( x->x_current  < x->x_nbforms ) )
    {
       x->x_forms[x->x_current].r = fr;
    }
}

static void pdp_form_g(t_pdp_form *x, t_floatarg fg )
{
    if ( ( x->x_current  >= 0 ) && ( x->x_current  < x->x_nbforms ) )
    {
       x->x_forms[x->x_current].g = fg;
    }
}

static void pdp_form_b(t_pdp_form *x, t_floatarg fb )
{
    if ( ( x->x_current  >= 0 ) && ( x->x_current  < x->x_nbforms ) )
    {
       x->x_forms[x->x_current].b = fb;
    }
}

static void pdp_form_clear(t_pdp_form *x )
{
    x->x_nbforms = 0;
}

static void pdp_form_delete(t_pdp_form *x,  t_floatarg fnum  )
{
  int i;
  char *lostword;

    if ( ( fnum>0 ) && ( fnum<=x->x_nbforms ) )
    {
       for ( i=(int)fnum; i<x->x_nbforms; i++ )
       {
          memcpy( &x->x_forms[ i-1 ], &x->x_forms[ i ], sizeof( t_form ) );
       }
       x->x_nbforms--;
    }
}

static void pdp_form_alpha(t_pdp_form *x, t_floatarg falpha )
{
    if ( ( falpha  >= 0. ) && ( falpha  <= 1. ) )
    {
       x->x_alpha = falpha;
    }
}

static void pdp_form_resize(t_pdp_form *x,  t_floatarg fnewsize  )
{
  t_form *forms;
  int i, csize;

    if ( (int) fnewsize<=0 ) return;

    // allocate new structures
    forms = (t_form*) getbytes( fnewsize*sizeof(t_form) );

    for ( i=0; i<fnewsize; i++ )
    {
       forms[i].r = forms[i].g = forms[i].b = 255;
    }

    if ( fnewsize < x->x_nbforms )
    {
       post( "pdp_form : new size is too small : texts lost !!" );
       csize = fnewsize;
    }
    else
    {
       csize = x->x_nbforms;
    }

    // copy all values
    for ( i=0; i<csize; i++ )
    {
        memcpy( &forms[i], &x->x_forms[i], sizeof( t_form ) );
    }
  
    // free old structures
    if ( x->x_forms ) freebytes( x->x_forms, x->x_capacity*sizeof(t_form) );

    // set new structures
    x->x_forms = forms;
    x->x_nbforms = csize;
    x->x_capacity = fnewsize;
    if ( x->x_nbforms > 0 )
    {
       x->x_current = 0;
    }
    else
    {
       x->x_current = -1;
    }
}

static void pdp_form_allocate(t_pdp_form *x)
{
   x->x_image = imlib_create_image( x->x_vwidth, x->x_vheight );
   if ( x->x_image == NULL )
   {
      post( "pdp_form : severe error : could not allocate image !!" );
   }
   imlib_context_set_image(x->x_image);
}

static void pdp_form_free_ressources(t_pdp_form *x)
{
   // if ( x->x_image != NULL ) imlib_free_image();
}

static void pdp_form_process_yv12(t_pdp_form *x)
{
    t_pdp     *header = pdp_packet_header(x->x_packet0);
    short int *data   = (short int *)pdp_packet_data(x->x_packet0);
    t_pdp     *newheader = pdp_packet_header(x->x_packet1);
    short int *newdata = (short int *)pdp_packet_data(x->x_packet1);
    int     ti;
    int     px, py;
    unsigned char y, u, v;
    DATA32    *imdata;
    DATA32    bgcolor;
    short int *pY, *pU, *pV;

    if ( ( (int)(header->info.image.width) != x->x_vwidth ) ||
         ( (int)(header->info.image.height) != x->x_vheight ) )
    {
         pdp_form_free_ressources(x);
         x->x_vwidth = header->info.image.width;
         x->x_vheight = header->info.image.height;
         x->x_vsize = x->x_vwidth*x->x_vheight;
         pdp_form_allocate(x);
    }

    newheader->info.image.encoding = header->info.image.encoding;
    newheader->info.image.width = x->x_vwidth;
    newheader->info.image.height = x->x_vheight;

    memcpy( newdata, data, (x->x_vsize+(x->x_vsize>>1))<<1 );

    // draw all texts
    if ( x->x_image != NULL ) imlib_context_set_image(x->x_image); 
    imlib_image_clear();
    imlib_context_set_direction(IMLIB_TEXT_TO_ANGLE);
    imdata = imlib_image_get_data();
    bgcolor = imdata[0];

    for (ti=0; ti<x->x_nbforms; ti++)
    {
       imlib_context_set_color( x->x_forms[ti].r, x->x_forms[ti].g, x->x_forms[ti].b, 255 );

       switch ( x->x_forms[ti].type )
       {
          case IMLIB_LINE :
            imlib_image_draw_line( x->x_forms[ti].n1, x->x_forms[ti].n2, x->x_forms[ti].n3, x->x_forms[ti].n4, 1);
            break;

          case IMLIB_RECTANGLE :
            imlib_image_draw_rectangle( x->x_forms[ti].n1, x->x_forms[ti].n2, 
                                        x->x_forms[ti].n3-x->x_forms[ti].n1, x->x_forms[ti].n4-x->x_forms[ti].n2 );
            imlib_image_fill_rectangle( x->x_forms[ti].n1, x->x_forms[ti].n2, 
                                        x->x_forms[ti].n3-x->x_forms[ti].n1, x->x_forms[ti].n4-x->x_forms[ti].n2 );
            break;

          case IMLIB_ELLIPSE :
            imlib_image_draw_ellipse( x->x_forms[ti].n1, x->x_forms[ti].n2, x->x_forms[ti].n3, x->x_forms[ti].n4 );
            imlib_image_fill_ellipse( x->x_forms[ti].n1, x->x_forms[ti].n2, x->x_forms[ti].n3, x->x_forms[ti].n4 );
            break;
       }
    }

    pY = newdata;
    pV = newdata+x->x_vsize;
    pU = newdata+x->x_vsize+(x->x_vsize>>2);
    for ( py=0; py<x->x_vheight; py++ )
    {
       for ( px=0; px<x->x_vwidth; px++ )
       {
          if ( imdata[py*x->x_vwidth+px] != bgcolor )
          {
            y = yuv_RGBtoY(imdata[py*x->x_vwidth+px]);
            u = yuv_RGBtoU(imdata[py*x->x_vwidth+px]);
            v = yuv_RGBtoV(imdata[py*x->x_vwidth+px]);
          
            *(pY) = (y<<7)*x->x_alpha + (*pY)*(1-x->x_alpha);
            if ( (px%2==0) && (py%2==0) )
            {
              *(pV) = ((v-128)<<8)*x->x_alpha + (*pV)*(1-x->x_alpha);
              *(pU) = ((u-128)<<8)*x->x_alpha + (*pU)*(1-x->x_alpha);
            }
          }
          pY++;
          if ( (px%2==0) && (py%2==0) )
          {
            pV++;pU++;
          }
       }
    }

    return;
}

static void pdp_form_sendpacket(t_pdp_form *x)
{
    /* delete source packet */
    pdp_packet_mark_unused(x->x_packet0);
    x->x_packet0 = -1;

    /* unregister and propagate if valid dest packet */
    pdp_packet_pass_if_valid(x->x_outlet0, &x->x_packet1);
}

static void pdp_form_process(t_pdp_form *x)
{
   int encoding;
   t_pdp *header = 0;

   /* check if image data packets are compatible */
   if ( (header = pdp_packet_header(x->x_packet0))
	&& (PDP_IMAGE == header->type)){
    
	/* pdp_form_process inputs and write into active inlet */
	switch(pdp_packet_header(x->x_packet0)->info.image.encoding)
        {

	  case PDP_IMAGE_YV12:
            x->x_packet1 = pdp_packet_clone_rw(x->x_packet0);
            pdp_queue_add(x, pdp_form_process_yv12, pdp_form_sendpacket, &x->x_queue_id);
	    break;

	  case PDP_IMAGE_GREY:
            // should write something to handle these one day
            // but i don't use this mode                      
	    break;

	  default:
	    /* don't know the type, so dont pdp_form_process */
	    break;
	    
	}
    }

}

static void pdp_form_input_0(t_pdp_form *x, t_symbol *s, t_floatarg f)
{

    /* if this is a register_ro message or register_rw message, register with packet factory */

    if (s== gensym("register_rw")) 
       x->x_dropped = pdp_packet_convert_ro_or_drop(&x->x_packet0, (int)f, pdp_gensym("image/YCrCb/*") );

    if ((s == gensym("process")) && (-1 != x->x_packet0) && (!x->x_dropped)){

        /* add the process method and callback to the process queue */
        pdp_form_process(x);

    }

}

static void pdp_form_free(t_pdp_form *x)
{
  int i;

    pdp_form_free_ressources(x);
    pdp_queue_finish(x->x_queue_id);
    pdp_packet_mark_unused(x->x_packet0);
}

t_class *pdp_form_class;

void *pdp_form_new(void)
{
    int i;

    t_pdp_form *x = (t_pdp_form *)pd_new(pdp_form_class);
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("current"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("x1"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("y1"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("x2"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("y2"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("r"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("g"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("b"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("alpha"));

    x->x_outlet0 = outlet_new(&x->x_obj, &s_anything); 
    x->x_packet0 = -1;
    x->x_packet1 = -1;
    x->x_queue_id = -1;
    x->x_image = NULL;

    x->x_capacity = DEFAULT_CAPACITY;

    x->x_forms = (t_form *) getbytes( x->x_capacity*sizeof(t_form) );

    for ( i=0; i<x->x_capacity; i++ )
    {
       x->x_forms[i].r = x->x_forms[i].g = x->x_forms[i].b = 255;
    }

    x->x_nbforms = 0;
    x->x_current = -1;
    x->x_alpha = 1.;

    return (void *)x;
}


#ifdef __cplusplus
extern "C"
{
#endif


void pdp_form_setup(void)
{

    // post( pdp_form_version );
    pdp_form_class = class_new(gensym("pdp_form"), (t_newmethod)pdp_form_new,
    	(t_method)pdp_form_free, sizeof(t_pdp_form), 0, A_NULL);

    class_addmethod(pdp_form_class, (t_method)pdp_form_input_0, gensym("pdp"),  
                             A_SYMBOL, A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_line, gensym("line"),  A_GIMME, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_rectangle, gensym("rectangle"),  A_GIMME, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_ellipse, gensym("ellipse"),  A_GIMME, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_current, gensym("current"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_x1, gensym("x1"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_y1, gensym("y1"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_x2, gensym("x2"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_y2, gensym("y2"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_r, gensym("r"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_g, gensym("g"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_b, gensym("b"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_clear, gensym("clear"),  A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_delete, gensym("delete"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_resize, gensym("resize"),  A_DEFFLOAT, A_NULL);
    class_addmethod(pdp_form_class, (t_method)pdp_form_alpha, gensym("alpha"),  A_DEFFLOAT, A_NULL);


}

#ifdef __cplusplus
}
#endif