public void Line(Stroke stroke,Point point0,Point point1) { //Extremely Fast Line Algorithm //Copyright 2001-2002, By Po-Han Lin bool yLonger=false; int shortLen=point1.Y-point0.Y; int longLen=point1.X-point0.X; if(Math.Abs(shortLen)>Math.Abs(longLen)) { int swap=shortLen; shortLen=longLen; longLen=swap; yLonger=true; } int decInc; if(longLen==0)decInc=0; else decInc=(shortLen<<16)/longLen; if(yLonger) { if(longLen>0) { longLen+=point0.Y; for(int j=0x8000+(point0.X<<16);point0.Y<=longLen;++point0.Y) { Point(stroke,new Point(j>>16,point0.Y)); j+=decInc; } return; } longLen+=point0.Y; for(int j=0x8000+(point0.X<<16);point0.Y>=longLen;--point0.Y) { Point(stroke,new Point(j>>16,point0.Y)); j-=decInc; } return; } if(longLen>0) { longLen+=point0.X; for(int j=0x8000+(point0.Y<<16);point0.X<=longLen;++point0.X) { Point(stroke,new Point(point0.X,j>>16)); j+=decInc; } return; } longLen+=point0.X; for(int j=0x8000+(point0.Y<<16);point0.X>=longLen;--point0.X) { Point(stroke,new Point(point0.X,j>>16)); j-=decInc; } }
public void Point(Stroke stroke,Point point) { //Draw point (image) if(stroke!=null) graphics.DrawImage(stroke.Shape,new Rectangle(point.X-(int)(stroke.Width/2f),point.Y-(int)(stroke.Width/2f),(int)stroke.Width,(int)stroke.Width),0,0,stroke.Shape.Width,stroke.Shape.Height,GraphicsUnit.Pixel); }
private void UpdateStroke() { //Create stroke if(listBox1.SelectedIndex!=-1) { stroke=new Stroke(new Bitmap(Directory.GetCurrentDirectory()+"\\Shapes\\"+listBox1.SelectedItem),Color.FromArgb((int)numericUpDown2.Value,colorDialog1.Color),(float)numericUpDown3.Value,(float)numericUpDown4.Value,(float)numericUpDown5.Value,(float)numericUpDown9.Value,checkBox1.Checked,checkBox2.Checked); pictureBox1.Image=stroke.Shape; } }