-
-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Hi,
I need to draw thousand of pie Elements on my RenderContext. Because the calculation is very time consuming, I need to draw them on a memory bitmap and the the memory bitmap on screen.
But this don't work, simply it's nothing drawn but also no error or exception.
I modified your PieChart Example to demonstrate the issue. All other methods work excelent on memory bitmap, but FillPath and DrawPath will not (I've not tested more).
Can you please fix this?
Regards
namespace unvell.D2DLib.Examples.Demos
{
public partial class PieChart : DemoForm
{
List<PieInfo> pies = new List<PieInfo>();
D2DBitmapGraphics m_MemoryBitmap;
public PieChart()
{
Size = new Size(800, 1000);
Text = "PieChart Demo - d2dlib Examples";
CreateChart();
m_MemoryBitmap = Device.CreateBitmapGraphics(ClientRectangle.Width, ClientRectangle.Height);
}
void CreateChart()
{
pies.Clear();
// define the figure origin and size
var figureOrigin = new D2DPoint(300, 300);
var figureSize = new D2DSize(300, 300);
Random random = new Random();
var records = new float[2];
records[0] = random.Next(0, 360);
records[1] = 360 - records[0];
float currentAngle = 270 - (records[0] / 2);
// create pie geometries from records
foreach (var record in records)
{
var angleSpan = record;
var path = Device.CreatePieGeometry(figureOrigin, figureSize, currentAngle, currentAngle + angleSpan);
pies.Add(new PieInfo { path = path, color = D2DColor.Randomly() });
currentAngle += angleSpan;
}
}
protected override void OnRender(D2DGraphics g)
{
base.OnRender(g);
// draw background
D2DBrush brush = Device.CreateSolidColorBrush(D2DColor.Silver);
m_MemoryBitmap.BeginRender();
m_MemoryBitmap.FillRectangle(100, 100, 400, 400, D2DColor.LightYellow);
m_MemoryBitmap.FillEllipse(100, 300, 400, 400, D2DColor.AliceBlue);
// draw pie geometries
m_MemoryBitmap.FillPath(pies[0].path, pies[0].color);
m_MemoryBitmap.DrawPath(pies[0].path, D2DColor.LightYellow, 2);
//
m_MemoryBitmap.FillPathWithBrush(pies[0].path, brush);
//
m_MemoryBitmap.DrawText("Click to change color", D2DColor.Red, 250, 550);
m_MemoryBitmap.EndRender();
g.DrawBitmap(m_MemoryBitmap, ClientRectangle);
g.FillPathWithBrush(pies[1].path, brush);
g.DrawPath(pies[1].path, D2DColor.Blue, 2);
brush.Dispose();
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
CreateChart();
Invalidate();
}
}
class PieInfo
{
public D2DGeometry path;
public D2DColor color;
}
}