public void SetBrushOnLineSketchObjectRedo() { ICommand addCommand = new AddControlPointCommand(this.Line, new Vector3(0, 0, 0)); Invoker.ExecuteCommand(addCommand); addCommand = new AddControlPointCommand(this.Line, new Vector3(1, 1, 1)); Invoker.ExecuteCommand(addCommand); addCommand = new AddControlPointCommand(this.Line, new Vector3(2, 2, 0)); Invoker.ExecuteCommand(addCommand); Assert.AreEqual((2 * 20 + 2) * 7, this.Line.GetComponent <MeshFilter>().sharedMesh.vertices.Length); LineBrush brush = this.Line.GetBrush() as LineBrush; brush.SketchMaterial.AlbedoColor = Color.green; brush.CrossSectionVertices.Add(Vector3.one); brush.CrossSectionNormals.Add(Vector3.one); ICommand SetBrushCommand = new SetBrushCommand(this.Line, brush); Invoker.ExecuteCommand(SetBrushCommand); Invoker.Undo(); Invoker.Redo(); Assert.AreEqual(Color.green, this.Line.GetComponent <MeshRenderer>().sharedMaterial.color); LineBrush updatedBrush = this.Line.GetBrush() as LineBrush; Assert.AreEqual(Color.green, updatedBrush.SketchMaterial.AlbedoColor); Assert.AreEqual((2 * 20 + 2) * 8, this.Line.GetComponent <MeshFilter>().sharedMesh.vertices.Length); }
public override void LoadContent() { _circleBrush = new CircleBrush(64, Color.White, Color.Black); _circleBrush.Load(ScreenManager.GraphicsDevice); _circleBody = BodyFactory.Instance.CreateCircleBody(PhysicsSimulator, 64, 1); _circleBody.Position = new Vector2(725, 384); _circleGeom = GeomFactory.Instance.CreateCircleGeom(PhysicsSimulator, _circleBody, 64, 20); _rectangleBody = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 128, 1); _rectangleBody.Position = new Vector2(256, 384); _rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(PhysicsSimulator, _rectangleBody, 128, 128); _rectangleBrush = new RectangleBrush(128, 128, Color.Gold, Color.Black); _rectangleBrush.Load(ScreenManager.GraphicsDevice); _p1 = ScreenManager.ScreenCenter; _p2 = _circleGeom.Position; _lineBrush = new LineBrush(1, Color.Black); _lineBrush.Load(ScreenManager.GraphicsDevice); _marker = new CircleBrush(3, Color.Red, Color.Red); _marker.Load(ScreenManager.GraphicsDevice); base.LoadContent(); }
public override void LoadContent() { base.LoadContent(); _lineBrush = new LineBrush(2); _lineBrush.LoadContent(XnaDartsGame.ScreenManager.GraphicsDevice); }
public override void Initialize() { Form = new Form(Game); Form.MainForm = false; lb = new LineBrush(Game.GraphicsDevice, 1); Resize(_size); }
public void DrawSkeleton(SpriteBatch spriteBatch, LineBrush lb, Vector2 position, Vector2 size, Color color, int skeletonId = 0) { if (Skeletons.Length <= skeletonId || Skeletons[skeletonId] == null) { //Skeleton not found. Draw an X lb.Draw(spriteBatch, position, position + size, color); lb.Draw(spriteBatch, new LineSegment(position.X + size.X, position.Y, position.X, position.Y + size.Y), color); return; } //Right Hand lb.Draw(spriteBatch, ToVector2(JointType.HandRight, size, skeletonId), ToVector2(JointType.WristRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.WristRight, size, skeletonId), ToVector2(JointType.ElbowRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.ElbowRight, size, skeletonId), ToVector2(JointType.ShoulderRight, size, skeletonId), color, position); //Head & Shoulders lb.Draw(spriteBatch, ToVector2(JointType.ShoulderRight, size, skeletonId), ToVector2(JointType.ShoulderCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.Head, size, skeletonId), ToVector2(JointType.ShoulderCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.ShoulderCenter, size, skeletonId), ToVector2(JointType.ShoulderLeft, size, skeletonId), color, position); //Left Hand lb.Draw(spriteBatch, ToVector2(JointType.HandLeft, size, skeletonId), ToVector2(JointType.WristLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.WristLeft, size, skeletonId), ToVector2(JointType.ElbowLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.ElbowLeft, size, skeletonId), ToVector2(JointType.ShoulderLeft, size, skeletonId), color, position); //Hips & Spine lb.Draw(spriteBatch, ToVector2(JointType.HipLeft, size, skeletonId), ToVector2(JointType.HipCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.HipRight, size, skeletonId), ToVector2(JointType.HipCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.Spine, size, skeletonId), ToVector2(JointType.HipCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.Spine, size, skeletonId), ToVector2(JointType.ShoulderCenter, size, skeletonId), color, position); //Left foot lb.Draw(spriteBatch, ToVector2(JointType.HipLeft, size, skeletonId), ToVector2(JointType.KneeLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.KneeLeft, size, skeletonId), ToVector2(JointType.AnkleLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.AnkleLeft, size, skeletonId), ToVector2(JointType.FootLeft, size, skeletonId), color, position); //Right foot lb.Draw(spriteBatch, ToVector2(JointType.HipRight, size, skeletonId), ToVector2(JointType.KneeRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.KneeRight, size, skeletonId), ToVector2(JointType.AnkleRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.AnkleRight, size, skeletonId), ToVector2(JointType.FootRight, size, skeletonId), color, position); }
private void LoadSpringContent(GraphicsDevice graphicsDevice) { _springLineBrush = new LineBrush(_springLineThickness, _springLineColor); _springCircleBrush = new CircleBrush(2, _springLineColor, _springLineColor); _springLineBrush.Load(graphicsDevice); _springCircleBrush.Load(graphicsDevice); }
private void LoadRevoluteJointContent(GraphicsDevice graphicsDevice) { _revoluteJointLineBrush = new LineBrush(_revoluteJointLineThickness, _revoluteJointColor); _revoluteJointRectangleBrush = new RectangleBrush(10, 10, _revoluteJointColor, _revoluteJointColor); _revoluteJointLineBrush.Load(graphicsDevice); _revoluteJointRectangleBrush.Load(graphicsDevice); }
private void LoadSliderJointContent(GraphicsDevice graphicsDevice) { _sliderJointLineBrush = new LineBrush(_sliderJointLineThickness, _sliderJointColor); _sliderJointRectangleBrush = new RectangleBrush(10, 10, _sliderJointColor, _sliderJointColor); _sliderJointLineBrush.Load(graphicsDevice); _sliderJointRectangleBrush.Load(graphicsDevice); }
public override void Initialize() { base.Initialize(); form = new Form(game); form.MouseSpeed = 0; Reset(); lb = new LineBrush(game.GraphicsDevice, 1); }
void Reset() { PhysicsSimulator.Game = game; sim = new PhysicsSimulator(); sim.Gravity *= 2.0f; lb = new LineBrush(game.GraphicsDevice, 1); poly = new Polygon(); poly.AddVertex(0, 0); poly.AddVertex(0, 150); poly.AddVertex(100, 150); poly.AddVertex(100, 0);/* * poly.AddVertex(50, 100); * poly.AddVertex(50, 50); * poly.AddVertex(100, 50); * poly.AddVertex(100, 0);*/ poly.Triangulate(); var poly2 = new Polygon(); poly2.AddVertex(0, 500); poly2.AddVertex(500, 400); poly2.AddVertex(800, 500); poly2.AddVertex(800, 600); poly2.AddVertex(0, 600); poly2.Triangulate(); var poly3 = new Polygon(); poly3.AddVertex(700, 0); poly3.AddVertex(800, 0); poly3.AddVertex(800, 450); poly3.AddVertex(700, 450); poly3.Triangulate(); var circle = Polygon.BuildCircle(20, new Vector2(600), 90); circle.Triangulate(); bodies = new List <Body>(); bodies.Add(new Body(sim, game, poly, 10)); bodies.Add(new Body(sim, game, poly2, 10)); bodies.Add(new Body(sim, game, poly3, 10)); bodies.Add(new Body(sim, game, circle, 10)); //body1.AttachToGravity = false; bodies[1].IsStatic = true; bodies[2].IsStatic = true; bodies[3].IsStatic = true; //body2.IsFree = true; palette = new List <Color>(); for (int i = 0; i < 10; i++) { palette.Add(GraphicsHelper.GetRandomColor()); } }
public Brush GetBrush() { LineBrush brush = new LineBrush(); brush.SketchMaterial = new SketchMaterialData(meshRenderer.sharedMaterial); brush.CrossSectionScale = this.lineDiameter; brush.InterpolationSteps = this.InterpolationSteps; SplineMesh.GetCrossSectionShape(out brush.CrossSectionVertices, out brush.CrossSectionNormals); return(brush); }
public void PaintWorld(WorldLayer layer) { if (!Hud.Game.Me.IsInTown) { IScreenCoordinate coord = Hud.Window.CreateScreenCoordinate(Hud.Window.CursorX, Hud.Window.CursorY); IWorldCoordinate cursor = coord.ToWorldCoordinate(); int count = 0; foreach (IMonster monster in Hud.Game.AliveMonsters) { if (monster.FloorCoordinate.XYDistanceTo(cursor) < Distance) { count++; } } if (DrawCursorCircle) { CursorCircleBrush.DrawWorldEllipse(Distance, -1, cursor); } if (DrawCursorLabel) { float width = Hud.Window.Size.Height * CursorLabelWRatio; float height = Hud.Window.Size.Height * CursorLabelHRatio; CursorLabelDecorator.Paint(coord.X + CursorLabelXOffset, coord.Y + CursorLabelYOffset, width, height, count.ToString(), null, ""); } if (DrawTopLabel) { float x = Hud.Window.Size.Width * TopLabelXRatio; float y = Hud.Window.Size.Height * TopLabelYRatio; float width = Hud.Window.Size.Height * TopLabelWRatio; float height = Hud.Window.Size.Height * TopLabelHRatio; TopLabelDecorator.Paint(x - width / 2, y, width, height, count.ToString(), null, ""); } if (DrawCursorLine) { var player = Hud.Game.Me.ScreenCoordinate; LineBrush.DrawLine(player.X, player.Y, coord.X, coord.Y); } if (DrawDistanceLabel) { var distance = Hud.Game.Me.FloorCoordinate.XYDistanceTo(cursor); float x = Hud.Window.Size.Width * DistanceLabelXRatio; float y = Hud.Window.Size.Height * DistanceLabelYRatio; float width = Hud.Window.Size.Height * DistanceLabelWRatio; float height = Hud.Window.Size.Height * DistanceLabelHRatio; TopLabelDecorator.Paint(x - width / 2, y, width, height, distance.ToString("F1", CultureInfo.InvariantCulture)); } } }
public void Draw(SpriteBatch spriteBatch, LineBrush lb, Color color, Vector2 offset, bool?showTriangles = null) { if ((showTriangles.HasValue && showTriangles.Value) || ShowTriangles) { foreach (var item in Bodies) { if (item.Mesh.Triangles != null) { foreach (var tri in item.Mesh.Triangles) { tri.Draw(spriteBatch, lb, offset, color); } } } } else { foreach (var item in Bodies) { item.Mesh.Draw(spriteBatch, lb, offset, color); } } }
static void DrawPrimitives(IEnumerable <Drawable> primitives, Cairo.Context grw) { foreach (var p in primitives) { var l = p as LineElement; if (l != null) { LineBrush.Draw(grw, l); } var a = p as ArcElement; if (a != null) { ArcBrush.Draw(grw, a); } var a3 = p as Arc3PointsElement; if (a3 != null) { Arc3PointsBrush.Draw(grw, a3); } var t = p as TextElement; if (t != null) { TextBrush.Draw(grw, t); } var r = p as RectangleElement; if (r != null) { RectangleBrush.Draw(grw, r); } } }
protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { if (IsInHitTest) { return; } int lastBar = ChartBars.ToIndex; int firstBar = ChartBars.FromIndex; double highPrice = 0; double lowPrice = double.MaxValue; SharpDX.Direct2D1.Brush brushDown = BarDownBrush.ToDxBrush(RenderTarget); SharpDX.Direct2D1.Brush lineBrush = LineBrush.ToDxBrush(RenderTarget); SharpDX.Direct2D1.Brush brushUp = BarUpBrush.ToDxBrush(RenderTarget); brushDown.Opacity = (float)(Opacity / 100.0); brushUp.Opacity = (float)(Opacity / 100.0); for (int idx = firstBar; idx <= lastBar && idx >= 0; idx++) { highPrice = Math.Max(highPrice, Bars.GetHigh(idx)); lowPrice = Math.Min(lowPrice, Bars.GetLow(idx)); } int volumeBarCount = BarCount; double priceRange = highPrice - lowPrice; double priceBoxSize = priceRange / volumeBarCount; double volumeMax = 0; // Pass 1: Fill all VolumeInfo structures with appropriate data for (int i = 0; i < volumeBarCount; i++) { double priceUpper = lowPrice + priceBoxSize * (i + 1); double priceLower = lowPrice + priceBoxSize * i; double priceVolumeUp = 0; double priceVolumeDown = 0; for (int idx = firstBar; idx <= lastBar; idx++) { double checkPrice; PriceSeries series = (Inputs[0] as PriceSeries); switch (series.PriceType) { case PriceType.Open: checkPrice = Bars.GetOpen(idx); break; case PriceType.Close: checkPrice = Bars.GetClose(idx); break; case PriceType.High: checkPrice = Bars.GetHigh(idx); break; case PriceType.Low: checkPrice = Bars.GetLow(idx); break; case PriceType.Median: checkPrice = (Bars.GetHigh(idx) + Bars.GetLow(idx)) / 2; break; case PriceType.Typical: checkPrice = (Bars.GetHigh(idx) + Bars.GetLow(idx) + Bars.GetClose(idx)) / 3; break; case PriceType.Weighted: checkPrice = (Bars.GetHigh(idx) + Bars.GetLow(idx) + 2 * Bars.GetClose(idx)) / 4; break; default: checkPrice = Bars.GetClose(idx); break; } if (checkPrice >= priceLower && checkPrice < priceUpper) { if (Bars.GetOpen(idx) < Bars.GetClose(idx)) { priceVolumeUp += Bars.GetVolume(idx); } else { priceVolumeDown += Bars.GetVolume(idx); } } } volumeInfo[i].up = priceVolumeUp; volumeInfo[i].down = priceVolumeDown; volumeInfo[i].total = priceVolumeUp + priceVolumeDown; volumeMax = Math.Max(volumeMax, volumeInfo[i].total); } // Pass 2: Paint the volume bars for (int i = 0; i < Math.Min(volumeBarCount, lastBar - firstBar + 1); i++) { double priceUpper = lowPrice + priceBoxSize * (i + 1); double priceLower = lowPrice + priceBoxSize * i; int yUpper = Convert.ToInt32(chartScale.GetYByValue(priceUpper)) + BarSpacing; int yLower = Convert.ToInt32(chartScale.GetYByValue(priceLower)); int barWidthUp = (int)((chartScale.Height / 2) * (volumeInfo[i].up / volumeMax)); int barWidthDown = (int)((chartScale.Height / 2) * (volumeInfo[i].down / volumeMax)); SharpDX.RectangleF rect = new SharpDX.RectangleF(ChartPanel.X, yUpper, barWidthUp, Math.Abs(yUpper - yLower)); RenderTarget.FillRectangle(rect, brushUp); RenderTarget.DrawRectangle(rect, brushUp); SharpDX.RectangleF rect2 = new SharpDX.RectangleF(ChartPanel.X + barWidthUp, yUpper, barWidthDown, Math.Abs(yUpper - yLower)); RenderTarget.DrawRectangle(rect2, brushDown); RenderTarget.FillRectangle(rect2, brushDown); if (DrawLines) { RenderTarget.DrawLine(new SharpDX.Vector2(ChartPanel.X, yLower), new SharpDX.Vector2(ChartPanel.X + ChartPanel.W, yLower), lineBrush); if (i == volumeBarCount - 1) { RenderTarget.DrawLine(new SharpDX.Vector2(ChartPanel.X, yUpper), new SharpDX.Vector2(ChartPanel.X + ChartPanel.W, yUpper), lineBrush); } } } lineBrush.Dispose(); brushDown.Dispose(); brushUp.Dispose(); }
protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { if (Bars == null || Bars.Instrument == null || IsInHitTest) { return; } int firstBarIdxToPaint = -1; double tickSize = Bars.Instrument.MasterInstrument.TickSize; double volumeMax = 0; SharpDX.Direct2D1.Brush upBrush = VolumeUpBrush.ToDxBrush(RenderTarget); SharpDX.Direct2D1.Brush downBrush = VolumeDownBrush.ToDxBrush(RenderTarget); SharpDX.Direct2D1.Brush neutralBrush = VolumeNeutralBrush.ToDxBrush(RenderTarget); SharpDX.Direct2D1.Brush lineBrushDx = LineBrush.ToDxBrush(RenderTarget); upBrush.Opacity = (float)(alpha / 100.0); downBrush.Opacity = (float)(alpha / 100.0); neutralBrush.Opacity = (float)(alpha / 100.0); for (int i = newSessionBarIdx.Count - 1; i >= 0; i--) { int prevSessionBreakIdx = newSessionBarIdx[i]; if (prevSessionBreakIdx <= ChartBars.ToIndex) { startIndexOf = newSessionBarIdx.IndexOf(prevSessionBreakIdx); firstBarIdxToPaint = prevSessionBreakIdx; break; } } if (sortedDicList.Count < 1 && cacheDictionary.Keys.Count > 0) { sortedDicList.Add(cacheDictionary); } foreach (Dictionary <double, VolumeInfoItem> tmpDict in sortedDicList) { foreach (KeyValuePair <double, VolumeInfoItem> keyValue in tmpDict) { double price = keyValue.Key; if (Bars.BarsType.IsIntraday && (price > chartScale.MaxValue || price < chartScale.MinValue)) { continue; } VolumeInfoItem vii = keyValue.Value; double total = vii.up + vii.down + vii.neutral; volumeMax = Math.Max(volumeMax, total); } } if (volumeMax.ApproxCompare(0) == 0) { return; } int viiPositions = 0; foreach (KeyValuePair <double, VolumeInfoItem> keyValue in sortedDicList[startIndexOf]) { viiPositions++; VolumeInfoItem vii = keyValue.Value; double priceLower = keyValue.Key - tickSize / 2; float yLower = chartScale.GetYByValue(priceLower); float yUpper = chartScale.GetYByValue(priceLower + tickSize); float height = Math.Max(1, Math.Abs(yUpper - yLower) - barSpacing); int barWidthUp = (int)((ChartPanel.W / 2) * (vii.up / volumeMax)); int barWidthNeutral = (int)((ChartPanel.W / 2) * (vii.neutral / volumeMax)); int barWidthDown = (int)((ChartPanel.W / 2) * (vii.down / volumeMax)); float stationaryXpos = chartControl.GetXByBarIndex(ChartBars, !Bars.IsTickReplay ? ChartBars.FromIndex : Math.Max(ChartBars.FromIndex, firstBarIdxToPaint)); float xpos = chartControl.GetXByBarIndex(ChartBars, !Bars.IsTickReplay ? ChartBars.FromIndex : Math.Max(1, Math.Max(ChartBars.FromIndex, firstBarIdxToPaint)) - 1); RenderTarget.FillRectangle(new SharpDX.RectangleF(xpos, yUpper, barWidthUp, height), upBrush); xpos += barWidthUp; RenderTarget.FillRectangle(new SharpDX.RectangleF(xpos, yUpper, barWidthNeutral, height), neutralBrush); xpos += barWidthNeutral; RenderTarget.FillRectangle(new SharpDX.RectangleF(xpos, yUpper, barWidthDown, height), downBrush); if (!drawLines) { continue; } // Lower line RenderTarget.DrawLine(new SharpDX.Vector2(stationaryXpos, yLower), new SharpDX.Vector2((ChartPanel.X + ChartPanel.W), yLower), lineBrushDx); // Upper line (only at very top) if (viiPositions == sortedDicList[startIndexOf].Count) { RenderTarget.DrawLine(new SharpDX.Vector2(stationaryXpos, yUpper), new SharpDX.Vector2((ChartPanel.X + ChartPanel.W), yUpper), lineBrushDx); } } lineBrushDx.Dispose(); upBrush.Dispose(); downBrush.Dispose(); neutralBrush.Dispose(); }
void Awake() { _main = this; lineRenderer = GetComponent <LineRenderer>(); }
public void PaintTopInGame(ClipState clipState) { if (clipState != ClipState.BeforeClip) { return; } var uiBar = Hud.Render.MonsterHpBarUiElement; var monster = Hud.Game.SelectedMonster2 ?? Hud.Game.SelectedMonster1; if ((monster == null) || (uiBar == null)) { return; } var hpText = GLQ_BasePluginCN.ValueToString(monster.CurHealth, ValueFormat.LongNumber) + " / " + GLQ_BasePluginCN.ValueToString(monster.MaxHealth, ValueFormat.LongNumber); hpText += " - " + GLQ_BasePluginCN.ValueToString(monster.CurHealth / (monster.MaxHealth / 100.0f), ValueFormat.LongNumber) + "%"; var textLayout = MonsterHitpointsFont.GetTextLayout(hpText); MonsterHitpointsFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height - textLayout.Metrics.Height) / 2); string textCC = null; if (monster.Frozen) { textCC += (textCC == null ? "" : ", ") + "冰冻"; } if (monster.Chilled) { textCC += (textCC == null ? "" : ", ") + "寒冷"; } if (monster.Slow) { textCC += (textCC == null ? "" : ", ") + "减速"; } if (monster.Stunned) { textCC += (textCC == null ? "" : ", ") + "昏迷"; } if (monster.Invulnerable) { BorderBrush.DrawRectangle(uiBar.Rectangle.Left, uiBar.Rectangle.Top, uiBar.Rectangle.Width, uiBar.Rectangle.Height); textCC += (textCC == null ? "" : ", ") + "无敌"; } if (monster.Blind) { textCC += (textCC == null ? "" : ", ") + "致盲"; } string textDebuff = null; if (monster.Locust) { textDebuff += (textDebuff == null ? "" : ", ") + "虫群"; } if (monster.Palmed) { textDebuff += (textDebuff == null ? "" : ", ") + "爆裂掌"; } if (monster.Haunted) { textDebuff += (textDebuff == null ? "" : ", ") + "蚀魂"; } if (monster.MarkedForDeath) { textDebuff += (textDebuff == null ? "" : ", ") + "标记"; } if (monster.Strongarmed) { textDebuff += (textDebuff == null ? "" : ", ") + "力士"; } if (monster.Phoenixed) { textDebuff += (textDebuff == null ? "" : ", ") + "火鸟"; } if (isKrysbin(monster)) { textDebuff += (textDebuff == null ? "" : ", ") + "克利斯宾"; } var text = textCC + (textCC != null && textDebuff != null ? " | " : "") + textDebuff; if (monster.DotDpsApplied > 0) { text += (string.IsNullOrEmpty(text) ? "" : " | ") + "DOT: " + GLQ_BasePluginCN.ValueToString(monster.DotDpsApplied, ValueFormat.LongNumber); } if (text != null) { textLayout = MonsterEffectsFont.GetTextLayout(text); MonsterEffectsFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top - (uiBar.Rectangle.Height * 0.38f) - textLayout.Metrics.Height); } if (monster.SummonerAcdDynamicId != 0 && monster.IsElite) { LineBrush.DrawLine(uiBar.Rectangle.Left, uiBar.Rectangle.Top - uiBar.Rectangle.Height * 1.5f, uiBar.Rectangle.Right, uiBar.Rectangle.Top + uiBar.Rectangle.Height + uiBar.Rectangle.Height * 1.5f, 0); LineBrush.DrawLine(uiBar.Rectangle.Left, uiBar.Rectangle.Top + uiBar.Rectangle.Height + uiBar.Rectangle.Height * 1.5f, uiBar.Rectangle.Right, uiBar.Rectangle.Top - uiBar.Rectangle.Height * 1.5f, 0); } }
protected override void LoadContent() { Debug.WriteLine("Begin NeatGame.LoadContent"); // Create a new SpriteBatch, which can be used to draw textures. SpriteBatch = new SpriteBatch(GraphicsDevice); LoadSong("Sounds\\blank"); //LoadVideo("Videos\\errorvideo","error"); videoPlayers.Add(new VideoPlayer()); LoadSound("Sounds\\mute"); LoadSound("Sounds\\BLEEP10"); LoadSound("Sounds\\BLEEP3"); LoadSound("Sounds\\BLEEP6"); LoadSound(@"Sounds\elegantdying"); LoadSound(@"Sounds\typewriter-key-1", "console_keystroke"); LoadSound(@"Sounds\typewriter-backspace-1", "console_backspace"); LoadSound(@"Sounds\typewriter-paper-roll-up-1", "console_echo"); LoadSound(@"Sounds\typewriter-return-1", "console_return"); LoadSound(@"Sounds\typewriter-space-bar-1", "console_space"); LoadTexture("Sprites\\Blank"); LoadTexture("Sprites\\Solid"); LoadTexture("Sprites\\Error"); LoadTexture("Sprites\\Transparent"); LoadTexture("Sprites\\gamerCardHUD"); LoadTexture("Sprites\\mediaHUD"); LoadTexture("Sprites\\menuFocus"); LoadTexture("Sprites\\buttonBG1", "buttonBG"); LoadTexture("Sprites\\MessageBox", "MessageBoxWindow"); LoadTexture("Sprites\\msgbox_text", "MessageBoxWindow_TextBox"); LoadTexture("Sprites\\msgbox_yesno", "MessageBoxWindow_YesNo"); LoadTexture("Sprites\\msgbox_button", "MessageBoxWindow_Button"); LoadTexture("Sprites\\msgbox_buttonFocus", "MessageBoxWindow_ButtonFocused"); LoadTexture("Sprites\\checked", "checkedbox"); LoadTexture("Sprites\\Checkbox", "uncheckedbox"); LoadTexture("Sprites\\icon"); LoadTexture("Sprites\\neatlogo"); LoadTexture("Sprites\\pointers"); CreateSprite("mousepointer", "pointers", new Rectangle(1, 33, 17, 32)); CreateSprite("handleft", "pointers", new Rectangle(33, 1, 32, 32)); CreateSprite("handright", "pointers", new Rectangle(1, 1, 32, 32)); CreateSprite("handleft_pushed", "pointers", new Rectangle(33, 1, 32, 32)); CreateSprite("handright_pushed", "pointers", new Rectangle(1, 1, 32, 32)); LoadTexture("Sprites\\WindowSheet"); CreateSprite("window_tl", "windowsheet", new Rectangle(0, 0, 11, 35)); CreateSprite("window_tm", "windowsheet", new Rectangle(19, 0, 25, 38)); CreateSprite("window_tr", "windowsheet", new Rectangle(55, 0, 7, 35)); CreateSprite("window_v", "windowsheet", new Rectangle(0, 40, 4, 10)); CreateSprite("window_bl", "windowsheet", new Rectangle(0, 61, 5, 5)); CreateSprite("window_br", "windowsheet", new Rectangle(57, 61, 5, 5)); CreateSprite("window_h", "windowsheet", new Rectangle(19, 62, 25, 4)); CreateSprite("trackbar_lu", "windowsheet", new Rectangle(68, 2, 17, 20)); CreateSprite("trackbar_lc", "windowsheet", new Rectangle(68, 22, 17, 15)); CreateSprite("trackbar_lb", "windowsheet", new Rectangle(68, 37, 17, 22)); CreateSprite("trackbar_ct", "windowsheet", new Rectangle(85, 2, 14, 20)); CreateSprite("trackbar_cc", "windowsheet", new Rectangle(85, 22, 14, 15)); CreateSprite("trackbar_cb", "windowsheet", new Rectangle(85, 37, 14, 22)); CreateSprite("trackbar_ru", "windowsheet", new Rectangle(215, 2, 17, 20)); CreateSprite("trackbar_rc", "windowsheet", new Rectangle(215, 22, 17, 15)); CreateSprite("trackbar_rb", "windowsheet", new Rectangle(215, 37, 17, 22)); CreateSprite("trackbar_gu", "windowsheet", new Rectangle(232, 2, 21, 20)); CreateSprite("trackbar_gc", "windowsheet", new Rectangle(232, 22, 21, 15)); CreateSprite("trackbar_gb", "windowsheet", new Rectangle(232, 37, 21, 22)); LoadTexture("Sprites\\kinect\\tiltbuttons"); CreateSprite("tilt_up", "tiltbuttons", new Rectangle(0, 0, 128, 128)); CreateSprite("tilt_down", "tiltbuttons", new Rectangle(0, 128, 128, 128)); CreateSprite("kinect_seated", "tiltbuttons", new Rectangle(128, 128, 128, 128)); CreateSprite("kinect_standing", "tiltbuttons", new Rectangle(128, 0, 128, 128)); NormalFont = Content.Load <SpriteFont>("Fonts\\normal"); LoadFont("Normal", NormalFont); LoadFont("Fonts\\smallFont"); LoadFont("Fonts\\menuFont"); LoadFont("Fonts\\Cambria"); LoadFont("Fonts\\Calibri"); LoadFont("Fonts\\messageBoxTitleFont"); LoadFont("Fonts\\messageBoxTextFont"); LoadFont("Fonts\\consolefont"); LoadFont("Fonts\\fxFont"); LoadFont(@"Fonts\FormFont"); LoadFont(@"Fonts\ElegantFont"); LoadEffect("Effects\\ColorFilter"); LoadEffect(@"Effects\Ripple"); LoadEffect(@"Effects\Crop"); LoadEffect(@"Effects\TextureWrapper"); LoadEffect(@"Effects\Circle"); BasicLine = new LineBrush(GraphicsDevice, 1); ElegantTextEngine.LoadContent(); Debug.WriteLine("Begin Screens LoadContent"); foreach (var p in Screens) { Debug.WriteLine("LoadContent: " + p.Key); p.Value.LoadContent(); } Debug.WriteLine("End NeatGame.LoadContent"); }
private void LoadAABBContent(GraphicsDevice graphicsDevice) { //load aabb texture _aabbLineBrush = new LineBrush(_aabbLineThickness, _aabbColor); _aabbLineBrush.Load(graphicsDevice); }
private void LoadEdgeContent(GraphicsDevice graphicsDevice) { _edgeLineBrush = new LineBrush(_edgeLineThickness, _edgeColor); _edgeLineBrush.Load(graphicsDevice); }
// Start is called before the first frame update void Start() { //Create a SketchWorld, many commands require a SketchWorld to be present SketchWorld = Instantiate(Defaults.SketchWorldPrefab).GetComponent <SketchWorld>(); //Create a LineSketchObject LineSketchObject = Instantiate(Defaults.LineSketchObjectPrefab).GetComponent <LineSketchObject>(); Invoker = new CommandInvoker(); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 4, 2))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 3))); Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 2))); Invoker.Undo(); Invoker.Redo(); LineBrush brush = this.LineSketchObject.GetBrush() as LineBrush; brush.CrossSectionVertices = CircularCrossSection.GenerateVertices(3); brush.CrossSectionNormals = CircularCrossSection.GenerateVertices(3, 1); Invoker.ExecuteCommand(new SetBrushCommand(this.LineSketchObject, brush)); //oder ohne Command //this.LineSketchObject.SetBrush(brush); //oder nur //this.LineSketchObject.SetLineCrossSection(... //Create a RibbonSketchObject RibbonSketchObject = Instantiate(Defaults.RibbonSketchObjectPrefab).GetComponent <RibbonSketchObject>(); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(1, 1, 1), Quaternion.identity)); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(1.5f, 1.1f, 1), Quaternion.Euler(0, 0, 0))); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(2f, 1.2f, 1), Quaternion.Euler(22, 0, 0))); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(2.5f, 1.3f, 1), Quaternion.Euler(45, 0, 0))); Invoker.ExecuteCommand(new AddPointAndRotationCommand(RibbonSketchObject, new Vector3(3f, 1.4f, 1), Quaternion.Euler(60, 0, 0))); //Create a PatchSketchObject PatchSketchObject = Instantiate(Defaults.PatchSketchObjectPrefab).GetComponent <PatchSketchObject>(); PatchSketchObject.Width = 3; Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(0, 0, 1), new Vector3(0, 1, 2), new Vector3(0, 0, 3) })); Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(1, 1, 1), new Vector3(1, 0, 2), new Vector3(1, 1, 3) })); Invoker.ExecuteCommand(new AddSegmentCommand(PatchSketchObject, new List <Vector3> { new Vector3(2, 0, 1), new Vector3(2, 1, 2), new Vector3(2, 0, 3) })); //Add the LineSketchObject to the SketchWorld Invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(LineSketchObject, SketchWorld)); //Create a SketchObjectGroup and add objects to it SketchObjectGroup = Instantiate(Defaults.SketchObjectGroupPrefab).GetComponent <SketchObjectGroup>(); Invoker.ExecuteCommand(new AddToGroupCommand(SketchObjectGroup, RibbonSketchObject)); Invoker.ExecuteCommand(new AddToGroupCommand(SketchObjectGroup, PatchSketchObject)); //Add the SketchObjectGroup to the SketchWorld Invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(SketchObjectGroup, SketchWorld)); //Serialize the SketchWorld to a XML file SavePath = System.IO.Path.Combine(Application.dataPath, "YourSketch.xml"); SketchWorld.SaveSketchWorld(SavePath); //Create another SketchWorld and load the serialized SketchWorld DeserializedSketchWorld = Instantiate(Defaults.SketchWorldPrefab).GetComponent <SketchWorld>(); DeserializedSketchWorld.LoadSketchWorld(SavePath); DeserializedSketchWorld.transform.position += new Vector3(5, 0, 0); //Export the SketchWorld as an OBJ file //SketchWorld.ExportSketchWorldToDefaultPath(); //Select the SketchObjectGroup SketchObjectSelection = Instantiate(Defaults.SketchObjectSelectionPrefab).GetComponent <SketchObjectSelection>(); Invoker.ExecuteCommand(new AddToSelectionAndHighlightCommand(SketchObjectSelection, SketchObjectGroup)); Invoker.ExecuteCommand(new ActivateSelectionCommand(SketchObjectSelection)); }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Demonstration script using the SharpDXHelper class for managed custom rendering"; Name = "SharpDXHelperExample"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; // Set defaults for our properties, can be assigned to our DX/Media Brush in states from State.DataLoaded to State.Historical LineBrush = Brushes.RoyalBlue; LineBrushWidth = 2; LineBrushOpacity = 50.0; RectangleBrush = Brushes.LightGreen; RectangleBorderBrush = Brushes.Green; RectangleBrushWidth = 5; RectangleBrushOpacity = 10.0; RoundedRectangleBrush = Brushes.DarkGreen; RoundedRectangleBorderBrush = Brushes.LimeGreen; RoundedRectangleBrushWidth = 5; RoundedRectangleBrushOpacity = 10.0; EllipseBrush = Brushes.DarkRed; EllipseBrushWidth = 5; EllipseBrushOpacity = 40.0; string image1Path = System.IO.Path.Combine(NinjaTrader.Core.Globals.UserDataDir, "SharpDXHelper.png"); Image1Path = System.IO.File.Exists(image1Path) ? image1Path : String.Empty; Image1Opacity = 30.0f; string image2Path = System.IO.Path.Combine(NinjaTrader.Core.Globals.UserDataDir, "SharpDXHelper2.png"); Image2Path = System.IO.File.Exists(image2Path) ? image2Path : String.Empty; Image2Opacity = 20.0f; } else if (State == State.DataLoaded) { // Create a Series<bool> to tell if we want to draw something for a particular bar, must have MaximumBarsLookBack.Infinite. // This is more efficient than calculating what should be rendered during OnRender(), where we should only worry about how things should be rendered. DrawSeries = new Series <bool>(this, MaximumBarsLookBack.Infinite); // Create a list of brush names for us to manage with the helper class' "DXMediaBrush" Dictionary string[] brushes = new string[] { "LineBrush", "RectBrush", "RectBorderBrush", "RoundedRectBrush", "RoundedRectBorderBrush", "EllipseBrush" }; // If we use resourses managed by the helper class (bitmaps and internally managed brushes created from Windows Media Brush references) // and want to use a timer to clear brushes after a certain period of time, ChartControl must be used with the constructor for the resource timer and cannot be null if (ChartControl != null) { // Create new instance of the Helper Class // We are using managed brushes in this example, and have a 5 minute refresh period // minutesToRefersh values of 0 or less will not create a timer for brush disposal // This is useful for cleaning up programmatically created brushes that may not always be reused thorught a NinjaScript's life. DXH = new DXHelper(true, ChartControl, 0); // Add the brushes we defined in our brushes list DXH.AddBrushes(brushes); // Set our brushes to the values we would like DXH.UpdateBrush(RenderTarget, "LineBrush", LineBrush, LineBrushOpacity); DXH.UpdateBrush(RenderTarget, "RectBrush", RectangleBrush, RectangleBrushOpacity); DXH.UpdateBrush(RenderTarget, "RectBorderBrush", RectangleBorderBrush, RectangleBrushOpacity); DXH.UpdateBrush(RenderTarget, "RoundedRectBrush", RoundedRectangleBrush, RoundedRectangleBrushOpacity); DXH.UpdateBrush(RenderTarget, "RoundedRectBorderBrush", RoundedRectangleBorderBrush, RoundedRectangleBrushOpacity); DXH.UpdateBrush(RenderTarget, "EllipseBrush", EllipseBrush, EllipseBrushOpacity); } // Create a DXMediaBrush DXMBrush = new DXMediaBrush(); DXMBrush.UpdateBrush(RenderTarget, LineBrush, LineBrushOpacity); // Apply Opacity to LineBrush (used for User Defined Media Brush Demonstration. See overlay line 5.) LineBrush = LineBrush.Clone(); LineBrush.Opacity = LineBrushOpacity / 100.0; LineBrush.Freeze(); } else if (State == State.Terminated) { // Dispose of the resources created by our helper class. if (DXH != null) { DXH.Dispose(); } } }
public void Draw(SpriteBatch spriteBatch, int _hoffset, int _lines, bool showOnBottom) { if (/*standAlone && */ !IsActive) { return; } if (yCurtain >= 0) { yCurtain = 0; } else { yCurtain += CurtainSpeed; } string messages = GetMessages(_lines, ref mOffset).Replace("\r\n", "\n"); var font = standAlone ? StandAloneFont : game.GetFont(Font); Vector2 charSize = font.MeasureString("Z"); int height = (int)(charSize.Y * (_lines + 1));// MeasureHeight(_lines); var width = standAlone ? spriteBatch.GraphicsDevice.DisplayMode.Width : game.GameWidth; //Draw Rectangle spriteBatch.Draw( standAlone ? StandAloneTexture : game.GetTexture(BackTexture), new Rectangle(0, _hoffset + (showOnBottom ? -yCurtain : yCurtain), width, height), BackColor); //Write Text spriteBatch.DrawString( font, "> " + command + (((int)(game.Frame / 20)) % 2 == 0 ? "_" : " "), new Vector2(0, _hoffset + (showOnBottom ? -yCurtain : yCurtain)), InputColor); try { //Limit text to _lines lines. int rowLength = (int)(width / charSize.X); int length = messages.Length; for (int i = 1; i < length / rowLength; i++) { if (messages[i - 1] == ColorChangeSpecialCharacter) { messages.Insert((i * rowLength) + 1, "\n"); } else { messages.Insert(i * rowLength, "\n"); } } var texts = messages.Split('\n'); Stack <string> reverseTexts = new Stack <string>(); for (int i = texts.Length - 1; i >= 0 && reverseTexts.Count < _lines; i--) { reverseTexts.Push(texts[i]); } messages = ""; while (reverseTexts.Count > 0) { messages += reverseTexts.Pop() + "\n"; } if (EnableCharacterByCharacterDrawing) { //Draw text with colors int row = 0; int col = 0; Color c = TextColor; Vector2 startPoint = new Vector2(0, _hoffset + (showOnBottom ? -yCurtain : yCurtain) + charSize.Y); for (int i = 0; i < messages.Length; i++) { if (messages[i] == ColorChangeSpecialCharacter && messages.Length > i + 1 && ColorsTable.ContainsKey(messages[i + 1])) { //change color c = ColorsTable[messages[i + 1]]; i++; } else if (messages[i] == '\n') { row++; col = 0; } else { spriteBatch.DrawString( font, messages[i].ToString(), new Vector2(col * charSize.X, row * charSize.Y) + startPoint, c); col++; } if (col > rowLength) { row++; col = 0; } } } else { //Draw text without colors spriteBatch.DrawString(font, messages, new Vector2(0, _hoffset + (showOnBottom ? -yCurtain : yCurtain) + charSize.Y), TextColor); } } catch (Exception e) { Clear(); WriteLine("Error: " + e.Message); WriteLine("Console cleared to fix the problem."); } if (lb == null) { lb = new LineBrush(spriteBatch.GraphicsDevice, 1); } else { lb.Draw(spriteBatch, new Vector2(0, _hoffset - 1 + (showOnBottom ? -yCurtain : yCurtain)), new Vector2(width, _hoffset - 1 + (showOnBottom ? -yCurtain : yCurtain)), InputColor); lb.Draw(spriteBatch, new Vector2(0, _hoffset + 1 + height + (showOnBottom ? -yCurtain : yCurtain)), new Vector2(width, _hoffset + height + (showOnBottom ? -yCurtain : yCurtain)), InputColor); } }
public override void LoadContent() { base.LoadContent(); lb = new LineBrush(game.GraphicsDevice, 1); }
public void Draw(SpriteBatch sb, LineBrush lb, Color color) { lb.Draw(sb, StartPos, EndPos, color); }
public void Draw(SpriteBatch sb, LineBrush lb, Vector2 offset, Color color) { lb.Draw(sb, StartPos + offset, EndPos + offset, color); }
private void LoadCoordinateAxisContent(GraphicsDevice graphicsDevice) { _coordinateAxisLineBrush = new LineBrush(_coordinateAxisLineThickness, _coordinateAxisColor); _coordinateAxisLineBrush.Load(graphicsDevice); }