Beispiel #1
0
 public static void DrawFilledCurve(Rect r, AudioCurveAndColorEvaluator eval)
 {
     if (Event.current.type == EventType.Repaint)
     {
         Color color;
         HandleUtility.ApplyWireMaterial();
         GL.Begin(1);
         float pixelsPerPoint = EditorGUIUtility.pixelsPerPoint;
         float num2           = 1f / pixelsPerPoint;
         float num3           = r.width * pixelsPerPoint;
         float num4           = 1f / (num3 - 1f);
         float max            = r.height * 0.5f;
         float num6           = r.y + (0.5f * r.height);
         float y    = r.y + r.height;
         float num8 = Mathf.Clamp(max * eval(0f, out color), -max, max);
         for (int i = 0; i < num3; i++)
         {
             float x     = Mathf.Floor(r.x) + (i * num2);
             float num11 = Mathf.Clamp(max * eval(i * num4, out color), -max, max);
             float num12 = ((num11 >= num8) ? num8 : num11) - (0.5f * num2);
             float num13 = ((num11 <= num8) ? num8 : num11) + (0.5f * num2);
             GL.Color(new Color(color.r, color.g, color.b, 0f));
             AudioMixerDrawUtils.Vertex(x, num6 - num13);
             GL.Color(color);
             AudioMixerDrawUtils.Vertex(x, num6 - num12);
             AudioMixerDrawUtils.Vertex(x, num6 - num12);
             AudioMixerDrawUtils.Vertex(x, y);
             num8 = num11;
         }
         GL.End();
     }
 }
 public static void DrawFilledCurve(Rect r, AudioCurveAndColorEvaluator eval)
 {
     if (Event.current.type == EventType.Repaint)
     {
         Color color;
         HandleUtility.ApplyWireMaterial();
         GL.Begin(1);
         float pixelsPerPoint = EditorGUIUtility.pixelsPerPoint;
         float num2           = 1f / pixelsPerPoint;
         float num3           = 0.5f * num2;
         float num4           = Mathf.Ceil(r.width) * pixelsPerPoint;
         float num5           = Mathf.Floor(r.x) + pixelEpsilon;
         float num6           = 1f / (num4 - 1f);
         float max            = r.height * 0.5f;
         float num8           = r.y + (0.5f * r.height);
         float y = r.y + r.height;
         float b = Mathf.Clamp(max * eval(0f, out color), -max, max);
         for (int i = 0; i < num4; i++)
         {
             float x     = num5 + (i * num2);
             float a     = Mathf.Clamp(max * eval(i * num6, out color), -max, max);
             float num14 = Mathf.Min(a, b) - num3;
             float num15 = Mathf.Max(a, b) + num3;
             GL.Color(new Color(color.r, color.g, color.b, 0f));
             AudioMixerDrawUtils.Vertex(x, num8 - num15);
             GL.Color(color);
             AudioMixerDrawUtils.Vertex(x, num8 - num14);
             AudioMixerDrawUtils.Vertex(x, num8 - num14);
             AudioMixerDrawUtils.Vertex(x, y);
             b = a;
         }
         GL.End();
     }
 }
        public static void DrawSymmetricFilledCurve(Rect r, AudioCurveAndColorEvaluator eval)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            HandleUtility.ApplyWireMaterial();

            GL.Begin(GL.LINES);

            // Adjust by a half pixel to each side so that the transition covers a full pixel.
            // This is needed for very slowly rising edges.
            float pixelScale    = (float)EditorGUIUtility.pixelsPerPoint;
            float pixelSize     = 1.0f / pixelScale;
            float pixelHalfSize = 0.5f * pixelSize;
            float pixelWidth    = Mathf.Ceil(r.width) * pixelScale;
            float startx        = Mathf.Floor(r.x) + pixelEpsilon;
            float wx            = 1.0f / (float)(pixelWidth - 1);
            float cy            = r.height * 0.5f;
            float my            = r.y + 0.5f * r.height;
            Color color;

            float py = Mathf.Clamp(cy * eval(0.0001f, out color), 0.0f, cy);

            for (int x = 0; x < pixelWidth; x++)
            {
                float nx        = startx + x * pixelSize;
                float ny        = Mathf.Clamp(cy * eval(x * wx, out color), 0.0f, cy);
                float e1        = Mathf.Max(Mathf.Min(ny, py) - pixelHalfSize, 0.0f); // Avoid self-intersection
                float e2        = Mathf.Min(Mathf.Max(ny, py) + pixelHalfSize, cy);
                Color edgeColor = new Color(color.r, color.g, color.b, 0.0f);
                GL.Color(edgeColor);
                AudioMixerDrawUtils.Vertex(nx, my - e2);
                GL.Color(color);
                AudioMixerDrawUtils.Vertex(nx, my - e1);
                AudioMixerDrawUtils.Vertex(nx, my - e1);
                AudioMixerDrawUtils.Vertex(nx, my + e1);
                AudioMixerDrawUtils.Vertex(nx, my + e1);
                GL.Color(edgeColor);
                AudioMixerDrawUtils.Vertex(nx, my + e2);
                py = ny;
            }

            GL.End();
        }