Hi im new to c# and I am trying to learn how to (make a) scale in a panel. I have created a Mandelbrot, but now I have to zoom in on -2 to 2 in both axes.
My question is, how do I make a scale (e.g x,y 0.01) for this panel in which I can choose the center of the panel myself? I want my graph to go from -2 to 2 in both axes. I know I should be using Graphics.ScaleTransform to scale it and e.Graphics.TranslateTransform to center it, but I just can't figure out how.
This is my panel method :
public void panel1_Paint(object sender, PaintEventArgs e)
{
for (double p = 0; p < 400; p++)
{
for (double j = 0; j < 400; j++)
//over here I zoomed it in manually, but it was just to make sure the Mandelbrot was working
{
int mandel = mandelgetalberekening((p - 200)*0.01, (j-200)*0.01);
if (mandel % 2 == 0)
{
e.Graphics.FillRectangle(Brushes.Purple, (float)p, (float)j, 1, 1);
}
else
{
e.Graphics.FillRectangle(Brushes.White, (float)p, (float)j, 1, 1);
}
}
}
and if I try to use something like this I just gives me an empty window:
public void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.ScaleTransform((float)0.01, (float)0.01);
for (double p = 0; p < 400; p++)
{
for (double j = 0; j < 400; j++)
{
int mandel = mandelgetalberekening((p - 200)*0.01, (j-200)*0.01);
if (mandel % 2 == 0)
{
e.Graphics.FillRectangle(Brushes.Purple, (float)p, (float)j, 1, 1);
}
else
{
e.Graphics.FillRectangle(Brushes.White, (float)p, (float)j, 1, 1);
}
}
}
``