(来左边儿 跟我一起画个龙,在你右边儿 画一道彩虹 ~~~~~~~~~~~ )
效果如下:
以下展示部分颜色源码:
namespace AcTools
{public class Class1{public Wform.Timer timer;//定时器需建在类下面public static DateTime startTime;[CommandMethod("xx")]public void Demo(){红到黄(255, 1000.0);黄到绿(255, 1000.0 + 255 * 1);绿到蓝(255, 1000.0 + 255 * 2);蓝到紫(255, 1000.0 + 255 * 3);timer = new Wform.Timer();timer.Interval = 2500;//相当于多久更新一下屏幕timer.Tick += Timer_Tick;//定时器关联事件;startTime = DateTime.Now;timer.Start(); //红到紫(255, 1000.0 + 255 * 4);}public void Timer_Tick(object sender, EventArgs e)//一定时间间隔触发的事件{TimeSpan elapsed = DateTime.Now - startTime;红到紫(255, 1000.0 + 255 * 4);if (elapsed.TotalSeconds > 10){timer.Stop();timer.Dispose();Z.ed.WriteMessage("over\n");}Z.ed.UpdateScreen();}public void 红到紫(double num, double radius){//红到紫 255, 0 ,0 ---- 255 ,0, 255List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 0) ? Color.FromRgb(255, 0, 0) : Color.FromRgb(255, 0,(byte)(0 + i / num * 255) ),};circles.Add(circle);}arcs = Halfcircle(circles);for (int i = 0; i < 5; i++){List<Entity> ents = arcs.Cast<Entity>().ToList();//list类型强转Flash flash = new Flash(ents );//创建瞬态flash.FlashUpdate(ents);//更新瞬态//Z.ed.GetPoint("");//foreach (Entity item in ents){item.ChangeEntityColor(i);}flash.FlashUpdate(ents);//更新瞬态Thread.Sleep(500);Z.ed.UpdateScreen();flash.FlashlistErase();//删除瞬态}//Z.db.AddEntityToModeSpace(arcs.ToArray());}public void 红到黄(double num,double radius){//红到黄 255 0 0 - 255 255 0List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i ,Color = (i ==0)? Color.FromRgb(255, 0, 0) : Color.FromRgb(255, (byte)(0 + i/ num* 255), 0),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());} public void 黄到绿(double num, double radius){//黄到绿255 ,255 ,0 - 0, 255,0 List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 1) ? Color.FromRgb(255, 255, 0) : Color.FromRgb((byte)(255 - i / num * 255), 255,0),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());}public void 绿到蓝(double num, double radius){//绿到蓝0, 255,0 ---- 0 ,0 ,255List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 1) ? Color.FromRgb(0,255, 255 ) : Color.FromRgb(0,(byte)(255 - i / num * 255), (byte)(0 + i / num * 255)),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());}public void 蓝到紫(double num, double radius){//蓝到紫 0 ,0 ,255 - 255, 0, 255 List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 1) ? Color.FromRgb(0, 0, 255) : Color.FromRgb((byte)(0 + i / num * 255), 0, 255),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());}public static List<Arc> Halfcircle(List<Circle> circles){ List<Arc> arcs = new List<Arc>();//画弧if (!( circles is null )&& circles.Count >0){foreach (Circle circle in circles){arcs.Add(new Arc() { Center = circle.Center,Radius = circle .Radius,StartAngle = 0,Color = circle .Color, EndAngle = Math.PI });}}return arcs;}}
}
namespace AcTools
{public class Class1{[CommandMethod("xx")]public void Demo(){红到黄(255, 1000.0);黄到绿(255, 1000.0 + 255 * 1);绿到蓝(255, 1000.0 + 255 * 2);蓝到紫(255, 1000.0 + 255 * 3);}public void 红到紫(double num, double radius){//红到紫 255, 0 ,0 ---- 255 ,0, 255List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 0) ? Color.FromRgb(255, 0, 0) : Color.FromRgb(255, 0,(byte)(0 + i / num * 255) ),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());}public void 红到黄(double num,double radius){//红到黄 255 0 0 - 255 255 0List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i ,Color = (i ==0)? Color.FromRgb(255, 0, 0) : Color.FromRgb(255, (byte)(0 + i/ num* 255), 0),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());} public void 黄到绿(double num, double radius){//黄到绿255 ,255 ,0 - 0, 255,0 List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 1) ? Color.FromRgb(255, 255, 0) : Color.FromRgb((byte)(255 - i / num * 255), 255,0),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());}public void 绿到蓝(double num, double radius){//绿到蓝0, 255,0 ---- 0 ,0 ,255List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 1) ? Color.FromRgb(0,255, 255 ) : Color.FromRgb(0,(byte)(255 - i / num * 255), (byte)(0 + i / num * 255)),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());}public void 蓝到紫(double num, double radius){//蓝到紫 0 ,0 ,255 - 255, 0, 255 List<Circle> circles = new List<Circle>();//画圆List<Arc> arcs = new List<Arc>();//画弧for (int i = 1; i <= num; i++){Circle circle = new Circle(){Center = new Point3d(500, 1000, 0),Radius = radius + i,Color = (i == 1) ? Color.FromRgb(0, 0, 255) : Color.FromRgb((byte)(0 + i / num * 255), 0, 255),};circles.Add(circle);}arcs = Halfcircle(circles);Z.db.AddEntityToModeSpace(arcs.ToArray());}public static List<Arc> Halfcircle(List<Circle> circles){ List<Arc> arcs = new List<Arc>();//画弧if (!( circles is null )&& circles.Count >0){foreach (Circle circle in circles){arcs.Add(new Arc() { Center = circle.Center,Radius = circle .Radius,StartAngle = 0,Color = circle .Color, EndAngle = Math.PI });}}return arcs;}}
}
public static ObjectId[] AddEntityToModeSpace(this Database db, params Entity[] ent){// 声明ObjectId 用于返回ObjectId[] entId = new ObjectId[ent.Length];// 开启事务处理using (DocumentLock acLckDoc = Z.doc.LockDocument()){using (Transaction trans = db.TransactionManager.StartTransaction()){// 打开块表BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);// 打开块表记录BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);for (int i = 0; i < ent.Length; i++){// 将图形添加到块表记录if (ent[i].IsNewObject){entId[i] = btr.AppendEntity(ent[i]);// 更新数据信息trans.AddNewlyCreatedDBObject(ent[i], true);}// Z.ed.Redraw(ent[i]);//动态显示}// 提交事务trans.Commit();}}return entId;}public static Database db {get { return HostApplicationServices.WorkingDatabase; }}
Arc arc = new Arc()
{
Center = new Point3d(500,500+i,0),
Radius = 500,StartAngle = Math.PI*0.1+i*0.01,
EndAngle=Math.PI*0.9+i * 0.01,
//StartPoint = new Point3d(0, i, 0),
//EndPoint = new Point3d(1000, i, 0),
Color = Color.FromRgb(255, (byte)i, 0),
};
public void xx(){//红到黄 255 0 0 - 255 255 0List<Line> lines = new List<Line>();//画线for (int i = 0; i < 255; i++){Line line = new Line() { StartPoint = new Point3d(0,i,0),EndPoint = new Point3d(1000,i, 0),Color = Color .FromRgb(255, (byte)i, 0),}; lines.Add(line);}Z.db.AddEntityToModeSpace(lines.ToArray());List<Arc> arcs = new List<Arc>();//画圆弧for (int i = 0; i < 255; i++){Arc arc = new Arc(){Center = new Point3d(500,1000+i,0),Radius = 500,StartAngle = Math.PI*0.1-i*0.01,EndAngle=Math.PI*0.9+i * 0.01,//StartPoint = new Point3d(0, i, 0),//EndPoint = new Point3d(1000, i, 0),Color = Color.FromRgb(255, (byte)i, 0),};arcs.Add(arc);}Z.db.AddEntityToModeSpace(arcs.ToArray());}
finally: