Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully integrate DrawingWand C-API #194

Merged
merged 37 commits into from Feb 20, 2015
Merged

Conversation

@emcconville
Copy link
Owner

@emcconville emcconville commented Sep 14, 2014

Originally a PU for adding a few methods I needed for whatever project, this drawing_pu turned into a general effort to integrate all ImageMagick's drawing wand methods. This request is open for code-review, feedback, and improved documents.

Drawing API Integration Status

  • ClearDrawingWand
  • CloneDrawingWand
  • DestroyDrawingWand
  • DrawAffine
  • DrawAnnotation
  • DrawArc
  • DrawBezier
  • DrawCircle
  • DrawClearException
  • DrawComposite
  • DrawColor
  • DrawComment
  • DrawEllipse
  • DrawGetBorderColor
  • DrawGetClipPath
  • DrawGetClipRule
  • DrawGetClipUnits
  • DrawGetException
  • DrawGetExceptionType (Never needed as python manages exceptions)
  • DrawGetFillColor
  • DrawGetFillOpacity
  • DrawGetFillRule
  • DrawGetFont
  • DrawGetFontFamily
  • DrawGetFontResolution
  • DrawGetFontSize
  • DrawGetFontStretch
  • DrawGetFontStyle
  • DrawGetFontWeight
  • DrawGetGravity
  • DrawGetOpacity
  • DrawGetStrokeAntialias
  • DrawGetStrokeColor
  • DrawGetStrokeDashArray
  • DrawGetStrokeDashOffset
  • DrawGetStrokeLineCap
  • DrawGetStrokeLineJoin
  • DrawGetStrokeMiterLimit
  • DrawGetStrokeOpacity
  • DrawGetStrokeWidth
  • DrawGetTextAlignment
  • DrawGetTextAntialias
  • DrawGetTextDecoration
  • DrawGetTextDirection
  • DrawGetTextEncoding
  • DrawGetTextKerning
  • DrawGetTextInterlineSpacing
  • DrawGetTextInterwordSpacing
  • DrawGetVectorGraphics
  • DrawGetTextUnderColor
  • DrawLine
  • DrawMatte
  • DrawPathClose
  • DrawPathCurveToAbsolute
  • DrawPathCurveToRelative
  • DrawPathCurveToQuadraticBezierAbsolute
  • DrawPathCurveToQuadraticBezierRelative
  • DrawPathCurveToQuadraticBezierSmoothAbsolute
  • DrawPathCurveToQuadraticBezierSmoothRelative
  • DrawPathCurveToSmoothAbsolute
  • DrawPathCurveToSmoothRelative
  • DrawPathEllipticArcAbsolute
  • DrawPathEllipticArcRelative
  • DrawPathFinish
  • DrawPathLineToAbsolute
  • DrawPathLineToRelative
  • DrawPathLineToHorizontalAbsolute
  • DrawPathLineToHorizontalRelative
  • DrawPathLineToVerticalAbsolute
  • DrawPathLineToVerticalRelative
  • DrawPathMoveToAbsolute
  • DrawPathMoveToRelative
  • DrawPathStart
  • DrawPoint
  • DrawPolygon
  • DrawPolyline
  • DrawPopClipPath
  • DrawPopDefs
  • DrawPopPattern
  • DrawPushClipPath
  • DrawPushDefs
  • DrawPushPattern
  • DrawRectangle
  • DrawResetVectorGraphics
  • DrawRotate
  • DrawRoundRectangle (Integrate with rectangle method)
  • DrawScale
  • DrawSetBorderColor
  • DrawSetClipPath
  • DrawSetClipRule
  • DrawSetClipUnits
  • DrawSetFillColor
  • DrawSetFillOpacity
  • DrawSetFontResolution
  • DrawSetOpacity
  • DrawSetFillPatternURL
  • DrawSetFillRule
  • DrawSetFont
  • DrawSetFontFamily
  • DrawSetFontSize
  • DrawSetFontStretch
  • DrawSetFontStyle
  • DrawSetFontWeight
  • DrawSetGravity
  • DrawSetStrokeColor
  • DrawSetStrokePatternURL
  • DrawSetStrokeAntialias
  • DrawSetStrokeDashArray
  • DrawSetStrokeDashOffset
  • DrawSetStrokeLineCap
  • DrawSetStrokeLineJoin
  • DrawSetStrokeMiterLimit
  • DrawSetStrokeOpacity
  • DrawSetStrokeWidth
  • DrawSetTextAlignment
  • DrawSetTextAntialias
  • DrawSetTextDecoration
  • DrawSetTextDirection
  • DrawSetTextEncoding
  • DrawSetTextKerning
  • DrawSetTextInterlineSpacing
  • DrawSetTextInterwordSpacing
  • DrawSetTextUnderColor
  • DrawSetVectorGraphics
  • DrawSkewX
  • DrawSkewY
  • DrawTranslate
  • DrawSetViewbox
  • IsDrawingWand
  • NewDrawingWand
  • ~~~PeekDrawingWand~~~ (requires building DrawInfo struct, and this is not helpful until other drawing-info methods are exposed to the C-API)
  • PopDrawingWand
  • PushDrawingWand

Original PU Overview

  • Created PointInfo struct reference in API type casting.
  • Assigned / mapped arguments for wand library methods.
  • Completed initial unit test & documentation.

Examples

Drawing.polygon

with Image(filename="crosshatch.png") as img:
    with Drawing() as draw:
        draw.fill_color = Color("#fff")
        draw.stroke_color = Color("#000")
        draw.stroke_width = 2
        points = [(5,5),(45,40),(45,10),(5,45)]
        draw.polygon(points)
        draw.draw(img)
        img.save(filename="polygon.png")

Drawing.polygon

Drawing.polyline

with Image(filename="crosshatch.png") as img:
    with Drawing() as draw:
        draw.fill_color = Color("transparent")
        draw.stroke_color = Color("#000")
        draw.stroke_width = 2
        points = [(5,5),(45,40),(45,10),(5,45)]
        draw.polyline(points)
        draw.draw(img)
        img.save(filename="polyline.png")

Drawing.polyline

Drawing.bezier

with Image(filename="crosshatch.png") as img:
    with Drawing() as draw:
        draw.fill_color = Color("transparent")
        draw.stroke_color = Color("#000")
        draw.stroke_width = 2
        points = [(5,5), (0,50), (50,0), (45,45)]
        draw.bezier(points)
        draw.draw(img)
        img.save(filename="bezier.png")

Drawing.bezier

@coveralls
Copy link

@coveralls coveralls commented Sep 14, 2014

Coverage Status

Coverage increased (+0.14%) when pulling f905d8f on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@emcconville emcconville changed the title Drawing pu Added support for drawing Polygone, Polyline, and Bezier curves Sep 14, 2014
frewsxcv and others added 25 commits Aug 24, 2014
 - Created PointInfo struct reference in API type casting.
 - Assigned / mapped arguments for Draw(bezier|poly(gon|line)) library method.
 - Completed initial unit test & documentation.
 - Arc
 - Circle
 - Ellipse
 - Point

Light refactoring of docs & method signature order.
…ble are likely to change.

 - Drawing.path_close
 - Drawing.path_curve
 - Drawing.path_curve_to_quadratic_bezier
 - Drawing.path_elliptic_arc
 - Drawing.path_finish
 - Drawing.path_line
 - Drawing.path_horizontal_line
 - Drawing.path_vertical_line
 - Drawing.path_move
 - Drawing.path_start
 - Fill & stroke properties
 - Color & Matte
 - Basic coordinate skew & translation
- Drawing wand Push/Pop
- Pattern Push/Pop (needs testing)
- Clip path Push/Pop (needs testing)
- Definitions Push/Pop (needs testing)
 - Drawing.font_family
 - Drawing.font_stretch
 - Drawing.font_style
 - Drawing.font_weight
… cleaned Drawing.comment test case, and other minor code-style.
@emcconville emcconville changed the title Added support for drawing Polygone, Polyline, and Bezier curves Fully integrate DrawingWand C-API Jan 31, 2015
@coveralls
Copy link

