J
John
I wrote this class
class CLine
{
public float sX,sY,dX,dY,m,x,y;
public void Draw (PaintEventArgs g)
{
//Graphics g = this.CreateGraphics
();
Bitmap bm=new Bitmap(1,1);
bm.SetPixel(0,0,Color.Black);
m = (dY-sY)/(dX-sX);
if (m<=1)
{
for (x=sX;x<=dX;x++)
{
y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x)
+512,-1*Convert.ToInt32(Math.Round(y))+384);
}
}
else
{
for (y=sY;y<=dY;y++)
{
x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32
(Math.Round(x))+512,-1*Convert.ToInt32(y)+384);
}
}
}
}
What should I do if I wanna call Draw method? I've tried
below code but it doesn't work.
CLine first = new CLine();
first.sX = 0; first.sY = 0; first.dX = 300; first.dY = -
500;
first.Draw(); <== Problem's here!
Thank in advance for your help.
class CLine
{
public float sX,sY,dX,dY,m,x,y;
public void Draw (PaintEventArgs g)
{
//Graphics g = this.CreateGraphics
();
Bitmap bm=new Bitmap(1,1);
bm.SetPixel(0,0,Color.Black);
m = (dY-sY)/(dX-sX);
if (m<=1)
{
for (x=sX;x<=dX;x++)
{
y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x)
+512,-1*Convert.ToInt32(Math.Round(y))+384);
}
}
else
{
for (y=sY;y<=dY;y++)
{
x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32
(Math.Round(x))+512,-1*Convert.ToInt32(y)+384);
}
}
}
}
What should I do if I wanna call Draw method? I've tried
below code but it doesn't work.
CLine first = new CLine();
first.sX = 0; first.sY = 0; first.dX = 300; first.dY = -
500;
first.Draw(); <== Problem's here!
Thank in advance for your help.