Example #1
0
    // update
    private void Draw()
    {
        if (pointsList.Count < 1)
        {
            graphics.Clear();
            graphics.Render();
            return;
        }

        graphics.Clear();
        graphics.SetDefaultColor(drawColor0);
        graphics.SetDefaultThickness(thickness);

        Vector3 dir = -Vector3.forward;

        graphics.SetDefaultFaceDir(dir);

        // childを作るかどうかでの処理わけ。childを作らない場合は pointsList を全て描画、作る場合は最新の pointsList のみ描画
        int startIndex = createChildDrawer ? pointsList.Count - 1 : 0;

        for (int i = startIndex; i < pointsList.Count; i++)
        {
            //for (int i = 0; i < pointsList.Count; i++) {
            List <Vector3> points         = pointsList[i];
            float[]        thicknessArray = new float[points.Count];
            Color[]        colorArray     = new Color[points.Count];
            for (int j = 0; j < thicknessArray.Length; j++)
            {
                if (j == 0)
                {
                    thicknessArray[j] = thicknessMin;
                    colorArray[j]     = drawColor0;
                }
                else
                {
                    float dist = Vector3.Distance(points[j - 1], points[j]);
                    //thicknessArray[j] = (1-(dist / 40f)) * thickness + thickness;
                    float t = 1 - Mathf.Clamp01(dist / distLimit);
                    colorArray[j] = Color.Lerp(drawColor0, drawColor1, t);
                    //thicknessArray[j] = thickness;
                    //thicknessArray[j] = t * thickness + thicknessMin;
                    thicknessArray[j] = ((t * thickness + thicknessMin) + thicknessArray[j - 1]) * 0.5f; // avg
                }
            }
            //
            if (useCatmull)
            {
                //graphics.DrawSpline(points.ToArray(), thicknessArray, colorArray);
                graphics.DrawQuadraticCurve(points.ToArray(), thicknessArray, colorArray);
            }
            else
            {
                graphics.DrawLine(points.ToArray(), thicknessArray);
            }
        }
        graphics.Render();
    }
Example #2
0
    void Draw()
    {
        graphics.Clear();

        // quadTest
        Rect rect = new Rect(-0.5f, -0.5f, 1, 1);

        float offsetX = offset.x * numX / 2.0f;
        float offsetY = offset.y * numY / 2.0f;

        angle += Time.deltaTime * 50;
        float _angle = angle;

        for (int i = 0; i < numX; i++)
        {
            for (int j = 0; j < numY; j++)
            {
                float x = i * offset.x - offsetX;
                float y = j * offset.y - offsetY;
                float z = 0;
                _angle += 0.1f;

                float r     = 1.0f / numX * i;
                float g     = 1.0f / numY * j;
                Color color = new Color(r, g, 0, 1);

                graphics.DrawQuad(rect, x, y, z, size, size, _angle, color);
            }
        }
        graphics.Render();
    }
Example #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();
    }
Example #4
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();
    }
Example #5
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();
    }
    // 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();
    }
Example #7
0
 void Draw()
 {
     graphics.Clear();
     graphics.DrawCircle(radius, 0, 0, divid, Color.red);
     graphics.Render();
 }