@coveralls coveralls commented Feb 2, 2015

Coverage Status

Coverage increased (+0.66%) to 84.81% when pulling 2f3de46 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@coveralls
Copy link

@coveralls coveralls commented Feb 2, 2015

Coverage Status

Coverage increased (+0.65%) to 84.8% when pulling 2c13583 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

1 similar comment
@coveralls
Copy link

@coveralls coveralls commented Feb 2, 2015

Coverage Status

Coverage increased (+0.65%) to 84.8% when pulling 2c13583 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@dahlia
Copy link
Collaborator

@dahlia dahlia commented Feb 3, 2015

WOW. I am amazed and really appreciate your effort! Although it doesn’t seem possible to be reviewed at a time, I will gradually review the whole of this patch until this weekend. Really thanks for you again.

@coveralls
Copy link

@coveralls coveralls commented Feb 5, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling bfee33f on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

1 similar comment
@coveralls
Copy link

@coveralls coveralls commented Feb 5, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling bfee33f on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@emcconville
Copy link
Owner Author

@emcconville emcconville commented Feb 7, 2015

Thanks @dahlia. With all the methods covered, I'm planing on updating the documentation + examples over the next couple weeks.

@coveralls
Copy link

@coveralls coveralls commented Feb 8, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling 083da68 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

2 similar comments
@coveralls
Copy link

@coveralls coveralls commented Feb 8, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling 083da68 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@coveralls
Copy link

@coveralls coveralls commented Feb 8, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling 083da68 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@coveralls
Copy link

@coveralls coveralls commented Feb 14, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling f479073 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

2 similar comments
@coveralls
Copy link

@coveralls coveralls commented Feb 14, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling f479073 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@coveralls
Copy link

@coveralls coveralls commented Feb 14, 2015

Coverage Status

Coverage increased (+0.86%) to 85.02% when pulling f479073 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

…ods.

 - Drawing.clip_path
 - Drawing.font
 - Drawing.font_family
 - Drawing.stroke_dash_array
 - Drawing.text_encoding
 - Drawing.vector_graphics
@emcconville
Copy link
Owner Author

@emcconville emcconville commented Feb 15, 2015

Commit ee5aeb4 fixes memory leaks in the wand library. MagickWand is expecting calling programs to handle deallocation for the following methods (and wand counterparts.)

  • DrawGetClipPath => Drawing.clip_path
  • DrawGetFont => Drawing.font
  • DrawGetFontFamily => Drawing.font_family
  • DrawGetStrokeDashArray => Drawing.stroke_dash_array
  • DrawGetTextEncoding => Drawing.text_encoding
  • DrawGetVectorGraphics => Drawing.vector_graphics
@coveralls
Copy link

@coveralls coveralls commented Feb 15, 2015

Coverage Status

Coverage increased (+0.97%) to 85.13% when pulling ee5aeb4 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

1 similar comment
@coveralls
Copy link

@coveralls coveralls commented Feb 15, 2015

Coverage Status

Coverage increased (+0.97%) to 85.13% when pulling ee5aeb4 on emcconville:drawing_pu into 64ab5a5 on dahlia:0.3-maintenance.

@dahlia
Copy link
Collaborator

@dahlia dahlia commented Feb 19, 2015

It seems complete for me. @emcconville Is it ready to merge?

@emcconville
Copy link
Owner Author

@emcconville emcconville commented Feb 20, 2015

Yes, Please merge. I believe I've covered everything in CONTRIBUTING doc.

Cheers, 🍻

dahlia added a commit that referenced this pull request Feb 20, 2015
Fully integrate DrawingWand C-API
@dahlia dahlia merged commit 2ea0a55 into emcconville:0.3-maintenance Feb 20, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.97%) to 85.13%
Details
@dahlia
Copy link
Collaborator

@dahlia dahlia commented Feb 20, 2015

This patch was shipped with 0.4.0 release (what’s new in 0.4, changelog). Check it up!

@emcconville emcconville deleted the emcconville:drawing_pu branch Apr 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.