Skip to content

Conversation

watzon
Copy link

@watzon watzon commented May 21, 2020

Closes #7

It's tested and working, but I'm open to suggestions. It's based directly off of ChunkyPNG::Canvas::Drawing#rect.

@l3kn
Copy link
Collaborator

l3kn commented May 22, 2020

Nice!

I think it's reasonable to assume that x0 < x1 and y0 < y1
Clipping the rectangle against the canvas first, then using set instead of safe_set would probably make this a little bit faster.

I have not used crystal in a while and looking at my old code, the API isn't designed that well.

The canvas.circle takes a boolean filled argument,
canvas.fill_polygon has "fill" in its name and there's no way to draw just the outline of a polygon.

Your method takes two colors as arguments, one for filling an one for the outline,
this seems like the best approach to me.

Also there is a Point type that's only used for polygons,
it would be nice to have additional line, circle and rect methods
working on Points instead of x, y pairs.

I think these design flaws would justify a major version update at some point.

Regarding this pull request, can you also add an example for the readme?
Also, the version in shard.yml should be changed to 0.6.0.

@watzon
Copy link
Author

watzon commented Jun 15, 2020

Once the 0.35.1 patch comes out for Crystal I'm going to update this and apply fixes for anything that's broken as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add #rect method

2 participants