2 CairoSolidPattern ioDoc(
3 docCopyright("Trevor Fancher", 2007)
4 docCopyright("Daniel Rosengren", 2007)
5 docLicense("BSD revised")
6 docCategory("Graphics")
9 #include "IoCairoSolidPattern.h"
10 #include "IoCairoPattern.h"
11 #include "IoCairoPattern_inline.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
);
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
},
38 IoObject_addMethodTable_(self
, methodTable
);
43 IoCairoSolidPattern
*IoCairoSolidPattern_rawClone(IoCairoSolidPattern
*proto
)
45 IoObject
*self
= IoObject_rawClonePrimitive(proto
);
47 IoObject_setDataPointer_(self
, cairo_pattern_reference(PATTERN(proto
)));
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);
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
)
68 cairo_pattern_get_rgba(PATTERN(self
), &color
[0], &color
[1], &color
[2], &color
[3]);
69 return IoSeq_newWithDoubles_count_(IOSTATE
, color
, 4);