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

Shapes: FeatureRequest - Copy functionality for AddArc on PathBuilder #4

Closed
4 tasks done
Astralking opened this issue Mar 15, 2018 · 12 comments
Closed
4 tasks done
Labels
Milestone

Comments

@Astralking
Copy link

Prequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

Recently we've been encountering numerous "Error occured in GDI+" issues and even after attempting to dispose of everything correctly the issue still occurs with no consistency. In case this issue ever started happening all the time live sites we wanted to preemptively use an alternative for our image creation for in ASP.NET (WebAPI + MVC)

All features we use seem to already have been ported over to ImageSharp however currently there seems to be no way of adding an arc to a Path in the same way GraphicsPath works in System.Drawing, preventing any sort of exact logic replacement. I contemplated trying to do something similar with a bezier like in the samples however it seemed overkill.

I imagine it would be integrated into PathBuilder however it will need to be drawn on top of an existing image (which would previously have been in the graphics object). It seems the existing implementation with Polygon simply saves the image off directly however there might be a way to get this working with the existing code base I'm unaware of using "Fill". If an implementation for this does exist please let me know and close this issue.

Steps to Reproduce

Example System.Drawing code to replicate in code:

var locationPoint = new Point(20, 20);
var size = new Size(150, 150);
var arcBounds = new Rectangle(locationPoint, size);

using (var graphics = Graphics.FromImage(pictureBox1.Image))
using (var path = new GraphicsPath())
{
    float startAngle = 45;
    float sweepAngle = 90;

    path.AddArc(arcBounds, startAngle, sweepAngle);
    path.CloseFigure();
    graphics.FillPath(new SolidBrush(Color.Black), path);
    graphics.DrawPath(new Pen(Color.Red), path);
}

And resulting picture image:
IncisionImage

If you need more information please let me know. Also, thanks for creating this library! It seems Microsoft gave up a long time ago on GDI+ issues.

System Configuration

  • ImageSharp version: v1.0.0-beta0002
  • Environment (Operating system, version and so on): Windows Server 2012 R2/Windows 10
  • .NET Framework version: 4.6.1
@SamuelFisher
Copy link

I would also find this really useful - being able to add an arc is something that is missing when trying to render an SVG-style path (which has an arc command).

@paolofulgoni
Copy link

Given that the arcs can be sections of circles or ellipses, I'd like if there were two new classes CircularArcLineSegment and EllipticalArcLineSegment, similar to the existing CubicBezierLineSegment

@paolofulgoni
Copy link

As a workaround, here are some useful formula to approximate the arcs with bezier curves: https://stackoverflow.com/a/44829356/323447
I haven't tested them though

@paolofulgoni
Copy link

@JimBobSquarePants @tocsoft is this feature planned?
if not, do you think the implementation would be easy enough to be considered a good first issue?

@tocsoft
Copy link
Member

tocsoft commented Nov 28, 2019

nothing is planned from us at this stage. But would be happy to receive a PR implementing this.

@antonfirsov antonfirsov changed the title FeatureRequest - Copy functionality for AddArc on PathBuilder Shapes: FeatureRequest - Copy functionality for AddArc on PathBuilder Jan 17, 2020
@antonfirsov antonfirsov transferred this issue from SixLabors/Shapes Jan 17, 2020
@tocsoft tocsoft removed their assignment Dec 3, 2020
@JimBobSquarePants JimBobSquarePants added the help wanted Extra attention is needed label Apr 13, 2021
@JimBobSquarePants
Copy link
Member

I've added the "help wanted" label to this issue as it is a feature I do believe we require but will need assistance in delivering.

@derBobo
Copy link
Contributor

derBobo commented Jun 11, 2021

I started implementing this feature here. Right now I'm struggeling to implement the Transform Method for the EllipticalArcLineSegment maybe Someone here can have a look and help me.

@JimBobSquarePants
Copy link
Member

@derBobo That's awesome thanks! If you raise a draft PR against this repository we can all work together to get it completed.

@derBobo
Copy link
Contributor

derBobo commented Jun 14, 2021 via email

@antonfirsov antonfirsov added this to the 1.0.0-rc.1 milestone Jun 18, 2021
@antonfirsov
Copy link
Member

Triaging to RC1 now since we hoping in community help, we can push it out later, if we see that we can't make it.

@derBobo derBobo mentioned this issue Jun 18, 2021
4 tasks
@derBobo
Copy link
Contributor

derBobo commented Sep 10, 2021

The pr #144 is merged now, so this issue can be closed.

@JimBobSquarePants
Copy link
Member

Thanks @derBobo !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants