• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RenderOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RenderOptions的典型用法代码示例。如果您正苦于以下问题:C# RenderOptions类的具体用法?C# RenderOptions怎么用?C# RenderOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RenderOptions类属于命名空间,在下文中一共展示了RenderOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: renderSprite

    internal static new void renderSprite( dfRenderData renderData, RenderOptions options )
    {
        #if UNITY_EDITOR

        var atlas = options.atlas;
        if( atlas == null )
            throw new NullReferenceException( "The Texture Atlas cannot be null" );

        if( atlas.Texture == null )
            throw new NullReferenceException( "The Texture Altas has no texture assigned or the texture was deleted" );

        if( options.spriteInfo == null )
            throw new ArgumentNullException( "The Sprite cannot be null" );

        #endif

        options.baseIndex = renderData.Vertices.Count;

        rebuildTriangles( renderData, options );
        rebuildVertices( renderData, options );
        rebuildUV( renderData, options );
        rebuildColors( renderData, options );

        if( options.fillAmount < 1f )
        {
            doFill( renderData, options );
        }
    }
开发者ID:haozi000005,项目名称:happy2d,代码行数:28,代码来源:dfSlicedSprite.cs


示例2: DrawBitmap

 /// <summary>
 /// Draws bitmap.
 /// </summary>
 /// <param name="data">
 /// Image pixel data.
 /// </param>
 /// <param name="width">
 /// Output image width.
 /// </param>
 /// <param name="height">
 /// Output image height.
 /// </param>
 /// <param name="options">
 /// More rendering options.
 /// </param>
 /// <returns>
 /// Drawn bitmap.
 /// </returns>
 public static Bitmap DrawBitmap(byte[] data, int width, int height, RenderOptions options)
 {
     ImagePalette palette = options.Palette;
     Bitmap bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
     ColorPalette pal = bmp.Palette;
     palette.CopyTo(pal.Entries, 0);
     if(options.TransparentIndex >= 0)pal.Entries[options.TransparentIndex] = Color.Transparent;
     bmp.Palette = pal;
     BitmapData bmpdata = bmp.LockBits(new Rectangle(0,0,width,height), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
     if(data.Length == 0){}
     else if(width%4 == 0)
     {
         Marshal.Copy(data, 0, bmpdata.Scan0, Math.Min(bmpdata.Stride*bmpdata.Height, data.Length));
     }else{
         for(int y = 0; y < height; y++)
         {
             if(y == height-1)
             {
                 Marshal.Copy(data, width*y, bmpdata.Scan0+bmpdata.Stride*y, data.Length-width*y);
             }else{
                 Marshal.Copy(data, width*y, bmpdata.Scan0+bmpdata.Stride*y, width);
             }
         }
     }
     bmp.UnlockBits(bmpdata);
     return bmp;
 }
开发者ID:IllidanS4,项目名称:AlbLib,代码行数:45,代码来源:Drawing.cs


示例3: BlendDemo

        public BlendDemo(IntPtr hInstance)
            : base(hInstance) {
            _waterTexOffset = new Vector2();
            _eyePosW = new Vector3();
            _renderOptions = RenderOptions.TexturesAndFog;
            _theta = 1.3f * MathF.PI;
            _phi = 0.4f * MathF.PI;
            _radius = 80;

            MainWindowCaption = "Blend Demo";
            Enable4XMsaa = false;

            _landWorld = Matrix.Identity;
            _wavesWorld = Matrix.Translation(0, -3.0f, 0);
            _view = Matrix.Identity;
            _proj = Matrix.Identity;

            _boxWorld = Matrix.Scaling(15.0f, 15.0f, 15.0f) * Matrix.Translation(8.0f, 5.0f, -15.0f);

            _grassTexTransform = Matrix.Scaling(5.0f, 5.0f, 0.0f);

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient   = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = Color.Black,
                    Direction = new Vector3(0.0f, -0.707f, -0.707f)
                }
            };
            _landMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
            _wavesMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = new Color4(0.6f, 1.0f, 1.0f, 1.0f),
                Specular = new Color4(32.0f, 0.8f, 0.8f, 0.8f)
            };
            _boxMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.4f, 0.4f, 0.4f)
            };
        }
开发者ID:amitprakash07,项目名称:dx11,代码行数:57,代码来源:Program.cs


示例4: RenderControls

        public RenderControls(RenderOptions parent)
        {
            InitializeComponent();

            _Parent = parent;

            RenderSliders();

            PopulateCombos();
        }
开发者ID:dom767,项目名称:woofractal,代码行数:10,代码来源:RenderControls.xaml.cs


示例5: Renderer

        public Renderer(int passes, ViewportPolicy viewportPolicy, RenderOptions renderOptions)
        {
            this.Passes = passes;
            this.Policy = viewportPolicy;
            this.Options = renderOptions;
            this.sortMode = Renderer.ToSortMode(renderOptions);
            this.blendState = Renderer.ToBlendState(renderOptions);

            // Doing a GlobalRenderLock because Renderer objects might be constructed in different threads.
            lock (PhantomGame.Game.GlobalRenderLock)
            {
                if ((renderOptions & RenderOptions.Canvas) == RenderOptions.Canvas)
                    this.canvas = new Canvas(PhantomGame.Game.GraphicsDevice);
                this.batch = new SpriteBatch(PhantomGame.Game.GraphicsDevice);
            }

            if (this.sortMode == SpriteSortMode.Immediate)
                this.activeRenderPass = this.RenderPassFullLock;
            else
                this.activeRenderPass = this.RenderPassEndLock;
        }
开发者ID:HuntiXz,项目名称:phantom,代码行数:21,代码来源:Renderer.cs


示例6: CreatePatternBrush

        void CreatePatternBrush(float pixelSize)
        {
            //  Determine adjusted pixel size of the brush to create.
            const float MAX_PATTERN_SIZE = 80;
            const float MIN_PATTERN_SIZE = 10;
            if (pixelSize < patternWidth / MAX_PATTERN_SIZE)
                pixelSize = patternWidth / MAX_PATTERN_SIZE;
            if (pixelSize < patternHeight / MAX_PATTERN_SIZE)
                pixelSize = patternHeight / MAX_PATTERN_SIZE;
            if (pixelSize > patternWidth / MIN_PATTERN_SIZE)
                pixelSize = patternWidth / MIN_PATTERN_SIZE;
            if (pixelSize > patternHeight / MIN_PATTERN_SIZE)
                pixelSize = patternHeight / MIN_PATTERN_SIZE;

            if (patternBrushes != null && Math.Abs(pixelSize - pixelSizeCached) / pixelSize < 0.01)
                return;         // the pattern brush is already OK size.

            // Get size of bitmap to create with the image of the pattern.
            float width = (float) Math.Round(patternWidth / pixelSize);
            float height = (float) Math.Round(patternHeight / pixelSize);

            // Create dictionary to hold brushes for each color.
            patternBrushes = new Dictionary<SymColor, Brush>(2);
            pixelSizeCached = pixelSize;

            RenderOptions renderOpts = new RenderOptions();
            renderOpts.minResolution = pixelSize;
            renderOpts.usePatternBitmaps = false;

            foreach (SymColor color in map.colors) {
                if (!patternGlyph.HasColor(color))
                    continue;

                // Create a new bitmap and fill it transparent.
                Bitmap bitmap = new Bitmap((int) width, (int) (offsetRows ? height * 2 : height));
                Graphics g = Graphics.FromImage(bitmap);
                g.CompositingMode = CompositingMode.SourceCopy;
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, bitmap.Width, bitmap.Height);

                // Set the center of the bitmap to 0,0, and scale to mm (each pixel is 0.01 mm).
                g.TranslateTransform(width / 2.0F, height / 2.0F);
                g.ScaleTransform(width / patternWidth, height / patternHeight);

                // Draw the pattern into the bitmap.
                GraphicsTarget grTarget = new GraphicsTarget(g);
                patternGlyph.Draw(grTarget, new PointF(0F, 0F), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts);

                if (offsetRows) {
                    patternGlyph.Draw(grTarget, new PointF(patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts);
                    patternGlyph.Draw(grTarget, new PointF(-patternWidth / 2, patternHeight), -patternAngle, GraphicsUtil.IdentityMatrix, null, color, renderOpts);
                }

                // Create a TextureBrush on the bitmap.
                TextureBrush brush = new TextureBrush(bitmap);

                // Scale and the texture brush.
                brush.RotateTransform(patternAngle);
                brush.ScaleTransform(patternWidth / width, patternHeight / height);
                brush.TranslateTransform(-width / 2.0F, -height / 2.0F);

                // Dispose of the graphics.
                g.Dispose();

                // Add it to the collection of brushes.
                patternBrushes.Add(color, brush);
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:68,代码来源:SymDef.cs


示例7: DrawPatternWithTexBrush

        // Draw the pattern using the texture brush.
        void DrawPatternWithTexBrush(GraphicsTarget g, SymPathWithHoles path, float angle, SymColor color, RenderOptions renderOpts)
        {
            Brush brush = (Brush) patternBrushes[color];
            Debug.Assert(brush != null);

            if (angle != 0.0F) {
                object graphicsState = g.Save();

                try {
                    // Set the clipping region to draw only inside the area.
                    g.SetClip(path);

                    // use a transform to rotate.
                    Matrix matrix = GraphicsUtil.RotationMatrix(angle, new PointF(0, 0));
                    g.Transform(matrix);

                    // Get the correct bounding rect.
                    RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -angle);

                    g.FillRectangle(brush, bounding);
                }
                finally {
                    // restore the clip region and the transform
                    g.Restore(graphicsState);
                }
            }
            else {
                path.Fill(g, brush);
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:31,代码来源:SymDef.cs


示例8: DrawPattern

        // Draw the pattern (at the given angle) inside the path.
        void DrawPattern(GraphicsTarget g, SymPathWithHoles path, float angle, SymColor color, RenderOptions renderOpts)
        {
            object graphicsState = g.Save();

            try {
                // Set the clipping region to draw only inside the area.
                g.SetClip(path);

                // use a transform to rotate
                Matrix matrix = GraphicsUtil.RotationMatrix(patternAngle + angle, new PointF(0, 0));
                g.Transform(matrix);

                // Get the correct bounding rect.
                RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(patternAngle + angle));

                DrawPatternRows(g, bounding, color, renderOpts);
            }
            finally {
                // restore the clip region and the transform
                g.Restore(graphicsState);
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:23,代码来源:SymDef.cs


示例9: DrawHatching

        // Draw the hatching into the interior of the SymPath.
        void DrawHatching(GraphicsTarget g, SymPathWithHoles path, float angle, RenderOptions renderOpts)
        {
            object graphicsState = g.Save();

            try {
                // Set the clipping region to draw only inside the area.
                g.SetClip(path);

                // use a transform to rotate and then draw hatching.
                Matrix matrix = GraphicsUtil.RotationMatrix(hatchAngle1 + angle, new PointF(0, 0));
                g.Transform(matrix);

                // Get the correct bounding rect.
                RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(hatchAngle1 + angle));

                DrawHatchLines(g, hatchPen, hatchSpacing, bounding, renderOpts);

                // and again for the second bound of hatching
                if (hatchMode == 2) {
                    // Get the correct bounding rect.
                    bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -(hatchAngle2 + angle));

                    matrix = GraphicsUtil.RotationMatrix(hatchAngle2 - hatchAngle1, new PointF(0, 0));
                    g.Transform(matrix);
                    DrawHatchLines(g, hatchPen, hatchSpacing, bounding, renderOpts);
                }
            }
            finally {
                // restore the clip region and the transform
                g.Restore(graphicsState);
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:33,代码来源:SymDef.cs


示例10: DrawTextOnPath

        // Draw this text symbol along a path.
        internal void DrawTextOnPath(GraphicsTarget g, SymPath path, string text, SymColor color, RenderOptions renderOpts)
        {
            if (color == null)
                return;
            if (color != fontColor && (framing.framingStyle == FramingStyle.None || color != framing.framingColor))
                return;

            if (!objectsCreated)
                CreateObjects();

            // Get the location of each grapheme to print.
            List<GraphemePlacement> graphemeList = GetLineTextGraphemePlacement(path, text);
            PointF topAscentPoint = new PointF(0, -FontAscent);    // Drawing is relative to top of char, we want to draw at baseline.

            foreach (GraphemePlacement grapheme in graphemeList) {
                object graphicsState;
                graphicsState = g.Save();

                try {
                    // Move location to draw at to the origin, set angle for drawing text.
                    Matrix matrix = GraphicsUtil.TranslationMatrix(grapheme.pointStart.X, grapheme.pointStart.Y);
                    matrix = GraphicsUtil.Multiply(GraphicsUtil.ScalingMatrix(1, -1), matrix);      // Reverse Y so text is correct way aroun
                    matrix = GraphicsUtil.Multiply(GraphicsUtil.RotationMatrix(-grapheme.angle, new PointF(0,0)), matrix);
                    g.Transform(matrix);

                    DrawStringWithEffects(g, color, grapheme.grapheme, topAscentPoint);
                }
                finally {
                    g.Restore(graphicsState);  // restore transform
                }
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:33,代码来源:SymDef.cs


示例11: Draw

 // Draw this point symbol at point pt with angle ang in this graphics (given color only).
 internal void Draw(GraphicsTarget g, PointF pt, float angle, float[] gaps, SymColor color, RenderOptions renderOpts)
 {
     glyph.Draw(g, pt, angle, GraphicsUtil.IdentityMatrix, gaps, color, renderOpts);
 }
开发者ID:jonc,项目名称:carto,代码行数:5,代码来源:SymDef.cs


示例12: OnRebuildRenderData

    protected override void OnRebuildRenderData()
    {
        if( Atlas == null )
            return;

        var spriteInfo = SpriteInfo;
        if( spriteInfo == null )
        {
            return;
        }

        renderData.Material = Atlas.Material;

        if( spriteInfo.border.horizontal == 0 || spriteInfo.border.vertical == 0 )
        {
            base.OnRebuildRenderData();
            return;
        }

        var color = ApplyOpacity( IsEnabled ? this.color : this.disabledColor );
        var options = new RenderOptions()
        {
            atlas = atlas,
            color = color,
            fillAmount = fillAmount,
            fillDirection = fillDirection,
            flip = flip,
            invertFill = invertFill,
            offset = pivot.TransformToUpperLeft( Size ),
            pixelsToUnits = PixelsToUnits(),
            size = Size,
            spriteInfo = SpriteInfo
        };

        renderSprite( renderData, options );
    }
开发者ID:haozi000005,项目名称:happy2d,代码行数:36,代码来源:dfSlicedSprite.cs


示例13: rebuildVertices

    private static void rebuildVertices( dfRenderData renderData, RenderOptions options )
    {
        float meshLeft = 0;
        float meshTop = 0;
        float meshRight = Mathf.Ceil( options.size.x );
        float meshBottom = Mathf.Ceil( -options.size.y );

        #region Borders

        var spriteInfo = options.spriteInfo;
        float borderLeft = spriteInfo.border.left;
        float borderTop = spriteInfo.border.top;
        float borderRight = spriteInfo.border.right;
        float borderBottom = spriteInfo.border.bottom;

        if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) )
        {
            float temp = borderRight;
            borderRight = borderLeft;
            borderLeft = temp;
        }

        if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) )
        {
            float temp = borderBottom;
            borderBottom = borderTop;
            borderTop = temp;
        }

        #endregion

        // Top left corner
        verts[ 0 ] = new Vector3( meshLeft, meshTop, 0 ) + options.offset;
        verts[ 1 ] = verts[ 0 ] + new Vector3( borderLeft, 0, 0 );
        verts[ 2 ] = verts[ 0 ] + new Vector3( borderLeft, -borderTop, 0 );
        verts[ 3 ] = verts[ 0 ] + new Vector3( 0, -borderTop, 0 );

        // Top right corner
        verts[ 4 ] = new Vector3( meshRight - borderRight, meshTop, 0 ) + options.offset;
        verts[ 5 ] = verts[ 4 ] + new Vector3( borderRight, 0, 0 );
        verts[ 6 ] = verts[ 4 ] + new Vector3( borderRight, -borderTop, 0 );
        verts[ 7 ] = verts[ 4 ] + new Vector3( 0, -borderTop, 0 );

        // Bottom left corner
        verts[ 8 ] = new Vector3( meshLeft, meshBottom + borderBottom, 0 ) + options.offset;
        verts[ 9 ] = verts[ 8 ] + new Vector3( borderLeft, 0, 0 );
        verts[ 10 ] = verts[ 8 ] + new Vector3( borderLeft, -borderBottom, 0 );
        verts[ 11 ] = verts[ 8 ] + new Vector3( 0, -borderBottom, 0 );

        // Bottom right corner
        verts[ 12 ] = new Vector3( meshRight - borderRight, meshBottom + borderBottom, 0 ) + options.offset;
        verts[ 13 ] = verts[ 12 ] + new Vector3( borderRight, 0, 0 );
        verts[ 14 ] = verts[ 12 ] + new Vector3( borderRight, -borderBottom, 0 );
        verts[ 15 ] = verts[ 12 ] + new Vector3( 0, -borderBottom, 0 );

        for( int i = 0; i < verts.Length; i++ )
        {
            renderData.Vertices.Add( ( verts[ i ] * options.pixelsToUnits ).Quantize( options.pixelsToUnits ) );
        }
    }
开发者ID:haozi000005,项目名称:happy2d,代码行数:60,代码来源:dfSlicedSprite.cs


示例14: rebuildUV

    private static void rebuildUV( dfRenderData renderData, RenderOptions options )
    {
        var atlas = options.atlas;
        var textureSize = new Vector2( atlas.Texture.width, atlas.Texture.height );

        var spriteInfo = options.spriteInfo;
        float offsetTop = spriteInfo.border.top / textureSize.y;
        float offsetBottom = spriteInfo.border.bottom / textureSize.y;
        float offsetLeft = spriteInfo.border.left / textureSize.x;
        float offsetRight = spriteInfo.border.right / textureSize.x;

        var rect = spriteInfo.region;

        // Top left corner
        uv[ 0 ] = new Vector2( rect.x, rect.yMax );
        uv[ 1 ] = new Vector2( rect.x + offsetLeft, rect.yMax );
        uv[ 2 ] = new Vector2( rect.x + offsetLeft, rect.yMax - offsetTop );
        uv[ 3 ] = new Vector2( rect.x, rect.yMax - offsetTop );

        // Top right corner
        uv[ 4 ] = new Vector2( rect.xMax - offsetRight, rect.yMax );
        uv[ 5 ] = new Vector2( rect.xMax, rect.yMax );
        uv[ 6 ] = new Vector2( rect.xMax, rect.yMax - offsetTop );
        uv[ 7 ] = new Vector2( rect.xMax - offsetRight, rect.yMax - offsetTop );

        // Bottom left corner
        uv[ 8 ] = new Vector2( rect.x, rect.y + offsetBottom );
        uv[ 9 ] = new Vector2( rect.x + offsetLeft, rect.y + offsetBottom );
        uv[ 10 ] = new Vector2( rect.x + offsetLeft, rect.y );
        uv[ 11 ] = new Vector2( rect.x, rect.y );

        // Bottom right corner
        uv[ 12 ] = new Vector2( rect.xMax - offsetRight, rect.y + offsetBottom );
        uv[ 13 ] = new Vector2( rect.xMax, rect.y + offsetBottom );
        uv[ 14 ] = new Vector2( rect.xMax, rect.y );
        uv[ 15 ] = new Vector2( rect.xMax - offsetRight, rect.y );

        #region Flip UV if requested

        if( options.flip != dfSpriteFlip.None )
        {

            for( int i = 0; i < uv.Length; i += 4 )
            {

                Vector2 temp = Vector2.zero;

                if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) )
                {
                    temp = uv[ i + 0 ]; uv[ i + 0 ] = uv[ i + 1 ]; uv[ i + 1 ] = temp;
                    temp = uv[ i + 2 ]; uv[ i + 2 ] = uv[ i + 3 ]; uv[ i + 3 ] = temp;
                }

                if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) )
                {
                    temp = uv[ i + 0 ]; uv[ i + 0 ] = uv[ i + 3 ]; uv[ i + 3 ] = temp;
                    temp = uv[ i + 1 ]; uv[ i + 1 ] = uv[ i + 2 ]; uv[ i + 2 ] = temp;
                }

            }

            if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) )
            {

                var th = new Vector2[ uv.Length ];
                Array.Copy( uv, th, uv.Length );

                // Swap top-left and top-right corners
                Array.Copy( uv, 0, uv, 4, 4 );
                Array.Copy( th, 4, uv, 0, 4 );

                // Swap bottom-left and bottom-right corners
                Array.Copy( uv, 8, uv, 12, 4 );
                Array.Copy( th, 12, uv, 8, 4 );

            }

            if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) )
            {

                var tv = new Vector2[ uv.Length ];
                Array.Copy( uv, tv, uv.Length );

                // Swap top-left and bottom-left corners
                Array.Copy( uv, 0, uv, 8, 4 );
                Array.Copy( tv, 8, uv, 0, 4 );

                // Swap top-right and bottom-right corners
                Array.Copy( uv, 4, uv, 12, 4 );
                Array.Copy( tv, 12, uv, 4, 4 );

            }

        }

        #endregion

        for( int i = 0; i < uv.Length; i++ )
        {
            renderData.UV.Add( uv[ i ] );
//.........这里部分代码省略.........
开发者ID:haozi000005,项目名称:happy2d,代码行数:101,代码来源:dfSlicedSprite.cs


示例15: rebuildTriangles

    private static void rebuildTriangles( dfRenderData renderData, RenderOptions options )
    {
        var baseIndex = options.baseIndex;

        var triangles = renderData.Triangles;
        for( int i = 0; i < triangleIndices.Length; i++ )
        {
            triangles.Add( baseIndex + triangleIndices[ i ] );
        }
    }
开发者ID:haozi000005,项目名称:happy2d,代码行数:10,代码来源:dfSlicedSprite.cs


示例16: DrawDashedWithOffset

        private static void DrawDashedWithOffset(GraphicsTarget g, SymPath path, Pen pen, DashInfo dashes, float offsetRight, float miterLimit, RenderOptions renderOpts)
        {
            float[] distances;

            distances = ComputeDashDistances(path, LocationKind.DashAndGapLengths, dashes.dashLength, dashes.firstDashLength, dashes.lastDashLength, dashes.gapLength, dashes.minGaps, 0, dashes.secondaryEndGaps, dashes.secondaryEndLength, dashes.secondaryMiddleGaps, dashes.secondaryMiddleLength, 1.0F, false);

            if (distances.Length == 0 || (dashes.gapLength < renderOpts.minResolution && (dashes.secondaryMiddleGaps == 0 || dashes.secondaryMiddleLength < renderOpts.minResolution) && (dashes.secondaryEndGaps == 0 || dashes.secondaryEndLength < renderOpts.minResolution))) {
                // No dashes, or the dashes are too small to be visible. Draw solid.
                if (offsetRight != 0) {
                    SymPath offsetPath = path.OffsetRight(offsetRight, miterLimit);
                    offsetPath.Draw(g, pen);
                }
                else
                    path.Draw(g, pen);
            }
            else {
                path.DrawDashedOffsetBizzarro(g, pen, distances, 0, offsetRight, miterLimit);
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:19,代码来源:SymDef.cs


示例17: DrawGlyphs

        // Draw the glyphs along the path. "longPath" is the same as path unless shortening of the ends has occurred, in which case
        // path is the shortened path (used for all glyphs except start and end), and longPath is used for the start and end.
        private void DrawGlyphs(GraphicsTarget g, GlyphInfo glyphInfo, SymPath path, SymPath longPath, SymColor color, RenderOptions renderOpts)
        {
            float[] distances;
            PointF[] points;
            float[] perpAngles, subtendedAngles;
            float firstDistance;

            // Figure out the distances of the glyphs along the line.
            switch (glyphInfo.location) {
            case GlyphLocation.Corners:
                // Corner points are done somewhat differently. Only can have 1 symbol.
                // There is an interesting feature in OCAD where the dimensions of corner glyphs are stretched a certain amount at
                // very acute angles. This is so that power line crossbars always extend beyond the power lines themselves.
                // This is handled by stretching the glyph based on the subtended angle at the corner.
                points = path.FindCornerPoints(out perpAngles, out subtendedAngles);
                if (points != null) {
                    for (int i = 0; i < points.Length; ++i) {
                        float subtendedAngle = subtendedAngles[i];
                        float stretch;
                        if (subtendedAngle != 0)
                            stretch = Util.MiterFactor(subtendedAngle);
                        else
                            stretch = 1.0F;
                        stretch = Math.Min(stretch, CORNER_GLYPH_STRETCH_LIMIT);

                        Matrix stretchMatrix = new Matrix();
                        stretchMatrix.Scale(1.0F, stretch);

                        glyphInfo.glyph.Draw(g, points[i], perpAngles[i] + 90.0F, stretchMatrix, null, color, renderOpts);
                    }
                }
                return;

            case GlyphLocation.Spaced:
                distances = ComputeDashDistances(path, LocationKind.GapCenters, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.SpacedOffset:
                distances = ComputeDashDistances(path, LocationKind.GapCentersOffset, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, glyphInfo.offset, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.SpacedDecrease:
                distances = ComputeDashDistances(path, LocationKind.GapCentersDecrease, glyphInfo.distance, glyphInfo.firstDistance, glyphInfo.lastDistance, 0, glyphInfo.minimum, 0, 0, 0, 0, 0, glyphInfo.decreaseLimit, glyphInfo.decreaseBothEnds);

                if (distances != null && distances.Length > 0) {
                    firstDistance = distances[0];

                    for (int n = 0; n < glyphInfo.number; ++n) {
                        distances[0] = Math.Max(0.0F, firstDistance - ((glyphInfo.number - 1 - n * 2) * (glyphInfo.spacing / 2.0F)));

                        points = path.FindPointsAlongLineBizzarro(distances, out perpAngles);

                        for (int i = 0; i < points.Length; ++i) {
                            float decreaseFactor;
                            if (glyphInfo.decreaseBothEnds) {
                                if (points.Length <= 2)
                                    decreaseFactor = glyphInfo.decreaseLimit;
                                else
                                    decreaseFactor = 1.0F - (Math.Abs(i - ((points.Length-1) / 2F)) * (1 - glyphInfo.decreaseLimit) / ((points.Length-1) / 2F));
                            }
                            else {
                                if (i == 0)
                                    decreaseFactor = 1.0F;
                                else
                                    decreaseFactor = 1.0F - (i * (1 - glyphInfo.decreaseLimit) / (points.Length - 1));
                            }
                            Matrix matrixTransform = new Matrix();
                            matrixTransform.Scale(decreaseFactor, decreaseFactor);
                            glyphInfo.glyph.Draw(g, points[i], perpAngles[i], matrixTransform, null, color, renderOpts);
                        }
                    }
                }

                return;
            case GlyphLocation.DashCenters:
                distances = ComputeDashDistances(path, LocationKind.DashCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, dashInfo.minGaps, 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.MiddleDashCenters:
                distances = ComputeDashDistances(path, LocationKind.MiddleDashCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, dashInfo.minGaps, 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.GapCenters:
                // OCAD doesn't respect the "0 minimum gaps" for the symbols, although it does for the gaps. Always have at least one symbol. This is handled on import by having glyphInfo.minimum be 1.
                distances = ComputeDashDistances(path, LocationKind.GapCenters, dashInfo.dashLength, dashInfo.firstDashLength, dashInfo.lastDashLength, dashInfo.gapLength, Math.Max(glyphInfo.minimum, dashInfo.minGaps), 0, 0, 0, 0, 0, 1.0F, false);
                break;
            case GlyphLocation.Start:
                distances = new float[1] { 0 };
                break;
            case GlyphLocation.End:
                distances = new float[1] { longPath.BizzarroLength };
                break;
            default:
                Debug.Fail("bad glyph location");
                return;
            }

            if (distances == null || distances.Length == 0)
                return;
            firstDistance = distances[0];

            for (int n = 0; n < glyphInfo.number; ++n) {
//.........这里部分代码省略.........
开发者ID:jonc,项目名称:carto,代码行数:101,代码来源:SymDef.cs


示例18: RenderToMapThenToBitmap

        // Render a description to a map, then to a bitmap for testing purposes. Hardcoded 6 mm box size.
        internal static Bitmap RenderToMapThenToBitmap(SymbolDB symbolDB, DescriptionLine[] description, DescriptionKind kind, int numColumns)
        {
            DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB);
            descriptionRenderer.Description = description;
            descriptionRenderer.DescriptionKind = kind;
            descriptionRenderer.CellSize = 6.0F;
            descriptionRenderer.Margin = 0.7F;
            descriptionRenderer.NumberOfColumns = numColumns;
            PointF location = new PointF(30, -100);

            SizeF size = descriptionRenderer.Measure();

            Bitmap bm = new Bitmap((int) size.Width * 8, (int) size.Height * 8);
            Graphics g = Graphics.FromImage(bm);
            g.ScaleTransform(bm.Width / size.Width, -bm.Height / size.Height);
            g.TranslateTransform(-location.X, -location.Y);

            g.Clear(Color.White);

            Map map = new Map(new GDIPlus_TextMetrics(), null);
            using (map.Write()) {
                Dictionary<object, SymDef> dict = new Dictionary<object, SymDef>();

                // Create white color and white-out symdef.
                SymColor white = map.AddColorBottom("White", 44, 0, 0, 0, 0, false);
                AreaSymDef whiteArea = new AreaSymDef("White out", "890", white, null);
                whiteArea.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.WhiteOut_OcadToolbox);
                map.AddSymdef(whiteArea);
                dict[CourseLayout.KeyWhiteOut] = whiteArea;

                SymColor color = map.AddColor("Purple", 11, 0.045F, 0.59F, 0, 0.255F, false);
                descriptionRenderer.RenderToMap(map, color, location, dict);
            }

            InputOutput.WriteFile(TestUtil.GetTestFile("descriptions\\desc_temp.ocd"), map, new MapFileFormat(MapFileFormatKind.OCAD, 8));

            using (map.Read()) {
                RenderOptions renderOpts = new RenderOptions();
                renderOpts.usePatternBitmaps = true;
                renderOpts.minResolution = 0.1F;
                renderOpts.renderTemplates = RenderTemplateOption.MapAndTemplates;
                map.Draw(new GDIPlus_GraphicsTarget(g), new RectangleF(location.X, location.Y - size.Height, size.Width, size.Height), renderOpts, null);
            }

            g.Dispose();

            return bm;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:49,代码来源:DescriptionRendererTests.cs


示例19: Render

 /// <summary>
 /// Draws the animated image to bitmap.
 /// </summary>
 /// <param name="index">
 /// Zero-based frame index.
 /// </param>
 /// <param name="options">
 /// More rendering options.
 /// </param>
 /// <returns>
 /// Drawn image.
 /// </returns>
 public Image Render(byte index, RenderOptions options)
 {
     return Drawing.DrawBitmap(Frames[index].ImageData, Frames[index].Width, Frames[index].Height, options);
 }
开发者ID:IllidanS4,项目名称:AlbLib,代码行数:16,代码来源:AnimatedHeaderedImage.cs


示例20: DrawHatchLines

        // Draw a set of horizontal hatching lines at the given spacing with
        // the given pen. A line should be centered on the zero y coordinate.
        void DrawHatchLines(GraphicsTarget g, Pen pen, float spacing, RectangleF boundingRect, RenderOptions renderOpts)
        {
            double firstLine = Math.Round(boundingRect.Top / spacing) * spacing;
            double lastLine = (Math.Round(boundingRect.Bottom / spacing) + 0.5) * spacing;

            for (double y = firstLine; y <= lastLine; y += spacing) {
                g.DrawLine(pen, new PointF(boundingRect.Left, (float) y), new PointF(boundingRect.Right, (float) y));
            }
        }
开发者ID:jonc,项目名称:carto,代码行数:11,代码来源:SymDef.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RenderState类代码示例发布时间:2022-05-24
下一篇:
C# RenderMode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap