mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
ImageMagick wrapper: Add API to get and set stroke and fill colors on a drawing wand
This commit is contained in:
parent
484caafc32
commit
14717a5e92
@ -95,6 +95,26 @@ class DrawingWand(_magick.DrawingWand): # {{{
|
|||||||
self.font_size_ = float(val)
|
self.font_size_ = float(val)
|
||||||
return property(fget=fget, fset=fset, doc=_magick.DrawingWand.font_size_.__doc__)
|
return property(fget=fget, fset=fset, doc=_magick.DrawingWand.font_size_.__doc__)
|
||||||
|
|
||||||
|
@dynamic_property
|
||||||
|
def stroke_color(self):
|
||||||
|
def fget(self):
|
||||||
|
return self.stroke_color_.color
|
||||||
|
def fset(self, val):
|
||||||
|
col = PixelWand()
|
||||||
|
col.color = unicode(val)
|
||||||
|
self.stroke_color_ = col
|
||||||
|
return property(fget=fget, fset=fset, doc=_magick.DrawingWand.font_size_.__doc__)
|
||||||
|
|
||||||
|
@dynamic_property
|
||||||
|
def fill_color(self):
|
||||||
|
def fget(self):
|
||||||
|
return self.fill_color_.color
|
||||||
|
def fset(self, val):
|
||||||
|
col = PixelWand()
|
||||||
|
col.color = unicode(val)
|
||||||
|
self.fill_color_ = col
|
||||||
|
return property(fget=fget, fset=fset, doc=_magick.DrawingWand.font_size_.__doc__)
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class Image(_magick.Image): # {{{
|
class Image(_magick.Image): # {{{
|
||||||
|
@ -263,6 +263,78 @@ magick_DrawingWand_fontsize_setter(magick_DrawingWand *self, PyObject *val, void
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
// DrawingWand.stroke_color {{{
|
||||||
|
static PyObject *
|
||||||
|
magick_DrawingWand_stroke_color_getter(magick_DrawingWand *self, void *closure) {
|
||||||
|
NULL_CHECK(NULL)
|
||||||
|
magick_PixelWand *pw;
|
||||||
|
PixelWand *wand = NewPixelWand();
|
||||||
|
|
||||||
|
if (wand == NULL) return PyErr_NoMemory();
|
||||||
|
DrawGetStrokeColor(self->wand, wand);
|
||||||
|
|
||||||
|
pw = (magick_PixelWand*) magick_PixelWandType.tp_alloc(&magick_PixelWandType, 0);
|
||||||
|
if (pw == NULL) return PyErr_NoMemory();
|
||||||
|
pw->wand = wand;
|
||||||
|
return Py_BuildValue("O", (PyObject *)pw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
magick_DrawingWand_stroke_color_setter(magick_DrawingWand *self, PyObject *val, void *closure) {
|
||||||
|
NULL_CHECK(-1)
|
||||||
|
if (val == NULL) {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "Cannot delete DrawingWand stroke color");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
magick_PixelWand *pw;
|
||||||
|
|
||||||
|
pw = (magick_PixelWand*)val;
|
||||||
|
if (!IsPixelWand(pw->wand)) { PyErr_SetString(PyExc_TypeError, "Invalid PixelWand"); return -1; }
|
||||||
|
|
||||||
|
DrawSetStrokeColor(self->wand, pw->wand);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
// DrawingWand.fill_color {{{
|
||||||
|
static PyObject *
|
||||||
|
magick_DrawingWand_fill_color_getter(magick_DrawingWand *self, void *closure) {
|
||||||
|
NULL_CHECK(NULL)
|
||||||
|
magick_PixelWand *pw;
|
||||||
|
PixelWand *wand = NewPixelWand();
|
||||||
|
|
||||||
|
if (wand == NULL) return PyErr_NoMemory();
|
||||||
|
DrawGetFillColor(self->wand, wand);
|
||||||
|
|
||||||
|
pw = (magick_PixelWand*) magick_PixelWandType.tp_alloc(&magick_PixelWandType, 0);
|
||||||
|
if (pw == NULL) return PyErr_NoMemory();
|
||||||
|
pw->wand = wand;
|
||||||
|
return Py_BuildValue("O", (PyObject *)pw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
magick_DrawingWand_fill_color_setter(magick_DrawingWand *self, PyObject *val, void *closure) {
|
||||||
|
NULL_CHECK(-1)
|
||||||
|
if (val == NULL) {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "Cannot delete DrawingWand fill color");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
magick_PixelWand *pw;
|
||||||
|
|
||||||
|
pw = (magick_PixelWand*)val;
|
||||||
|
if (!IsPixelWand(pw->wand)) { PyErr_SetString(PyExc_TypeError, "Invalid PixelWand"); return -1; }
|
||||||
|
|
||||||
|
DrawSetFillColor(self->wand, pw->wand);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
|
||||||
// DrawingWand.text_antialias {{{
|
// DrawingWand.text_antialias {{{
|
||||||
static PyObject *
|
static PyObject *
|
||||||
magick_DrawingWand_textantialias_getter(magick_DrawingWand *self, void *closure) {
|
magick_DrawingWand_textantialias_getter(magick_DrawingWand *self, void *closure) {
|
||||||
@ -336,6 +408,16 @@ static PyGetSetDef magick_DrawingWand_getsetters[] = {
|
|||||||
(char *)"DrawingWand fontsize",
|
(char *)"DrawingWand fontsize",
|
||||||
NULL},
|
NULL},
|
||||||
|
|
||||||
|
{(char *)"stroke_color_",
|
||||||
|
(getter)magick_DrawingWand_stroke_color_getter, (setter)magick_DrawingWand_stroke_color_setter,
|
||||||
|
(char *)"DrawingWand stroke color",
|
||||||
|
NULL},
|
||||||
|
|
||||||
|
{(char *)"fill_color_",
|
||||||
|
(getter)magick_DrawingWand_fill_color_getter, (setter)magick_DrawingWand_fill_color_setter,
|
||||||
|
(char *)"DrawingWand fill color",
|
||||||
|
NULL},
|
||||||
|
|
||||||
{(char *)"text_antialias",
|
{(char *)"text_antialias",
|
||||||
(getter)magick_DrawingWand_textantialias_getter, (setter)magick_DrawingWand_textantialias_setter,
|
(getter)magick_DrawingWand_textantialias_getter, (setter)magick_DrawingWand_textantialias_setter,
|
||||||
(char *)"DrawingWand text antialias",
|
(char *)"DrawingWand text antialias",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user