Ejemplo n.º 1
0
    void Draw()
    {
        graphics.Clear();

        Vector3 old        = Vector3.zero;
        Vector3 currentMid = Vector3.zero;
        Vector3 oldMid     = Vector3.zero;

        for (int i = 0; i < points.Length; i++)
        {
            Vector3 pt = points[i];
            if (i == 0)
            {
                currentMid = pt;
                old        = currentMid;
                oldMid     = pt;
                graphics.MoveTo(currentMid, color, thickness);
            }
            else
            {
                currentMid = getMidInputCoords(old, pt);
            }

            graphics.QuadraticCurveTo(oldMid, old, currentMid, color, thickness);
            old    = pt;
            oldMid = currentMid;
        }
        graphics.LineTo(points[points.Length - 1], color, thickness);
        //
        Color _color = Color.green;

        for (int i = 0; i < points.Length; i++)
        {
            Vector3 pt = points[i];
            if (i == 0)
            {
                graphics.MoveTo(pt, _color, thickness * 0.25f);
            }
            else
            {
                graphics.LineTo(pt, _color, thickness * 0.25f);
            }
        }
        graphics.Render();
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        UpdatePoints();

        graphics.Clear();
        graphics.curveSmoothing = curveSmoothing;

        float d = 1.0f / num;

        for (int i = 0; i < (num + 1); i++)
        {
            Vector3 pt        = point[i];
            Color   c         = Color.Lerp(Color.black, color, d * i);
            float   thickness = Mathf.Lerp(10, 50, d * i);
            if (i == 0)
            {
                graphics.MoveTo(pt, c, thickness);
            }
            else
            {
                graphics.LineTo(pt, c, thickness);
            }
        }

        for (int i = 0; i < (num + 1); i++)
        {
            Vector3 pt = point[i] + new Vector3(200, 100);
            Color   c  = Color.Lerp(Color.black, color, d * i);
            if (i == 0)
            {
                graphics.MoveTo(pt * 0.5f, c, 20);
            }
            else
            {
                graphics.LineTo(pt * 0.5f, c, 20);
            }
        }

        graphics.Render();
    }
Ejemplo n.º 3
0
    // Update is called once per frame

    // curve
    void CurveRender()
    {
        graphics.curveSmoothing = curveSmoothing;

        amp.x = rectTrans.rect.width;
        amp.y = rectTrans.rect.height;

        float offsetX = -rectTrans.pivot.x;
        float offsetY = -rectTrans.pivot.y;

        float num = splitNum;
        float d   = 1.0f / num;

        d = Mathf.Clamp01(d);

        graphics.Clear();

        for (int i = 0; i < num + 1; i++)
        {
            float x = d * i;
            float y = curve.Evaluate(x);

            Vector3 pos = new Vector3(x + offsetX, y + offsetY, 0);
            pos.Scale(amp);

            //			Color c = Color.Lerp(Color.black, color, x);
            Color c = color;

            if (i == 0)
            {
                graphics.MoveTo(pos, c, thickness);
            }
            else
            {
                graphics.LineTo(pos, c, thickness);
            }
        }
        graphics.Render();
    }
    // Update is called once per frame
    void Update()
    {
        graphics.curveSmoothing = curveSmoothing;
        graphics.isUseAvg       = isUseAvg;

        amp.x = Screen.width;

        float num = splitNum;
        float d   = 1.0f / num;

        d = Mathf.Clamp01(d);

        graphics.Clear();

        Vector3 dir = -Vector3.forward;

        graphics.SetDefaultFaceDir(dir);

        for (int i = 0; i < num + 1; i++)
        {
            float x = d * i;
            float y = curve.Evaluate(x);

            Vector3 pos = new Vector3(x, y, 0);
            pos.Scale(amp);

            Color c = Color.Lerp(Color.black, color, x);

            if (i == 0)
            {
                graphics.MoveTo(pos, c, thickness);
            }
            else
            {
                graphics.LineTo(pos, c, thickness);
            }
        }
        graphics.Render();
    }