Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.
e.SmoothingMode = SmoothingMode.HighQuality;
float Cx = this.posx;
float Cy = this.posy;
float Fx = this.finalx;
float Fy = this.finaly;
float Vx = Cx;
float Inc;
Inc=1;
float a = (Cy - Fy) / (Cx - Fx);
float b = (Cx * Fy - Fx * Cy) / (Cx - Fx);
if (Cx > Fx) Inc = -1;
while(Vx != Fx)
{
///////by Interpolation y=ax+b
///////where a=(y1-y2)/(x1-x2)
//////b =(x1*y2-x2*y1)/(x1-x2)
Vy = a * Vx + b;
e.DrawRectangle(Pens.Red, Vx, Vy, 4, 4);
Vx = Vx + Inc;
}
ALGO 1
lineplot(x1,y1,x2,y2)
{
for x=x1 to x2
{
y = f(x)
setPixel(x,y)
}
}
ALGO 2
lineplot(x1,y1,x2,y2)
{
// verify which is bigger: |x2-x1| or |y2-y1|
if |x2-x1| > |y2-y1|
then loop x values from x1 to x2
else loop y values from y1 to y2
}
PSEUDOCODE 1
lineplot(x1,y1,x2,y2)
{
if abs(x2-x1) > abs(y2-y1)
then // loop by varying x values
{
dx = abs(x2-x1) / (x2-x1) // will be +1 or -1
// calculate line equation
m = (y2-y1) / (x2-x1) // if x2=x1 then the line is vertical
c = y1 - m*x1
for x=x1 to x2 step dx
{
y = m*x + c
setPixel(x,y)
}
}
else
{
// do the equivalent by varying y values
}
}
myGraphics.SmoothingMode = SmoothingMode.AntiAlias;
and draw the rectangle with lines, instead of placing a dot for each different pixel
myGraphics.DrawLine(myPen,
this should improve drawing quality