public void DrawGrid(IEnumerable <DateTime> dateList, IEnumerable <decimal> pricesList) { if (!IsSettingsSet) { return; } DrawTools.LineColor = gridColor; DrawTools.dashLength = 0.05f; DrawTools.gap = 0.07f; priceTextPool.CleanPool(); float yPoint; foreach (var price in pricesList) { yPoint = CoordGrid.FromPriceToYAxis((float)price); yPoint = cam.WorldToScreenPoint(new Vector2(0, yPoint)).y; priceTextPool.SetText( price.ToString("F8"), yPoint, TextPoolManager.ShiftBy.Vertical ); Vector2 pricePoint1 = new Vector2(cam.WorldToScreenPoint(worldPointInLeftDownCorner).x, yPoint); Vector2 pricePoint2 = new Vector2(cam.WorldToScreenPoint(worldPointInRightUpCorner).x, yPoint); DrawTools.DrawOnePixelLine(pricePoint1, pricePoint2, true); } dateTextPool.CleanPool(); foreach (var date in dateList) { float dateLine = CoordGrid.FromDateToXAxis(date); dateLine = cam.WorldToScreenPoint(new Vector2(dateLine, 0)).x; dateTextPool.SetText( date.ChartStringFormat(), dateLine, TextPoolManager.ShiftBy.Horizontal ); Vector2 datePoint1 = new Vector2(dateLine, cam.pixelRect.min.y); Vector2 datePoint2 = new Vector2(dateLine, cam.pixelRect.max.y); DrawTools.DrawOnePixelLine(datePoint1, datePoint2, true); } }
public void DrawCross() { Vector2 pointerScreenPosition; Vector3 pointerWolrdPosition; GetWorldPointerPosition(out pointerScreenPosition, out pointerWolrdPosition); //Vector2 pointerViewportPosition = cam.ScreenToViewportPoint(pointerScreenPosition); DrawTools.LineColor = crossColor; Vector2 modifiedPointerPosition = cam.WorldToScreenPoint(new Vector2(Mathf.Round(pointerWolrdPosition.x), pointerWolrdPosition.y)); Vector2 camToViewportFromXToTop = new Vector2(modifiedPointerPosition.x, cam.pixelRect.yMin); Vector2 camToViewportFromXToBottom = new Vector2(modifiedPointerPosition.x, cam.pixelRect.yMax); //Магнитизм к X. Необходимо будет переписать DrawTools.DrawOnePixelLine(modifiedPointerPosition, camToViewportFromXToTop, true); DrawTools.DrawOnePixelLine(modifiedPointerPosition, camToViewportFromXToBottom, true); DrawTools.DrawOnePixelLine(modifiedPointerPosition, new Vector2(cam.pixelRect.xMin, pointerScreenPosition.y), true); DrawTools.DrawOnePixelLine(modifiedPointerPosition, new Vector2(cam.pixelRect.xMax, pointerScreenPosition.y), true); }