static bool HHVM_METHOD(ImagickDraw, setFontFamily, const String& font_family) { auto wand = getDrawingWandResource(Object{this_}); if (font_family.empty()) { IMAGICKDRAW_THROW("Can not set empty font family"); } auto status = DrawSetFontFamily(wand->getWand(), font_family.c_str()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to set font family"); } return true; }
static bool HHVM_METHOD(ImagickDraw, setFont, const String& font_name) { auto wand = getDrawingWandResource(Object{this_}); if (font_name.empty()) { IMAGICKDRAW_THROW("Can not set empty font"); } auto font = magickResolveFont(font_name); if (font.isNull()) { IMAGICKDRAW_THROW("Unable to set font, file path expansion failed"); } auto status = DrawSetFont(wand->getWand(), font.c_str()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to set font"); } return true; }
static bool HHVM_METHOD(ImagickDraw, push) { auto wand = getDrawingWandResource(Object{this_}); auto status = PushDrawingWand(wand->getWand()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to push the current ImagickDraw object"); } return true; }
static void HHVM_METHOD(ImagickDraw, __construct) { auto wand = NewDrawingWand(); if (wand == nullptr) { IMAGICKDRAW_THROW("Failed to create ImagickDraw object"); } else { setWandResource(s_ImagickDraw, Object{this_}, wand); } }
static bool HHVM_METHOD(ImagickDraw, popPattern) { auto wand = getDrawingWandResource(Object{this_}); auto status = DrawPopPattern(wand->getWand()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to terminate the pattern definition"); } return true; }
static void HHVM_METHOD(ImagickDraw, __clone) { auto wand = getDrawingWandResource(Object{this_}); auto newWand = CloneDrawingWand(wand->getWand()); if (newWand == nullptr) { IMAGICKDRAW_THROW("Failed to allocate DrawingWand structure"); } else { setWandResource(s_ImagickDraw, Object{this_}, newWand); } }
static bool HHVM_METHOD(ImagickDraw, setStrokePatternURL, const String& stroke_url) { auto wand = getDrawingWandResource(Object{this_}); auto status = DrawSetStrokePatternURL(wand->getWand(), stroke_url.c_str()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to set stroke pattern URL"); } return true; }
static bool HHVM_METHOD(ImagickDraw, setVectorGraphics, const String& xml) { auto wand = getDrawingWandResource(Object{this_}); auto status = DrawSetVectorGraphics(wand->getWand(), xml.c_str()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to set the vector graphics"); } return true; }
static bool HHVM_METHOD(ImagickDraw, setFillPatternURL, const String& fill_url) { auto wand = getDrawingWandResource(this_); auto status = DrawSetFillPatternURL(wand->getWand(), fill_url.c_str()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to set fill pattern URL"); } return true; }
static bool HHVM_METHOD(ImagickDraw, setClipPath, const String& clip_mask) { auto wand = getDrawingWandResource(Object{this_}); auto status = DrawSetClipPath(wand->getWand(), clip_mask.c_str()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to set clipping path"); } return true; }
static bool HHVM_METHOD(ImagickDraw, setStrokeDashArray, const Array& dashArray) { auto wand = getDrawingWandResource(Object{this_}); auto dashes = toDoubleArray(dashArray); if (dashes.empty()) { IMAGICKDRAW_THROW("Cannot read stroke dash array parameter"); } DrawSetStrokeDashArray(wand->getWand(), dashes.size(), dashes.data()); return true; }
static bool HHVM_METHOD(ImagickDraw, setFontWeight, int64_t font_weight) { auto wand = getDrawingWandResource(Object{this_}); if (100 <= font_weight && font_weight <= 900) { DrawSetFontWeight(wand->getWand(), font_weight); return true; } else { IMAGICKDRAW_THROW("Font weight valid range is 100-900"); } }
static bool HHVM_METHOD(ImagickDraw, bezier, const Array& coordinates) { auto wand = getDrawingWandResource(Object{this_}); auto points = toPointInfoArray(coordinates); if (points.empty()) { IMAGICKDRAW_THROW("Unable to read coordinate array"); } DrawBezier(wand->getWand(), points.size(), points.data()); return true; }
static bool HHVM_METHOD(ImagickDraw, render) { auto wand = getDrawingWandResource(Object{this_}); auto status = withMagickLocaleFix([&wand]{ return DrawRender(wand->getWand()); }); if (status == MagickFalse) { IMAGICKDRAW_THROW("Unable to render the drawing commands"); } return true; }
////////////////////////////////////////////////////////////////////////////// // class ImagickDraw ALWAYS_INLINE static void getAffineMatrixElement( const Array& array, const String& key, double& ret) { const Variant& value = array.rvalAtRef(key); if (value.isNull()) { IMAGICKDRAW_THROW( "AffineMatrix must contain keys: sx, rx, ry, sy, tx and ty"); } else { ret = value.toDouble(); } }
////////////////////////////////////////////////////////////////////////////// // class ImagickDraw ALWAYS_INLINE static void getAffineMatrixElement( const Array& array, const String& key, double& ret) { auto const value = array.rvalAt(key).unboxed(); if (isNullType(value.type())) { IMAGICKDRAW_THROW( "AffineMatrix must contain keys: sx, rx, ry, sy, tx and ty"); } else { ret = cellToDouble(value.tv()); } }
static bool HHVM_METHOD(ImagickDraw, composite, int64_t compose, double x, double y, double width, double height, const Object& compositeWand) { auto wand = getDrawingWandResource(Object{this_}); Object compositeWandObj(compositeWand); auto magick = getMagickWandResource(compositeWandObj); auto status = DrawComposite(wand->getWand(), (CompositeOperator)compose, x, y, width, height, magick->getWand()); if (status == MagickFalse) { IMAGICKDRAW_THROW("Compositing image failed"); } return true; }
static bool HHVM_METHOD(ImagickDraw, setResolution, double x, double y) { auto wand = getDrawingWandResource(Object{this_}); std::ostringstream density; density << x << "x" << y; auto drawInfo = PeekDrawingWand(wand->getWand()); drawInfo->density = AcquireString(density.str().c_str()); auto drawWand = DrawAllocateWand(drawInfo, nullptr); if (drawWand == nullptr) { IMAGICKDRAW_THROW("Failed to allocate new DrawingWand structure"); } setWandResource(s_ImagickDraw, Object{this_}, drawWand); return true; }