KarthikRIyer / swiftplot

Swift library for Data Visualization :bar_chart:
Apache License 2.0
398 stars 36 forks source link

Function to draw solid ellipses #107

Closed boronhub closed 4 years ago

boronhub commented 4 years ago

Added function to draw solid ellipses in AGGRenderer and SVGRenderer.

boronhub commented 4 years ago

@KarthikRIyer any idea how to fix the QuartzRenderer error ?

WilliamHYZhang commented 4 years ago

@boronhub comment out the Quartz Renderer tests if you're not using an Apple device.

KarthikRIyer commented 4 years ago

You'll need to implement the function in QuartzRenderer too. This is because QuartzRenderer needs to conform to the Renderer protocol. You'll be able to do this only if you are on a mac. If not, could you allow edits from maintainer option in your PR. Then I can add the relevant code to fix the build.

boronhub commented 4 years ago

Done!

KarthikRIyer commented 4 years ago

I don't have ready access to a mac (I did have one an hour ago). So I'll add the code as soon as I get my hands on a mac.

odmir commented 4 years ago

I think this should work:

public func drawSolidEllipse(center c: Point,
                             radius rx: Float,
                             radius ry: Float,
                             fillColor: Color) {
    let ellipse = CGMutablePath()
    ellipse.addEllipse(in: CGRect(x: CGFloat(c.x-rx), y: CGFloat(c.y-ry), width: CGFloat(rx*2), height: CGFloat(ry*2)),
                       transform: CGAffineTransform(translationX: CGFloat(xOffset), y: CGFloat(yOffset)))
    context.setFillColor(fillColor.cgColor)
    context.addPath(ellipse)
    context.fillPath()
}
boronhub commented 4 years ago

Commits + fixes pushed by @KarthikRIyer through #111