C#画点方法总结
1、直线
public void DrawLineFloat(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create coordinates of points that define line.
float x1 = 100.0F;
float y1 = 100.0F;
float x2 = 500.0F;
float y2 = 100.0F;
// Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}
2、正方形
g.DrawRectangle(thepen, ps[i].X, ps[i].Y, 0.5F, 0.5F);
3、指定的图形
Bitmap bm=new Bitmap(2,2); //这里调整点的大小
bm.SetPixel(0, 0, color); //设置点的颜色
bm.SetPixel(0, 1, color);
bm.SetPixel(1, 0, color);
bm.SetPixel(1, 1, color);
Graphics g = Graphics.FromHwnd(this.panel1.Handle); //画在哪里
g.DrawImageUnscaled(bm, e.X, e.Y); //具体坐标
- 1
- 2
- 3
前往页