Conversation
|
Hmm, I am not really good at this :) This attempt works fine if XY= 0,0 , otherwise wrong width/height :) public void Render(PlotDimensions dims, System.Drawing.Bitmap bmp, bool lowQuality = false)
{
// Use ScottPlot's GDI helper functions to create System.Drawing objects
using var gfx = ScottPlot.Drawing.GDI.Graphics(bmp, dims, lowQuality);
using var pen = ScottPlot.Drawing.GDI.Pen(Color, LineWidth, LineStyle);
// Use 'dims' methods to convert between axis coordinates and pixel positions
float xPixel = dims.GetPixelX(X - Radius);
float yPixel = dims.GetPixelY(Y - Radius);
// Render data by drawing on the Graphics object
gfx.DrawEllipse(pen, xPixel, yPixel, dims.GetPixelX(Radius * 2) - dims.GetPixelX(X), dims.GetPixelY(Radius * 2) - dims.GetPixelY(Y));
//gfx.DrawEllipse(pen, xPixel, yPixel, dims.GetPixelX(Radius * 2), dims.GetPixelY(Radius * 2));
} |
|
Hi @bukkideme, thanks so much for getting this started! I'll start working on this now and make some commits to this branch and possibly merge it in. I recommend not making additional commits while I'm working on it to avoid merge conflicts. Hopefully the changes I implement from here will help answer your questions! Even though the code in its present state isn't working perfectly, getting this PR started was still a big help, so thanks! I'll follow-up with a message shortly to indicate my progress. |
|
Thanks very much for continue the implementation, i will certainly learn from the commits you will make! I do not commit new things from now then! |
|
See 6364e92 I had to convert Plot plt = new();
plt.AddCirclePlot(0, 0, 5);
TestTools.SaveFig(plt); |
modify the constructor so it only accepts data (not styling) styling is modified by assigning to public properties rather than being passed into the constructor also gave AddCircle() a Color argument
the same plot type can be used for AddEllipse() and AddCircle()
|
I'm adding legend support while I'm in here too Plot plt = new(400, 300);
var c1 = plt.AddCircle(0, 0, 1);
c1.Label = "outlined";
c1.BorderLineWidth = 3;
c1.BorderLineStyle = LineStyle.Solid;
c1.BorderColor = System.Drawing.Color.Blue;
var c2 = plt.AddCircle(1, 1, 1);
c2.Label = "filled";
c2.BorderLineStyle = LineStyle.None;
c2.Color = System.Drawing.Color.Green;
var c3 = plt.AddCircle(2, 2, 1);
c3.Label = "both";
c3.Color = System.Drawing.Color.FromArgb(100, System.Drawing.Color.Green);
c3.BorderColor = System.Drawing.Color.Blue;
c3.BorderLineStyle = LineStyle.Dot;
plt.Legend(); |
|
... and while the hood was popped, I made some changes elsewhere in the code base using this pull request. I hope it's not too confusing! 😅 This looks great, and I'm going to merge in a few minutes and hopefully release a new version of ScottPlot at the end of this weekend 🚀 |
|
Awesome! :) I did not hope for such quick release! :) 🚀 |


Hi!
This is where I managed to get so far :)
To be honest, the pixel/coordinate transformations got me confused a bit. Also, I am not sure how to lock the created circle to coordinate positions, so when i zoom in/out (with AxisScaleLock(true)), the circle size should follow it dynamically (this should be also optional i guess?).
Maybe you can give me some help in this? :)
Otherwise it does draw a circle at least :)
Thanks!