Skip to content

Default drawing behaviour different after merging agg2.4 #61

@a-hurst

Description

@a-hurst

As I brought up in #50, the default line-end and line-cap arguments are different after merging the agg 2.4 update, unexpectedly changing the way various aggdraw-generated shapes look. Here are two screenshots from the same aggdraw-rendered experiment program, the first pre-2.4 and the second post-2.4:

Screen Shot 2019-08-13 at 7 21 10 PM

Screen Shot 2019-08-13 at 7 19 48 PM

If you download both the images and switch back and forth between them with Quick Look or something (ignoring the missing left line, that's just trial-to-trial variation), you can see that:

  1. The corners of the boxes are now rounded, whereas before they were completely square.
  2. The line in the middle of the box (created with the line() method of the aggdraw.Draw(), not the .rectangle() method) is slightly longer for some reason.
  3. The asterisk in the middle is slightly thicker.

I'm able to revert the drawing behaviour for both 1 and 2 to the pre-2.4 defaults by adding linejoin = 0 and linecap = 0 to the arguments when creating the Pen object, but this breaks backwards compatibility with old aggdraw versions, which lack these arguments. My personal preference would be to revert the defaults here to the old defaults before the next release, since a lot of the use of aggdraw in my field (cognitive science research) is in older Python experiments for generating stimuli, and people trying to revive/replicate one of those experiments (largely one-off scripts with no real maintainer) are highly unlikely to realize the shapes look different than they did 5-10 years ago and add the new arguments accordingly.

The thicker asterisk remains unchanged with the above overrides, however, which appears to be a regression because the thickness/size of the asterisk is exactly as specified pre-2.4 but appears to be an extra 1 pixel thicker/larger post-2.4. I'll see if I can figure out a minimal example that showcases this bug clearly, since what I have here is all wrapped in my own drawing/rendering code.

EDIT: To revert to the old defaults in aggdraw itself, I believe all that's required is replacing the agg::round_join with agg::miter_join and agg::round_cap with agg::butt_cap in this section here:

aggdraw/aggdraw.cxx

Lines 1823 to 1833 in e9d7bcb

static PyObject*
pen_new(PyObject* self_, PyObject* args, PyObject* kw)
{
PenObject* self;
PyObject* color;
float width = 1.0;
agg::line_join_e line_join = agg::round_join;
agg::line_cap_e line_cap = agg::round_cap;
float miter_limit = 4.0; // Like default in agg_math_stroke.h
int opacity = 255;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions