public override void DrawLine(double x1, double y1, double x2, double y2) { if (Clipper.ClipLine(ref x1, ref y1, ref x2, ref y2, Clip.XMin, Clip.YMin, Clip.XMax, Clip.YMax)) { target.Add(GFXUtil.FloatToInt(x1), GFXUtil.FloatToInt(y1), GFXUtil.FloatToInt(x2), GFXUtil.FloatToInt(y2), currentobject); } }
private void Line_ThinContinuous(int x1, int y1, int x2, int y2, bool setlastpixel) { if (!Clipper.ClipLine(ref x1, ref y1, ref x2, ref y2, Clip.XMin, Clip.YMin, Clip.XMax, Clip.YMax)) { return; } int d, x, y, ax, ay, sx, sy, dx, dy; dx = x2 - x1; ax = Math.Abs(dx) << 1; sx = dx < 0 ? -1 : 1; dy = y2 - y1; ay = Math.Abs(dy) << 1; sy = dy < 0 ? -1 : 1; x = x1; y = y1; if (ax > ay) { d = ay - (ax >> 1); while (x != x2) { *(scanlines[y] + x) = color; //set pixel if (d >= 0) { y += sy; d -= ax; } x += sx; d += ay; } } else { d = ax - (ay >> 1); while (y != y2) { *(scanlines[y] + x) = color; //set pixel if (d >= 0) { x += sx; d -= ay; } y += sy; d += ax; } } if (setlastpixel) { *(scanlines[y] + x) = color; //set last pixel } }
void Line_ThinStippled(int x1, int y1, int x2, int y2) { if (!Clipper.ClipLine(ref x1, ref y1, ref x2, ref y2, Clip.XMin, Clip.YMin, Clip.XMax, Clip.YMax)) { return; } int d, x, y, ax, ay, sx, sy, dx, dy; dx = x2 - x1; ax = Math.Abs(dx) << 1; sx = dx < 0 ? -1 : 1; dy = y2 - y1; ay = Math.Abs(dy) << 1; sy = dy < 0 ? -1 : 1; x = x1; y = y1; if (ax > ay) { d = ay - (ax >> 1); while (x != x2) { ///Setpixel logic//////////////////////// if ((stipplepattern & stipplebit) != 0) { *(scanlines[y] + x) = color; } stipplebit >>= 1; if (stipplebit == 0) { stipplebit = 0x8000; } //////////////////////////////////////// if (d >= 0) { y += sy; d -= ax; } x += sx; d += ay; } } else { d = ax - (ay >> 1); while (y != y2) { ///Setpixel logic//////////////////////// if ((stipplepattern & stipplebit) != 0) { *(scanlines[y] + x) = color; } stipplebit >>= 1; if (stipplebit == 0) { stipplebit = 0x8000; } //////////////////////////////////////// if (d >= 0) { x += sx; d -= ay; } y += sy; d += ax; } } ///Setpixel logic//////////////////////// if ((stipplepattern & stipplebit) != 0) { *(scanlines[y] + x) = color; } stipplebit >>= 1; if (stipplebit == 0) { stipplebit = 0x8000; } //////////////////////////////////////// }