public void rect(int x, int y, int w, int h, DrawType type) { if (type == DrawType.OUTLINE) { int ex = x + w - 1; int ey = y + h - 1; for (int i = x; i <= ex; i++) { pixel(i, y); pixel(i, ey); } for (int i = y; i <= ey; i++) { pixel(x, i); pixel(ex, i); } } else if (type == DrawType.FILLED) { int ex = x + w - 1; int ey = y + h - 1; for (int i = x; i <= ex; i++) { for (int j = y; j <= ey; j++) { pixel(i, j); } } } }
public MeshLocation(int indexCount, int vertexBufferOffset, int indexBufferOffset, DrawType drawType) { IndexCount = indexCount; VertexBufferOffset = vertexBufferOffset; IndexBufferOffset = indexBufferOffset; DrawType = drawType; }
public DrawRange(Spell.Active spell, CheckBox checkbox) { Type = DrawType.Active; Spell_Active = spell; CheckBox = checkbox; Drawing.OnDraw += OnDraw; }
private static void DrawButtonOnRect(DrawType button, Rect rect) { switch (button) { case DrawType.Enable: DrawActiveButton(rect); break; case DrawType.Static: DrawStaticButton(rect); break; case DrawType.Lock: DrawLockButton(rect); break; case DrawType.Icon: DrawIcon(rect); break; case DrawType.ApplyPrefab: DrawPrefabApply(rect); break; case DrawType.Tag: DrawTag(rect); break; case DrawType.Layer: DrawLayer(rect); break; } }
/// <summary> Builds the geodesic. /// </summary> public void Rebuild() { if ((Math.Abs(_za.D()) < EPSILON) || // za == origin (Math.Abs(_zb.D()) < EPSILON) || // zb == origin (Math.Abs((_za.X / _zb.X) - (_za.Y / _zb.Y)) < EPSILON)) // za == lambda.zb { _type = DrawType.Line; } else { _type = DrawType.Arc; double __da = 1 + _za.X * _za.X + _za.Y * _za.Y; double __db = 1 + _zb.X * _zb.X + _zb.Y * _zb.Y; double __dd = 2 * (_za.X * _zb.Y - _zb.X * _za.Y); _zo.X = (_zb.Y * __da - _za.Y * __db) / __dd; _zo.Y = (_za.X * __db - _zb.X * __da) / __dd; double __det = (_zb.X - _zo.X) * (_za.Y - _zo.Y) - (_za.X - _zo.X) * (_zb.Y - _zo.Y); double __fa = _za.Y * (_za.Y - _zo.Y) - _za.X * (_zo.X - _za.X); double __fb = _zb.Y * (_zb.Y - _zo.Y) - _zb.X * (_zo.X - _zb.X); _zc.X = ((_za.Y - _zo.Y) * __fb - (_zb.Y - _zo.Y) * __fa) / __det; _zc.Y = ((_zo.X - _za.X) * __fb - (_zo.X - _zb.X) * __fa) / __det; } }
public DeviceVisualModel(DrawType drawType, int x) { _x = x; DrawType = drawType; VisualBitmapScalingMode = BitmapScalingMode.LowQuality; }
public void RaiseDrawTypeClicked(DrawType type, int width) { if (OnDrawTypeClicked != null) { OnDrawTypeClicked(type, width); } }
public void Init() { int drawTypev = (int)UseMapEditor.Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.images, "Draw Function", imageID).Data; if (drawTypev == 10) { drawType = CImage.DrawType.Shadow; } if (startAngle != -1) { Direction = startAngle; } else { Direction = Global.WindowTool.random.Next(0, 33); } int turn = (int)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.images, "Gfx Turns", imageID).Data; Turnable = (turn == 1); iscriptID = (int)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.images, "Iscript ID", imageID).Data; iscriptOffset = Global.WindowTool.iscript.iscriptEntries[iscriptID].AnimHeader[0]; }
// ------------------------------------------------------------------- // GetGeneralDrawType // ------------------------------------------------------------------- public static GeneralDrawtype GetGeneralDrawType(DrawType type) { switch (type) { case DrawType.None: return(GeneralDrawtype.None); case DrawType.Floors: return(GeneralDrawtype.Floor); case DrawType.Autotiles: return(GeneralDrawtype.Autotile); case DrawType.FaceSprite: return(GeneralDrawtype.Sprite); case DrawType.FixSprite: return(GeneralDrawtype.Sprite); case DrawType.DoubleSprite: return(GeneralDrawtype.Sprite); case DrawType.QuadraSprite: return(GeneralDrawtype.Sprite); case DrawType.OnFloorSprite: return(GeneralDrawtype.Sprite); case DrawType.Montains: return(GeneralDrawtype.Relief); default: return(GeneralDrawtype.None); } }
public DrawTool CreateDrawTool(DrawType dt) { switch (dt) { case DrawType.Point: return(new DrawPoint()); case DrawType.Line: return(new DrawLine()); case DrawType.Polyline: return(new DrawPolyline()); case DrawType.Polygon: return(new DrawPolygon()); case DrawType.Rectangle: return(new DrawRectangle()); case DrawType.SelectOne: return(new DrawSelectOne()); case DrawType.Circle: return(new DrawCircle()); case DrawType._3DModel: return(new Draw3DModel()); //case DrawType.TerrainHole: // return new DrawTerrainHole(); default: return(null); } }
/// <summary> Constructs a custom block, with the default properties of the given classic/CPE block. </summary> public static BlockDefinition MakeCustomBlock(Block b) { BlockDefinition def = new BlockDefinition(); byte raw = (byte)b; def.BlockID = raw; def.Name = Name(raw); def.CollideType = (byte)Collide(b); def.Speed = 1; def.BlocksLight = BlocksLight(b); def.TopTex = topTex[raw]; def.BottomTex = bottomTex[raw]; def.SetSidesTex(sideTex[raw]); def.WalkSound = (byte)StepSound(b); def.FullBright = FullBright(b); def.Shape = Draw(b) == DrawType.Sprite ? (byte)0 : (byte)1; DrawType blockDraw = Draw(b); if (blockDraw == DrawType.Sprite) { blockDraw = DrawType.Transparent; } def.BlockDraw = (byte)blockDraw; def.FogDensity = FogDensity(b); CustomColor fog = FogColor(b); def.FogR = fog.R; def.FogG = fog.G; def.FogB = fog.B; def.FallBack = raw; def.MaxX = 16; def.MaxZ = Height(b); def.MaxY = 16; return(def); }
public void SetDrawType(DrawType drawType) { switch (drawType) { case DrawType.Points: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList; break; case DrawType.LineList: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineList; break; case DrawType.LineStrip: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineStrip; break; case DrawType.Triangles: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; break; case DrawType.TriangleStrip: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip; break; default: throw new NotSupportedException("Unexpected draw type: " + drawType); } }
private void tabControl1_Click(object sender, EventArgs e) { switch (tabControl1.SelectedIndex) { case 0: CurrDrawType = DrawType.Line; label1.Text = GetText("直线"); break; case 1: CurrDrawType = DrawType.Rectangle; label1.Text = GetText("空心矩形"); break; case 2: CurrDrawType = DrawType.Ellipse; label1.Text = GetText("空心圆"); break; case 3: CurrDrawType = DrawType.LeftText; label1.Text = GetText("左对齐"); break; } }
private void DrawType_Click(object sender, EventArgs e) { var btn = (Button)sender; CurrDrawType = (DrawType)btn.TabIndex; label1.Text = btn.Tag.ToString(); }
public void Init() { scale = new Vector2(1, 1); typeManager = new CollisionTypeManager(); objectSourceManager = new ObjectSourceManager(); enemyManager = new EnemySourceManager(); enemyManager.Init(); objectSourceManager.Init(); typeManager.Init(); map = new Map(); map.Init(); debugMode = false; buttonSelected = MapButtonType.None; drawTypeSelected = DrawType.Both; clearMap = new AMapButton(new Vector2(900, 880), "Clear Map"); saveFile = new AMapButton(new Vector2(1050, 920), "Save Map"); loadFile = new AMapButton(new Vector2(1050, 880), "Load Map"); playerStart = new AMapButton(new Vector2(900, 920), "Set Start Pos"); setMusicFile = new AMapButton(new Vector2(750, 920), "Set Music"); mapTransitionStart = new AMapButton(new Vector2(750, 880), "Map Transition"); setDrawType = new AMapButton(new Vector2(1225, 160), "Draw: Both"); decreaseX = new AMapButton(new Vector2(450, 880), " X -"); increaseX = new AMapButton(new Vector2(450, 920), " X +"); decreaseY = new AMapButton(new Vector2(600, 880), " Y -"); increaseY = new AMapButton(new Vector2(600, 920), " Y +"); }
public Mesh(string id, T[] vertices, uint[] indices, DrawType drawType) { Id = id; Vertices = vertices; Indices = indices; DrawType = drawType; }
public DrawRange(Spell.Skillshot spell, CheckBox checkbox) { Type = DrawType.Skillshot; Spell_Skillshot = spell; CheckBox = checkbox; Drawing.OnDraw += OnDraw; }
/// <summary> /// Draw a BuildingObjectLib3DS object. /// </summary> /// <param name="gl">Opengl handler.</param> /// <param name="buildingObj">The BuildingObjectLib3DS object.</param> public void DrawBuildingPart(OpenGL gl, BuildingObjectLib3DS buildingObj, DrawType type) { // Return when the input object is null if (buildingObj == null) return; // Draw all the children when type is Building, Floor or room. Or draw a Object. switch (buildingObj.GetBuildingType()) { case BuildingObjectType.Building: case BuildingObjectType.Floor: case BuildingObjectType.Room: foreach (BuildingObjectLib3DS child in buildingObj.GetChilds().Values) { DrawBuildingPart(gl, child, type); } break; case BuildingObjectType.Outside: case BuildingObjectType.Object: DrawObject(gl, buildingObj, type); break; default: break; } }
public void Deserialize(BinaryFormatter bf, Stream s) { int version = (int)bf.Deserialize(s); int objCount = (int)bf.Deserialize(s); _objs.Clear(); _objs.Capacity = objCount; for (int i = 0; i < objCount; i++) { DrawType type = (DrawType)bf.Deserialize(s); IDrawObj obj = CreateDrawObj(type); //DrawGroup控件需要提前获取Form,用来创建子控件 if (obj.Type == DrawType.Group) { obj.Parant = Container; } obj.Deserialize(bf, s); _objs.Add(obj); } _rect = (Rectangle)bf.Deserialize(s); _style = (FormStyle)bf.Deserialize(s); BorderStyle = (FormBorderStyle)bf.Deserialize(s); _defaultLayer = (int)bf.Deserialize(s); _visibleLayers = (BitArray)bf.Deserialize(s); _lockedLayers = (BitArray)bf.Deserialize(s); _caption = (string)bf.Deserialize(s); _backBrush.Data.Deserialize(bf, s); }
public async Task <Draw> GetDraw(DrawType drawType, string resultsUrl) { string html = await GetHtmlAsString(resultsUrl); _htmlDocument = GetHtmlDocument(html); Draw draw = new Draw { DrawType = (int)drawType, DrawDate = GetDrawDate(), DrawNo = GetDrawNumber(), DrawDetails = new List <DrawDetail>() }; List <int> numbers = GetNumbers(); for (int i = 0; i < numbers.Count; i++) { draw.DrawDetails.Add(new DrawDetail { Number = numbers[i], DrawOrder = i + 1 }); } return(draw); }
//Kártya húzás: Modellből adatok lekérése és továbbítása a megfelelő játékos oldalnak. private void DrawTheCard(int key, DrawTarget target, DrawType drawType, SkillState newState) { Card cardData = null; if (target == DrawTarget.Hand && !controller.GetBlindMatchState()) { cardData = modules.GetDataModule().GetPlayerWithKey(key).DrawCardFromDeck(); } else if (controller.GetBlindMatchState() || target == DrawTarget.Field) { cardData = modules.GetDataModule().GetPlayerWithKey(key).BlindDraw(); } //Ha a felhúzás sikeres if (cardData != null) { modules.GetClientModule().DrawNewCard(cardData, key, modules.GetDataModule().GetPlayerWithKey(key).GetPlayerStatus(), drawType, target, newState); //Ha a játékosról van szó továbbítjuk megjelenítésre a deck új méretét if (modules.GetDataModule().GetPlayerWithKey(key).GetPlayerStatus()) { int remainingDeckSize = modules.GetDataModule().GetPlayerWithKey(key).GetDeckSize(); modules.GetClientModule().RefreshDeckSize(key, remainingDeckSize); } } }
/// <summary> /// Draw a BuildingObjectLib3DS object. /// </summary> /// <param name="gl">Opengl handler.</param> /// <param name="buildingObj">The BuildingObjectLib3DS object.</param> public void DrawBuildingPart(OpenGL gl, BuildingObjectLib3DS buildingObj, DrawType type) { // Return when the input object is null if (buildingObj == null) { return; } // Draw all the children when type is Building, Floor or room. Or draw a Object. switch (buildingObj.GetBuildingType()) { case BuildingObjectType.Building: case BuildingObjectType.Floor: case BuildingObjectType.Room: foreach (BuildingObjectLib3DS child in buildingObj.GetChilds().Values) { DrawBuildingPart(gl, child, type); } break; case BuildingObjectType.Outside: case BuildingObjectType.Object: DrawObject(gl, buildingObj, type); break; default: break; } }
public ProfileDeviceEventsArg(DrawType updateType, ModuleDataModel dataModel, bool preview, DrawingContext drawingContext) { UpdateType = updateType.ToString().ToLower(); DataModel = dataModel; Preview = preview; DrawingContext = drawingContext; }
private static void Set(Rect r, Rect tooltipR, string tooltip, DrawType drawType) { TooltipHelper.startTime = EditorApplication.timeSinceStartup; TooltipHelper.fadeCompleted = false; TooltipHelper.drawType = DrawType.Label; TooltipHelper.content.text = tooltip; if (drawType == DrawType.Helpbox) { TooltipHelper.content.image = TooltipHelper.GetIconFromMessageType(); } else { TooltipHelper.content.image = null; } if (TooltipHelper.style == null) { TooltipHelper.style = new GUIStyle(EditorStyles.helpBox); } Vector2 size = TooltipHelper.style.CalcSize(TooltipHelper.content); tooltipR.width = size.x; tooltipR.height = size.y; TooltipHelper.uiRect = r; TooltipHelper.tooltipRect = tooltipR; TooltipHelper.hashCode = tooltip.GetHashCode(); }
private void DrawTypeSelected(object sender, EventArgs e) { var selectedItem = ((TextValue)((System.Windows.Forms.ComboBox)sender).SelectedItem); CurrDrawType = (DrawType)Convert.ToInt32(selectedItem.Value); label1.Text = selectedItem.Text; }
internal static void Draw(DrawType type, bool isClear, SKPaintSurfaceEventArgs e, float scale = 0.0f) { SKImageInfo info = e.Info; SKSurface surface = e.Surface; SKCanvas canvas = surface.Canvas; canvas.Clear(); if (isClear) { return; } switch (type) { case DrawType.Line: Line(info, canvas); break; case DrawType.Circle: Circle(info, canvas); break; case DrawType.MeasureText: MeasureText(info, canvas); break; case DrawType.CircleAnimation: CircleAnimation(info, canvas, scale); break; default: break; } }
// ------------------------------------------------------------------- // DrawTypeToString // ------------------------------------------------------------------- public static string DrawTypeToString(DrawType type) { switch (type) { case DrawType.None: return("None"); case DrawType.Floors: return("Floor"); case DrawType.Autotiles: return("Autotile"); case DrawType.FaceSprite: return("Face Sprite"); case DrawType.FixSprite: return("Fix Sprite"); case DrawType.DoubleSprite: return("Double Sprite"); case DrawType.QuadraSprite: return("Quadra Sprite"); case DrawType.OnFloorSprite: return("On floor Sprite"); case DrawType.Montains: return("Mountain"); default: return(""); } }
public CompositData(DrawMode drawMode, DrawType drawType) { DrawMode = drawMode; DrawType = drawType; Rect = new Rectangle(); }
public Graph(string name_, float maxY_, Color color_, DrawType type_) : this() { name = name_; maxY = maxY_; color = color_; drawType = type_; }
public void SetRectangle() { this.StartDraw = true; this.CurRect.LineWidth = 3; this.DrawTypes = DrawType.Rect; this.CurRect.LineColor = Color.Red; this.Cursor = Cursors.Cross; }
public ClientTextView(PointF point, string text, GTA.Font font, Color color) : base(point) { this.text = text; this.font = font; this.color = color; type = DrawType.Point; }
private static void DrawDraw(Vector3 center, float radius, Color color, DrawType DrawedType, int width = 5) { switch (DrawedType) { case DrawType.Circle: DrawCircle(center, radius, color, width); break; case DrawType.HINH1: DrawHinh1(center, radius, color, width); break; } }
public void Draw(Graphics g, Rectangle rect, DrawType dt) { Image toDraw; switch (dt) { case DrawType.eNormal: { toDraw = Normal; break; } case DrawType.eHover: { toDraw = Hover; break; } case DrawType.ePressed: { toDraw = Pressed; break; } default: { throw new ThemingError(this, "DrawType not set"); } } if (toDraw == null) throw new ThemingError(this, "Image null"); if (!IsNinePatch) { g.DrawImage(toDraw, rect); } else { int b = NinePatchBorder; int b2 = b * 2; g.DrawImage(toDraw, new Rectangle(0, 0, b, b), new Rectangle(0, 0, b, b), System.Drawing.GraphicsUnit.Pixel); g.DrawImage(toDraw, new Rectangle(rect.Width - b, 0, b, b), new Rectangle(toDraw.Width - b, 0, b, b), System.Drawing.GraphicsUnit.Pixel); g.DrawImage(toDraw, new Rectangle(0, rect.Height - b, b, b), new Rectangle(0, toDraw.Height - b, b, b), System.Drawing.GraphicsUnit.Pixel); g.DrawImage(toDraw, new Rectangle(rect.Width - b, rect.Height - b, b, b), new Rectangle(toDraw.Width - b, toDraw.Height - b, b, b), System.Drawing.GraphicsUnit.Pixel); //sides g.DrawImage(toDraw, new Rectangle(b, 0, rect.Width - b2, b), new Rectangle(b, 0, toDraw.Width - b2, 4), System.Drawing.GraphicsUnit.Pixel); g.DrawImage(toDraw, new Rectangle(b, rect.Height - b, rect.Width - 7, 5), new Rectangle(b, toDraw.Height - b, toDraw.Width - b2, b), System.Drawing.GraphicsUnit.Pixel); g.DrawImage(toDraw, new Rectangle(0, b, b, rect.Height - b2), new Rectangle(0, b, b, toDraw.Height - b2), System.Drawing.GraphicsUnit.Pixel); g.DrawImage(toDraw, new Rectangle(rect.Width - b, b, b, rect.Height - b2), new Rectangle(toDraw.Width - b, b, b, toDraw.Height - b2), System.Drawing.GraphicsUnit.Pixel); //centre g.DrawImage(toDraw, new Rectangle(b, b, rect.Width - b2, rect.Height - b2), new Rectangle(b, b, toDraw.Width - b2, toDraw.Height - b2), System.Drawing.GraphicsUnit.Pixel); } }
public DrawCommand(Texture2D texture, Vector2 position, Rectangle? sourceRect, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects = SpriteEffects.None, float layerDepth = 0, int maxlife = -1, ShaderPack? shaderPack = null) { this.type = DrawType.direct; this.texture2d = texture; this.position = position; this.color = color; this.permColor = color; this.scale = scale; this.rotation = rotation; this.sourceRect = sourceRect; this.origin = origin; this.effects = effects; this.layerDepth = layerDepth; this.maxlife = maxlife; this.life = maxlife; this.shaderPack = shaderPack ?? ShaderPack.Default; }
private void AddNewPosition(Point newPosition, DrawType drawType) { if (drawType == DrawType.Start) { currentPathGeometry.Figures.Add(new PathFigure { StartPoint = newPosition }); previousPosition = newPosition; } else { var currentFigure = currentPathGeometry.Figures.LastOrDefault(); if (currentFigure != null) { if (IsValidPosition(newPosition)) { currentFigure.Segments.Add(new LineSegment(newPosition, true)); previousPosition = newPosition; } } } }
public void SetDrawType(DrawType drawType) { switch(drawType) { case DrawType.Points: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList; break; case DrawType.LineList: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineList; break; case DrawType.LineStrip: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineStrip; break; case DrawType.Triangles: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; break; case DrawType.TriangleStrip: DeviceManager.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip; break; default: throw new NotSupportedException("Unexpected draw type: " + drawType); } }
public DrawCommand(string text, Vector2 position, Color color, float scale = 0.5f, int maxlife = -1, ShaderPack? shaderPack = null, float layerDepth = 0) { this.type = DrawType.drawString; this.position = position; this.color = color; this.permColor = color; this.layerDepth = layerDepth; this.scale = scale; this.text = text; this.maxlife = maxlife; this.life = maxlife; this.shaderPack = shaderPack ?? ShaderPack.Default; }
private void DrawLines(IEnumerable<TextPos> list, DrawType type) { foreach (var textPos in list) { var start = _richTextBox.GetPositionFromCharIndex(textPos.Start); var end = _richTextBox.GetPositionFromCharIndex(textPos.End); // The position above now points to the top left corner of the character. // We need to account for the character height so the underlines go // to the right place. end.X += 1; start.Y += TextBoxHelper.GetBaselineOffsetAtCharIndex(_richTextBox, textPos.Start); end.Y += TextBoxHelper.GetBaselineOffsetAtCharIndex(_richTextBox, textPos.End); if (start.X == -1 || end.X == -1) continue; // Draw the wavy underline/mark if (start.Y < end.Y) { switch (type) { case DrawType.Wave: DrawWave(start, new Point(_richTextBox.Width - 3, start.Y)); DrawWave(new Point(3, end.Y), end); break; case DrawType.Mark: DrawMark(start, new Point(_richTextBox.Width - 3, start.Y)); DrawMark(new Point(0, end.Y), end); break; } } else switch (type) { case DrawType.Wave: DrawWave(start, end); break; case DrawType.Mark: DrawMark(start, end); break; } } }
public DrawCommand(textures texture, Vector2 position, Rectangle? sourceRect, Color color, float rotation, Vector2 origin, Vector2 scalevect, SpriteEffects effects = SpriteEffects.None, float layerDepth = 0, int maxlife = -1, ShaderPack? shaderPack = null) { this.type = DrawType.vectScaled; this.texture = texture; this.position = position; this.color = color; this.permColor = color; this.scalevect = scalevect; this.rotation = rotation; this.sourceRect = sourceRect; this.origin = origin; this.effects = effects; this.layerDepth = layerDepth; this.maxlife = maxlife; this.life = maxlife; this.shaderPack = shaderPack ?? new ShaderPack(color); }
public void DrawLine(Command cmd, object param, DrawType drawtype, Point3D ptFrom, Point3D ptTo) { if (drawtype == DrawType.NoDraw) return; PaintEventArgs e = (PaintEventArgs)param; var from = ToClientF(ptFrom); var to = ToClientF(ptTo); if (PreDrawLineOrArc(param, drawtype, from, to)) { e.Graphics.DrawLine(GetPen(drawtype, LineDrawType.Line), from, to); } }
/// <summary> /// The drawing event call. /// </summary> /// <param name="drawType"> /// The draw Type. /// </param> public override void Draw(DrawType drawType) { if (this.Sprite != null && !this.Sprite.IsDisposed && this.IsVisible) { this.Sprite.Begin(this.SpriteFlags); if (this.Is3D && this.Effect != null && this.VertexBuffer != null && this.VertexDeclaration != null && !this.Effect.IsDisposed && !this.VertexDeclaration.IsDisposed && !this.VertexBuffer.IsDisposed) { var oldVertexDeclaration = Drawing.Direct3DDevice.VertexDeclaration; var position = this.GameObjectUnit != null && this.GameObjectUnit.IsValid ? this.GameObjectUnit.Position + this.Offset : this.Position3D + this.Offset; this.Effect.Begin(); this.Effect.BeginPass(0); this.Effect.SetValue( "ProjectionMatrix", Matrix.Translation(new Vector3(position.X, position.Z, position.Y)) * Drawing.View * Drawing.Projection); this.Effect.SetValue( "CircleColor", new Vector4(this.Color.R / 255f, this.Color.G / 255f, this.Color.B / 255f, this.Color.A / 255f)); Drawing.Direct3DDevice.SetStreamSource(0, this.VertexBuffer, 0, Utilities.SizeOf<Vector4>() * 2); Drawing.Direct3DDevice.VertexDeclaration = this.VertexDeclaration; Drawing.Direct3DDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); Drawing.Direct3DDevice.VertexDeclaration = oldVertexDeclaration; this.Effect.EndPass(); this.Effect.End(); } else if (!this.Is3D) { this.Line.Begin(); this.Line.Draw(this.vector2Vertices.Where(v => v.IsValid()).ToArray(), this.Color); this.Line.End(); } this.Sprite.Flush(); this.Sprite.End(); } this.CallOnDraw(); }
/// <summary> /// The drawing event call. /// </summary> /// <param name="drawType"> /// The draw Type. /// </param> public override void Draw(DrawType drawType) { if (this.Sprite != null && !this.Sprite.IsDisposed && this.Line != null && !this.Line.IsDisposed && this.IsVisible) { this.Sprite.Begin(this.SpriteFlags); this.Line.Begin(); this.Line.Draw( new[] { new Vector2(this.Position.X + this.Line.Width / 2f, this.Position.Y), new Vector2(this.Position.X + this.Line.Width / 2f, this.Position.Y + this.Height) }, this.Color); this.Line.End(); this.Sprite.Flush(); this.Sprite.End(); } this.CallOnDraw(); }
public PrimitiveShape(Vector2[] vertices, Color[] lineColor, DrawType type) { this.vertices = (Vector2[])vertices.Clone(); this.transformedVertices = new Vector2[vertices.Length]; this.type = type; this.lineColor = lineColor; CalculatePointsAndBounds(); }
/// <summary> /// Draw a mesh. /// </summary> /// <param name="gl">OpenGL handler.</param> /// <param name="buildingObj">The mesh.</param>BuildingObjectLib3DS _object, private void DrawMesh(OpenGL gl, Lib3dsMesh thisMesh, Hashtable textures, List<Lib3dsMaterial> matrials, DrawType type) { if (thisMesh == null || thisMesh.nfaces == 0) return; // Draw all the faces in this mesh. for (int j = 0; j < thisMesh.faces.Count; j++) { Lib3dsFace thisFace = thisMesh.faces[j]; float transparency = matrials[thisFace.material].transparency; //float[] fogColor = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f }; //float[] LightAmbient = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f }; //float[] LightDiffuse = new float[4] { 1.0f, 1.0f, 1.0f, 1.0f }; //float[] LightPosition = new float[4] { 0.0f, 0.0f, 2.0f, 1.0f }; switch (type) { case DrawType.WireFrame: gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_LINE); IsDrawTexture = false; gl.Color(0.5f, 0.5f, 0.5f, 0.5f); gl.LineWidth(1.5f); break; case DrawType.Full: IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name); gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL); break; case DrawType.Face: gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL); IsDrawTexture = false; break; case DrawType.Translucent: IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name); gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL); gl.Enable(OpenGL.GL_BLEND); gl.BlendFunc(OpenGL.GL_SRC_ALPHA,OpenGL.GL_ONE_MINUS_SRC_ALPHA); //gl.Enable(OpenGL.GL_TEXTURE_2D); // Enable Texture Mapping //gl.ShadeModel(OpenGL.GL_SMOOTH); // Enable Smooth Shading //gl.ClearColor(0.5f,0.5f,0.5f,1.0f); // We'll Clear To The Color Of The Fog //gl.ClearDepth(1.0f); // Depth Buffer Setup //gl.Enable(OpenGL.GL_DEPTH_TEST); // Enables Depth Testing //gl.DepthFunc(OpenGL.GL_LEQUAL); // The Type Of Depth Testing To Do //gl.Hint(OpenGL.GL_PERSPECTIVE_CORRECTION_HINT, OpenGL.GL_NICEST); // Really Nice Perspective Calculations //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, LightAmbient); // Setup The Ambient Light //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION,LightPosition); // Position The Light //gl.Enable(OpenGL.GL_LIGHT1); //gl.Fog(OpenGL.GL_FOG_COLOR, fogColor);//设置雾颜色,f是一个指定颜色的数组float f[4] //gl.Fog(OpenGL.GL_FOG_DENSITY, 0.85f); // 设置雾的密度 //gl.Hint(OpenGL.GL_FOG_HINT, OpenGL.GL_DONT_CARE); // 设置系统如何计算雾气 //gl.Fog(OpenGL.GL_FOG_START, 0.01f);//设置雾从多远开始 //gl.Fog(OpenGL.GL_FOG_END, 100.0f);//设置雾从多远结束 //gl.Fog(OpenGL.GL_FOG_MODE, OpenGL.GL_LINEAR);//设置使用哪种雾,共有三中雾化模式 //gl.Enable(OpenGL.GL_FOG);//打开雾效果 transparency = 0.2f; break; default: gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL); IsDrawTexture = false; break; } if (type != DrawType.WireFrame) { gl.Color(matrials[thisFace.material].diffuse[0], matrials[thisFace.material].diffuse[1], matrials[thisFace.material].diffuse[2], matrials[thisFace.material].transparency); } gl.Begin(OpenGL.GL_TRIANGLES); for (int k = 0; k != 3; ++k) { int index = thisFace.index[k]; if (IsDrawTexture) gl.TexCoord(thisMesh.texcos[index].s, thisMesh.texcos[index].t); gl.Vertex(thisMesh.vertices[index].x / 20, thisMesh.vertices[index].z / 20, -thisMesh.vertices[index].y / 20); } gl.End(); if(type == DrawType.Translucent) gl.Disable(OpenGL.GL_BLEND); } }
protected override void Update(GameTime gameTime) { mOldMouseState = mNewMouseState; mOldKeyboardState = mNewKeyboardState; mNewMouseState = Mouse.GetState(); mNewKeyboardState = Keyboard.GetState(); elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; mOldMousePos = mThisMousePos; mThisMousePos.X = mNewMouseState.X / mTileWidth; mThisMousePos.Y = mNewMouseState.Y / mTileWidth; int mouseDelta = (mOldMouseState.ScrollWheelValue - mNewMouseState.ScrollWheelValue) / 100; if (mouseDelta < 0 || (mouseDelta > 0 && mTileWidth > 1)) { mTileWidth = Math.Max(mTileWidth - mouseDelta, 1); MovableObject.Initalize(mGridWidth, mTileWidth); mGlobalScale = (float)mTileWidth / (float)mObjectTex.Width; mMovableObject = new MovableObject(new Vector2(16 * mGlobalScale, 16 * mGlobalScale)); } if (WasPressed(Keys.Escape)) { this.Exit(); } if (WasPressed(Keys.F1)) { graphics.ToggleFullScreen(); } if (WasPressed(Keys.C)) { this.Initialize(); } if (WasPressed(Keys.D)) { if (mDrawType != DrawType.DrawWay) mDrawType = DrawType.DrawWay; else mDrawType = DrawType.DrawWall; } if (WasPressed(EMouseButton.RightButton) == true) { Click = new Vector2(mNewMouseState.X, mNewMouseState.Y); mStartPoint = new Point((int)(mMovableObject.PositionCurrent.X / mTileWidth), (int)(mMovableObject.PositionCurrent.Y / mTileWidth)); mEndPoint = new Point(mThisMousePos.X, mThisMousePos.Y); mWatch = Stopwatch.StartNew(); if (mStartPoint == mEndPoint) { mMovableObject.LinearMove(mMovableObject.PositionCurrent, Click); } else { Stopwatch timeTest = Stopwatch.StartNew(); foundPath = mPathFinder.FindPath(mStartPoint, mEndPoint); timeTest.Stop(); Debug.Write("FindPath need " + timeTest.ElapsedMilliseconds + "ms"); if (foundPath != null) { Debug.WriteLine(" [" + foundPath.Count + " steps]"); mMovableObject.PathMove(ref foundPath, mMovableObject.PositionCurrent, Click); } else { Debug.WriteLine(" [FAILED TO FIND A WAY]"); } } } //Wall drawing / removing if (mNewMouseState.LeftButton == ButtonState.Pressed) { mThisMousePos.X = mNewMouseState.X / mTileWidth; mThisMousePos.Y = mNewMouseState.Y / mTileWidth; if ((mThisMousePos.X < mGridWidth) && (mThisMousePos.Y < mGridHeight) && (mThisMousePos.X >= 0) && (mThisMousePos.Y >= 0)) { switch (mDrawType) { case DrawType.DrawWall: PathGrid[mThisMousePos.X, mThisMousePos.Y] = 0; DrawGrid[mThisMousePos.X, mThisMousePos.Y] = 0; break; case DrawType.DrawWay: PathGrid[mThisMousePos.X, mThisMousePos.Y] = 1; DrawGrid[mThisMousePos.X, mThisMousePos.Y] = 1; break; } } } mMovableObject.Update(elapsedTime); ushort GridX = (ushort)(mPathFinder.PathGrid.GetUpperBound(0) + 1); ushort GridY = (ushort)(mPathFinder.PathGrid.GetUpperBound(1) + 1); if (mMovableObject.PositionChanged == false) { if (mWatch.IsRunning == true) mWatch.Stop(); mClearWalkPath += elapsedTime; if (mClearWalkPath >= 3f) { mClearWalkPath = 0f; mPathFinder.WalkedNodes = new byte[GridX, GridY]; } } else { mClearWalkPath = 0f; if (((int)mMovableObject.PositionCurrent.X / mTileWidth) < GridX && ((int)mMovableObject.PositionCurrent.Y / mTileWidth) < GridY) mPathFinder.WalkedNodes[(int)mMovableObject.PositionCurrent.X / mTileWidth, (int)mMovableObject.PositionCurrent.Y / mTileWidth] = 1; } base.Update(gameTime); }
public virtual void DrawRectangle(DrawType drawType) { if (drawType == DrawType.LINES || drawType == DrawType.FILL) { DrawStraightLine(new Vector2((int)rect.X, (int)rect.Y), new Vector2((int)rect.X + rect.Width, (int)rect.Y), sprite, color, THICKNESS); //top bar DrawStraightLine(new Vector2((int)rect.X, (int)rect.Y + rect.Height), new Vector2((int)rect.X + rect.Width + 1 * THICKNESS, (int)rect.Y + rect.Height), sprite, color, THICKNESS); //bottom bar DrawStraightLine(new Vector2((int)rect.X, (int)rect.Y), new Vector2((int)rect.X, (int)rect.Y + rect.Height), sprite, color, THICKNESS); //left bar DrawStraightLine(new Vector2((int)rect.X + rect.Width, (int)rect.Y), new Vector2((int)rect.X + rect.Width, (int)rect.Y + rect.Height), sprite, color, THICKNESS); //right bar } if (drawType == DrawType.FILL) { Setup.spriteBatch.Draw(sprite, new Vector2((float)rect.X, (float)rect.Y), rect, color * VISIBILITY, 0.0f, new Vector2(0, 0), 1.0f, SpriteEffects.None, 0.0f); } }
private Pen GetPen(DrawType moveType, LineDrawType drawtype) { switch (moveType) { default: case DrawType.NoMove: return _noMovePen; case DrawType.Fast: return _fastPen; case DrawType.Cut: return _cutPens[(int)drawtype]; case DrawType.LaserFast: return _laserFastPen; case DrawType.LaserCut: return _laserCutPen; } }
private bool PreDrawLineOrArc(object param, DrawType drawtype, PointF from, PointF to) { PaintEventArgs e = (PaintEventArgs)param; if (from.Equals(to)) { if (drawtype == DrawType.LaserCut) e.Graphics.DrawEllipse(GetPen(drawtype, LineDrawType.Dot), from.X, from.Y, 1, 1); else e.Graphics.DrawEllipse(GetPen(drawtype, LineDrawType.Dot), from.X, from.Y, 4, 4); return false; } return true; }
public void DrawArc(Command cmd, object param, DrawType drawtype, Point3D ptFrom, Point3D ptTo, Point3D pIJ, bool clockwise) { if (drawtype == DrawType.NoDraw) return; PaintEventArgs e = (PaintEventArgs)param; var from = ToClientF(ptFrom); var to = ToClientF(ptTo); pIJ = Rotate.Rotate(pIJ); double I = pIJ.X.Value; double J = pIJ.Y.Value; double R = Math.Sqrt(I * I + J * J); double cx = (ptFrom.X??0.0) + I; double cy = (ptFrom.Y??0.0) + J; double startAng = ConvertRadToDeg(Math.Atan2(J, I)); double endAng = ConvertRadToDeg(Math.Atan2(cy - (ptTo.Y??0.0), cx - (ptTo.X??0.0))); double diffAng = (endAng - startAng); if (startAng > endAng) diffAng += 360; if (clockwise == false) { startAng = endAng; diffAng = 360 - diffAng; while (diffAng > 360) diffAng -= 360; while (diffAng < -360) diffAng += 360; } var pt3d = new Point3D(cx - R * SignX, cy - R * SignY, ptFrom.Z??0); PointF rcfrom = ToClientF(pt3d); //Point rcfrom = new Point(ToClientXInt(cx - R * SignX), ToClientYInt(cy - R * SignY)); float RR = (float) ToClientSizeX(R * 2); var rec = new RectangleF(rcfrom, new SizeF(RR, RR)); //e.Graphics.DrawRectangle(_helpLine, rec); if (rec.Width > 0 && rec.Height > 0) { try { e.Graphics.DrawArc(GetPen(drawtype, LineDrawType.Arc), rec.X, rec.Y, rec.Width, rec.Height, (float)startAng, (float)diffAng); } catch (OutOfMemoryException) { // ignore this Exception } } }
public void DrawEllipse(Command cmd, object param, DrawType drawtype, Point3D ptCenter, int xradius, int yradius) { if (drawtype == DrawType.NoDraw) return; PaintEventArgs e = (PaintEventArgs)param; var from = ToClientF(ptCenter); e.Graphics.DrawEllipse(GetPen(drawtype, LineDrawType.Ellipse), from.X - xradius / 2, from.Y - yradius / 2, xradius, yradius); }
/// <summary> /// The drawing event call. /// </summary> /// <param name="drawType"> /// The draw Type. /// </param> public abstract void Draw(DrawType drawType);
/// <summary> /// The drawing event call. /// </summary> /// <param name="drawType"> /// The draw Type. /// </param> public override void Draw(DrawType drawType) { if (this.Sprite != null && !this.Sprite.IsDisposed && this.Texture != null && !this.Texture.IsDisposed && this.IsVisible) { var matrix = this.Sprite.Transform; this.Sprite.Begin(this.SpriteFlags); this.Sprite.Transform = Matrix.Scaling(this.Scale.X, this.Scale.Y, 0) * Matrix.RotationZ(this.Rotation) * Matrix.Translation(this.Position.X, this.Position.Y, 0); this.Sprite.Draw(this.Texture, this.Color, this.CorpRectangle); this.Sprite.Transform = matrix; this.sprite.Flush(); this.Sprite.End(); } this.CallOnDraw(); }
public PrimitiveShape(Vector2[] vertices, Color color, DrawType type) { this.vertices = (Vector2[])vertices.Clone(); this.transformedVertices = new Vector2[vertices.Length]; this.type = type; List<Color> temp = new List<Color>(); foreach (Vector2 vertice in this.vertices) { temp.Add(color); } this.lineColor = temp.ToArray(); CalculatePointsAndBounds(); }
private void InitForSimpleDrawing() { arm1.Center = new Point((drawBox.Left + (drawBox.Width/2)), (drawBox.Top + (drawBox.Height/2))); arm2.Center = new Point((drawBox.Left + (drawBox.Width/2)), (drawBox.Top + (drawBox.Height/2))); drawType = DrawType.Simple; }
private void DrawModels(DrawType technique) { foreach (RModel rModel in RModels) { rModel.DrawInstances(technique); } graphicsDevice.BlendState = BlendState.AlphaBlend; foreach (RModel rModel in AlphaBlendRModels) { rModel.DrawInstances(technique); } // graphicsDevice.BlendState = BlendState.Opaque; // we want alpha blend for the next thing we draw }
private void InitForBitBltDrawing() { arm1.Center = new Point(drawBox.Width/2, drawBox.Height/2); arm2.Center = new Point(drawBox.Width/2, drawBox.Height/2); drawType = DrawType.BitBlt; }
/// <summary> /// Draw a object. /// </summary> /// <param name="gl">OpenGL handler.</param> /// <param name="buildingObj">The object.</param> private void DrawObject(OpenGL gl, BuildingObjectLib3DS buildingObj, DrawType type) { Lib3dsMeshInstanceNode thisMeshInst = buildingObj.Object; if (thisMeshInst.childs.Count == 0) { // Maybe this object only have one mesh. Lib3dsMesh thisMesh = FindLib3dsMeshByName(thisMeshInst.name, buildingObj.Model.meshes); DrawMesh(gl, thisMesh, buildingObj.Textures, buildingObj.Model.materials, type); } else { // Draw all the meshes in this object. foreach (Lib3dsNode node in thisMeshInst.childs) { Lib3dsMesh thisMesh = FindLib3dsMeshByName(node.name, buildingObj.Model.meshes); DrawMesh(gl, thisMesh, buildingObj.Textures, buildingObj.Model.materials, type); } } }
public void DrawLine(string curveName, PointPairList pointPairList, DrawType drawType, Color color) { if (!HasInitialized) throw new Exception("ZedGraphHelper hasn't been initialized!"); switch (drawType) { case DrawType.DotNoLine: zedGraph.AddDots(curveName, pointPairList, color); break; case DrawType.DotLine: zedGraph.AddLineWithDots(curveName, pointPairList, color); break; case DrawType.LineNoDot: zedGraph.AddLineWithoutDots(curveName, pointPairList, color); break; } }