Updating built in Io code to use += instead of x = x + y
[io/quag.git] / addons / Cairo / source / IoCairoSolidPattern.c
blob1ff9a0282fd3c7856f7004c6ffe53a540af83f34
1 /*#io
2 CairoSolidPattern ioDoc(
3 docCopyright("Trevor Fancher", 2007)
4 docCopyright("Daniel Rosengren", 2007)
5 docLicense("BSD revised")
6 docCategory("Graphics")
7 */
9 #include "IoCairoSolidPattern.h"
10 #include "IoCairoPattern.h"
11 #include "IoCairoPattern_inline.h"
12 #include "tools.h"
15 static IoTag *IoCairoSolidPattern_newTag(void *state)
17 IoTag *tag = IoTag_newWithName_("SolidPattern");
18 IoTag_state_(tag, state);
19 IoTag_cloneFunc_(tag, (IoTagCloneFunc *)IoCairoSolidPattern_rawClone);
20 IoTag_freeFunc_(tag, (IoTagFreeFunc *)IoCairoPattern_free);
21 return tag;
24 IoCairoSolidPattern *IoCairoSolidPattern_proto(void *state)
26 IoObject *self = IoObject_new(state);
27 IoObject_tag_(self, IoCairoSolidPattern_newTag(state));
29 IoState_registerProtoWithFunc_(state, self, IoCairoSolidPattern_proto);
31 IoCairoPattern_addMethods(self);
33 IoMethodTable methodTable[] = {
34 {"create", IoCairoSolidPattern_create},
35 {"getRGBA", IoCairoSolidPattern_getRGBA},
36 {NULL, NULL},
38 IoObject_addMethodTable_(self, methodTable);
40 return self;
43 IoCairoSolidPattern *IoCairoSolidPattern_rawClone(IoCairoSolidPattern *proto)
45 IoObject *self = IoObject_rawClonePrimitive(proto);
46 if (PATTERN(proto))
47 IoObject_setDataPointer_(self, cairo_pattern_reference(PATTERN(proto)));
48 return self;
51 /* ----------------------------------------------------------- */
53 IoObject *IoCairoSolidPattern_create(IoCairoSolidPattern *self, IoObject *locals, IoMessage *m)
55 double r = IoMessage_locals_doubleArgAt_(m, locals, 0);
56 double g = IoMessage_locals_doubleArgAt_(m, locals, 1);
57 double b = IoMessage_locals_doubleArgAt_(m, locals, 2);
58 double a = 1.0;
59 if (IoMessage_argCount(m) > 3)
60 a = IoMessage_locals_doubleArgAt_(m, locals, 3);
62 return IoCairoPattern_newWithRawPattern_(IOSTATE, m, cairo_pattern_create_rgba(r, g, b, a));
65 IoObject *IoCairoSolidPattern_getRGBA(IoCairoSolidPattern *self, IoObject *locals, IoMessage *m)
67 double color[4];
68 cairo_pattern_get_rgba(PATTERN(self), &color[0], &color[1], &color[2], &color[3]);
69 return IoSeq_newWithDoubles_count_(IOSTATE, color, 4);