void BubbleEllipse::writeImage() const { int fontsize = static_cast<int>(font->size);//todo bgcolor->use(); imlib_image_fill_ellipse(centerx, centery, radiusx-1, radiusy-1); // Wähle die Höhe der 1. Zeile so, dass das 1. Wort gerade hineinpasst. int width, height; unsigned first_idx = text.find(' '); string first_word = (first_idx != string::npos) ? text.substr(0,first_idx) : text; font->use(); imlib_get_text_size(first_word.c_str(), &width, &height); height = -radiusy; do { height++; //printf("%s of width %d does not fit into width %d, increase h to %d\n", //first_word.c_str(), width, ellipseWidth(radiusx, radiusy, abs(height)), height); } while (ellipseWidth(radiusx, radiusy, abs(height)) < width && height <= 0); height += fontsize/3; // Schreibe den Text nacheinander in die Zeilen. string rest = text; while(rest.length() > 0) { if (height > radiusy-2) { std::cerr<< "Error: text does not fit, aborting: "<< text <<".\n"; break; } width = ellipseWidth(radiusx, radiusy, abs(height)); rest = drawTextLine(centerx-width/2, centery+height, rest, width, height/(float)radiusx); height += fontsize*1.7; } }
static inline PyObject * ImageObject_draw_ellipse(PyObject* self, PyObject *args, PyObject *kwargs) { int xc, yc, a, b; int red=-1, green, blue, alpha, fill=0; static char *keywords[] = {"xc", "yc", "a", "b", "color", "fill", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iiii|(iiii)i:draw_ellipsm", keywords, &xc, &yc, &a, &b, &red, &green, &blue, &alpha, &fill)){ return NULL; } imlib_context_set_image(((ImageObject *)self)->image); if(red >= 0){ //set color imlib_context_set_color(red, green, blue, alpha); } if(fill){ imlib_image_fill_ellipse(xc, yc, a, b); }else{ imlib_image_draw_ellipse(xc, yc, a, b); } Py_RETURN_NONE; }