public Color32 GetYLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)
 {
     if (ChartHelper.IsValueEqualsColor(areaColor, areaToColor))
     {
         return(areaColor);
     }
     return(Color32.Lerp(areaToColor, areaColor, (pos.x - grid.context.x) / grid.context.width));
 }
 public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)
 {
     if (ChartHelper.IsValueEqualsColor(areaColor, areaToColor))
     {
         return(areaColor);
     }
     return(Color32.Lerp(areaToColor, areaColor, (pos.y - grid.context.y) / grid.context.height));
 }
 public void SetColor(ref bool needInteract, Color32 color)
 {
     if (!ChartHelper.IsValueEqualsColor(color, m_TargetColor))
     {
         if (!ChartHelper.IsClearColor(m_TargetColor))
         {
             needInteract    = true;
             m_UpdateFlag    = true;
             m_ValueEnable   = true;
             m_UpdateTime    = Time.time;
             m_PreviousColor = m_TargetColor;
         }
         m_TargetColor = color;
     }
 }
Пример #4
0
        private static void DrawSerieLineNormalArea(VertexHelper vh, Serie serie, bool isY,
                                                    float zero, float min, float max, Color32 areaColor, Color32 areaToColor,
                                                    VisualMap visualMap, Axis axis, Axis relativedAxis, GridCoord grid)
        {
            var points = serie.context.drawPoints;
            var count  = points.Count;

            if (count < 2)
            {
                return;
            }

            var isBreak             = false;
            var lp                  = Vector3.zero;
            var isVisualMapGradient = VisualMapHelper.IsNeedAreaGradient(visualMap);
            var areaLerp            = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
            var zsp                 = isY ?
                                      new Vector3(zero, points[0].position.y) :
                                      new Vector3(points[0].position.x, zero);
            var zep = isY ?
                      new Vector3(zero, points[count - 1].position.y) :
                      new Vector3(points[count - 1].position.x, zero);

            var lastDataIsIgnore = false;

            for (int i = 0; i < points.Count; i++)
            {
                var tp       = points[i].position;
                var isIgnore = points[i].isIgnoreBreak;
                var color    = areaColor;
                var toColor  = areaToColor;
                var lerp     = areaLerp;

                if (serie.animation.CheckDetailBreak(tp, isY))
                {
                    isBreak = true;

                    var progress     = serie.animation.GetCurrDetail();
                    var ip           = Vector3.zero;
                    var axisStartPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
                    var axisEndPos   = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000);

                    if (UGLHelper.GetIntersection(lp, tp, axisStartPos, axisEndPos, ref ip))
                    {
                        tp = ip;
                    }
                }
                var zp = isY ? new Vector3(zero, tp.y) : new Vector3(tp.x, zero);
                if (isVisualMapGradient)
                {
                    color   = VisualMapHelper.GetLineGradientColor(visualMap, zp, grid, axis, relativedAxis, areaColor);
                    toColor = VisualMapHelper.GetLineGradientColor(visualMap, tp, grid, axis, relativedAxis, areaToColor);
                    lerp    = true;
                }
                if (i > 0)
                {
                    if ((lp.y - zero > 0 && tp.y - zero < 0) || (lp.y - zero < 0 && tp.y - zero > 0))
                    {
                        var ip = Vector3.zero;
                        if (UGLHelper.GetIntersection(lp, tp, zsp, zep, ref ip))
                        {
                            if (lerp)
                            {
                                AddVertToVertexHelperWithLerpColor(vh, ip, ip, color, toColor, isY, min, max, i > 0);
                            }
                            else
                            {
                                if (lastDataIsIgnore)
                                {
                                    UGL.AddVertToVertexHelper(vh, ip, ip, ColorUtil.clearColor32, true);
                                }

                                UGL.AddVertToVertexHelper(vh, ip, ip, toColor, color, i > 0);

                                if (isIgnore)
                                {
                                    UGL.AddVertToVertexHelper(vh, ip, ip, ColorUtil.clearColor32, true);
                                }
                            }
                        }
                    }
                }

                if (lerp)
                {
                    AddVertToVertexHelperWithLerpColor(vh, tp, zp, color, toColor, isY, min, max, i > 0);
                }
                else
                {
                    if (lastDataIsIgnore)
                    {
                        UGL.AddVertToVertexHelper(vh, tp, zp, ColorUtil.clearColor32, true);
                    }

                    UGL.AddVertToVertexHelper(vh, tp, zp, toColor, color, i > 0);

                    if (isIgnore)
                    {
                        UGL.AddVertToVertexHelper(vh, tp, zp, ColorUtil.clearColor32, true);
                    }
                }
                lp = tp;
                lastDataIsIgnore = isIgnore;
                if (isBreak)
                {
                    break;
                }
            }
        }
Пример #5
0
        private static void DrawSerieLineStackArea(VertexHelper vh, Serie serie, Serie lastStackSerie, bool isY,
                                                   float zero, float min, float max, Color32 color, Color32 toColor, VisualMap visualMap)
        {
            if (lastStackSerie == null)
            {
                return;
            }

            var upPoints   = serie.context.drawPoints;
            var downPoints = lastStackSerie.context.drawPoints;
            var upCount    = upPoints.Count;
            var downCount  = downPoints.Count;

            if (upCount <= 0 || downCount <= 0)
            {
                return;
            }

            var lerp = !ChartHelper.IsValueEqualsColor(color, toColor);
            var ltp  = upPoints[0].position;
            var lbp  = downPoints[0].position;

            if (lerp)
            {
                AddVertToVertexHelperWithLerpColor(vh, ltp, lbp, color, toColor, isY, min, max, false);
            }
            else
            {
                UGL.AddVertToVertexHelper(vh, ltp, lbp, color, false);
            }

            int u = 1, d = 1;
            var isBreakTop    = false;
            var isBreakBottom = false;

            while ((u < upCount || d < downCount))
            {
                var tp = u < upCount ? upPoints[u].position : upPoints[upCount - 1].position;
                var bp = d < downCount ? downPoints[d].position : downPoints[downCount - 1].position;

                var tnp = (u + 1) < upCount ? upPoints[u + 1].position : upPoints[upCount - 1].position;
                var bnp = (d + 1) < downCount ? downPoints[d + 1].position : downPoints[downCount - 1].position;

                if (serie.animation.CheckDetailBreak(tp, isY))
                {
                    isBreakTop = true;

                    var progress = serie.animation.GetCurrDetail();
                    var ip       = Vector3.zero;

                    if (UGLHelper.GetIntersection(ltp, tp,
                                                  new Vector3(progress, -10000),
                                                  new Vector3(progress, 10000), ref ip))
                    {
                        tp = ip;
                    }
                    else
                    {
                        tp = new Vector3(progress, tp.y);
                    }
                }
                if (serie.animation.CheckDetailBreak(bp, isY))
                {
                    isBreakBottom = true;

                    var progress = serie.animation.GetCurrDetail();
                    var ip       = Vector3.zero;

                    if (UGLHelper.GetIntersection(lbp, bp,
                                                  new Vector3(progress, -10000),
                                                  new Vector3(progress, 10000), ref ip))
                    {
                        bp = ip;
                    }
                    else
                    {
                        bp = new Vector3(progress, bp.y);
                    }
                }

                if (lerp)
                {
                    AddVertToVertexHelperWithLerpColor(vh, tp, bp, color, toColor, isY, min, max, true);
                }
                else
                {
                    UGL.AddVertToVertexHelper(vh, tp, bp, color, true);
                }
                u++;
                d++;
                if (bp.x < tp.x && bnp.x < tp.x)
                {
                    u--;
                }
                if (tp.x < bp.x && tnp.x < bp.x)
                {
                    d--;
                }

                ltp = tp;
                lbp = bp;
                if (isBreakTop && isBreakBottom)
                {
                    break;
                }
            }
        }