当前位置: 首页>>代码示例>>C#>>正文


C# Texture2D.DrawLine方法代码示例

本文整理汇总了C#中UnityEngine.Texture2D.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.DrawLine方法的具体用法?C# Texture2D.DrawLine怎么用?C# Texture2D.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Texture2D的用法示例。


在下文中一共展示了Texture2D.DrawLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawGraphLines

    public static void DrawGraphLines(Rect rect, Texture2D graphTexture, Func<float, float> Plot ) {
        int graphX = (int)rect.x;
        int graphY = (int)rect.y;
        int graphWidth = (int)rect.width;
        int graphHeight = (int)rect.height;

        Color[] pixels = graphTexture.GetPixels(graphX, graphY, graphWidth, graphHeight);
        Color32 color = new Color(0.2f, 0.2f, 0.2f);        

        for (int i = 0; i < pixels.Length; i++) {
            pixels[i] = color;
        }

        graphTexture.SetPixels(graphX, graphY, graphWidth, graphHeight, pixels);

        int lastX = graphX;
        int lastY = graphHeight;
        
        List<Vector2I> pointlist = new List<Vector2I>();
        for (int i = 0; i < graphWidth; i++) {
            float x = i / (float)graphWidth;
            float y = Plot(x);

            if (float.IsNaN(y)) continue; //not sure why this can happen but it does with non integer exponents

            //inverted y because text rendindering is updside down and i cant figure out 
            //how to flip the text correctly, so im flipping the graph instead
            
            pointlist.Add(new Vector2I(i, (int)((1 - y) * graphHeight)));
            
        }

        Color fadedGrey = new Color(0.24f, 0.24f, 0.24f, 0.5f);
        int quarterWidth = (int)(graphWidth * 0.25f);
        int quarterHeight = (int)(graphHeight * 0.25f);

        graphTexture.DrawLine(graphX, graphY + graphHeight, graphX + graphWidth, graphY, fadedGrey);

        graphTexture.DrawLine(graphX, quarterHeight * 1, graphX + graphWidth, quarterHeight * 1, fadedGrey);
        graphTexture.DrawLine(graphX, quarterHeight * 2, graphX + graphWidth, quarterHeight * 2, fadedGrey);
        graphTexture.DrawLine(graphX, quarterHeight * 3, graphX + graphWidth, quarterHeight * 3, fadedGrey);

        graphTexture.DrawLine(quarterWidth * 1, graphY, quarterWidth * 1, graphY + graphHeight, fadedGrey);
        graphTexture.DrawLine(quarterWidth * 2, graphY, quarterWidth * 2, graphY + graphHeight, fadedGrey);
        graphTexture.DrawLine(quarterWidth * 3, graphY, quarterWidth * 3, graphY + graphHeight, fadedGrey);

        if (pointlist.Count >= 2) {
            lastX = pointlist[0].x;
            lastY = pointlist[0].y;
            for (int i = 1; i < pointlist.Count; i++) {
                int y = pointlist[i].y;
                graphTexture.DrawLine(lastX, lastY, i, y, Color.green);
                lastX = i;
                lastY = y;
            }

        }
    }
开发者ID:toros11,项目名称:AbilitySystem,代码行数:58,代码来源:GraphHelper.cs

示例2: Start

    void Start()
    {
        Material material = renderer.material;
        Texture2D texture = new Texture2D(512,512, TextureFormat.RGB24, false);
        texture.wrapMode = TextureWrapMode.Clamp;
        material.SetTexture(0, texture);

        texture.DrawFilledRectangle(new Rect(0, 0, 120, 120), Color.green);

        texture.DrawRectangle(new Rect(0, 0, 120, 60), Color.red);

        texture.DrawCircle(256, 256, 100, Color.cyan);
        texture.DrawFilledCircle(256, 256, 50, Color.grey);

        texture.DrawCircle(0, 0, 512, Color.red);

        texture.DrawLine(new Vector2(120, 60), new Vector2(256, 256), Color.black);

        texture.Apply();
    }
开发者ID:AliAkbarMontazeri,项目名称:BitmapDrawingExampleProject,代码行数:20,代码来源:Example.cs

示例3: DrawLine

 private void DrawLine(Texture2D texture, float x0, float y0, float x1, float y1, Color color,int width =1)
 {
     for (int i = 0; i < width; i++)
     {
         float delta = 0.005f * i;
         texture.DrawLine((int)((x0 + delta) * _textureScale), (int)((y0 + delta) * _textureScale), (int)((x1 + delta) * _textureScale),
             (int)((y1 + delta) * _textureScale), color);
     }
 }
开发者ID:WilliamChao,项目名称:nmap,代码行数:9,代码来源:MapTexture2.cs

示例4: ScanLineCircle

        // Draw scanlines from opposite sides of the circle on y-scanlines instead of just plotting pixels
        // at the right coordinates
        private static void ScanLineCircle(Texture2D texture, int cx, int x, int cy, int y, Color color)
        {
            //texture.DrawPixel(cx + x,  cy + y, color);
            //texture.DrawPixel(-cx + x, cy + y, color);
            texture.DrawLine(cx + x, cy + y, -cx + x, cy + y, color);

            //texture.DrawPixel(cy + x,  cx + y, color);
            //texture.DrawPixel(-cy + x, cx + y, color);
            texture.DrawLine(cy + x, cx + y, -cy + x, cx + y, color);

            //texture.DrawPixel(-cx + x, -cy + y, color);
            //texture.DrawPixel(cx + x,  -cy + y, color);
            texture.DrawLine(-cx + x, -cy + y, cx + x, -cy + y, color);
            
            //texture.DrawPixel(-cy + x, -cx + y, color);
            //texture.DrawPixel(cy + x,  -cx + y, color);
            texture.DrawLine(-cy + x, -cx + y, cy + x, -cx + y, color);
        }
开发者ID:fromtons,项目名称:meme-pas-peur_app,代码行数:20,代码来源:BitmapDrawing.cs

示例5: DrawLine

 private void DrawLine(Texture2D texture, float x0, float y0, float x1, float y1, Color color)
 {
     texture.DrawLine((int)(x0 * _textureScale), (int)(y0 * _textureScale), (int)(x1 * _textureScale), (int)(y1 * _textureScale), color);
 }
开发者ID:co-chi-tam,项目名称:The-Dark-Creature,代码行数:4,代码来源:MapTexture.cs


注:本文中的UnityEngine.Texture2D.DrawLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。