Пример #1
0
        // Draw a line into a texture2D
        void CreateLine(Texture2D tex, Dictionary <float, float> vals, Color col, float xScale, float yScale)
        {
            PlotLine curve = new PlotLine(vals);

            //FloatCurve curve = new FloatCurve();
            //foreach (var item in vals) {
            //    curve.Add(item.Key * xScale, item.Value * yScale);
            //tex.SetPixel((int)(xScale*item.Key), (int)(yScale*item.Value), col);
            //}
            Utils.Log(String.Format("[ProfilingUI]: xScale: {0} \nyScale: {1}", xScale.ToString(), yScale.ToString()));



            for (int i = 1; i < tex.width - 1; i++)
            {
                int y1 = Mathf.Clamp((int)(curve.Evaluate(i / xScale) * yScale), 0, tex.height - 1);

                tex.SetPixel((int)(i), y1, col);
                tex.SetPixel((int)(i + 1), y1, col);
                tex.SetPixel((int)(i - 1), y1, col);

                tex.SetPixel((int)(i), y1 + 1, col);
                tex.SetPixel((int)(i + 1), y1 + 1, col);
                tex.SetPixel((int)(i - 1), y1 + 1, col);

                tex.SetPixel((int)(i), y1 - 1, col);
                tex.SetPixel((int)(i + 1), y1 - 1, col);
                tex.SetPixel((int)(i - 1), y1 - 1, col);
            }
        }