當前位置: 首頁>>代碼示例>>C#>>正文


C# Direct2D1.RenderTarget類代碼示例

本文整理匯總了C#中SharpDX.Direct2D1.RenderTarget的典型用法代碼示例。如果您正苦於以下問題:C# RenderTarget類的具體用法?C# RenderTarget怎麽用?C# RenderTarget使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RenderTarget類屬於SharpDX.Direct2D1命名空間,在下文中一共展示了RenderTarget類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Render

 public override void Render(RenderTarget pRender, float pPercent)
 {
     pRender.Transform = Matrix3x2.Identity;
     pRender.DrawText("dx:" + dx + "  dy:" + dy + "  da:" + da, Constants.SmallFont, new RectangleF(0, 0, 200, 50), new SolidColorBrush(pRender, Color4.Black));
     pRender.Transform = Matrix3x2.Rotation(MathUtil.DegreesToRadians(-a + 180)) * Matrix3x2.Translation(x, y);
     pRender.DrawBitmap(ShipBitmap, new RectangleF(-17, -17, 34, 34), 1.0f, BitmapInterpolationMode.Linear);
 }
開發者ID:jonathandlo,項目名稱:deep-space-dive,代碼行數:7,代碼來源:Ship.cs

示例2: RenderScatterGeometry

 public void RenderScatterGeometry(RenderTarget renderTarget)
 {
     double[] x = curve.X;
     double[] y = curve.Y;
     int length = x.Length;
     double xScale, xOffset, yScale, yOffset;
     xScale = graphToCanvas.Matrix.M11;
     xOffset = graphToCanvas.Matrix.OffsetX - this.xOffsetMarker;
     yScale = graphToCanvas.Matrix.M22;
     yOffset = graphToCanvas.Matrix.OffsetY - this.yOffsetMarker;
     bool[] include = curve.includeMarker;
     StrokeStyleProperties properties = new StrokeStyleProperties();
     properties.LineJoin = LineJoin.MiterOrBevel;
     StrokeStyle strokeStyle = new StrokeStyle(renderTarget.Factory, properties);
     for (int i = 0; i < length; ++i)
     {
         if (include[i])
         {
             renderTarget.Transform = (Matrix3x2)Matrix.Translation((float)(x[i] * xScale + xOffset), (float)(y[i] * yScale + yOffset), 0);
             renderTarget.FillGeometry(Geometry, FillBrush);
             renderTarget.DrawGeometry(Geometry, Brush, (float)StrokeThickness, strokeStyle);
         }
     }
     renderTarget.Transform = Matrix3x2.Identity;
 }
開發者ID:goutkannan,項目名稱:ironlab,代碼行數:25,代碼來源:DirectPathScatter.cs

示例3: Render

        public override void Render(RenderTarget pRender, float pPercent)
        {
            pRender.Clear(new RawColor4(0.9f, 0.85f, 0.75f, 1.0f));

            upgradesButton.Render(pRender, pPercent);
            playerShip.Render(pRender, pPercent);
        }
開發者ID:jonathandlo,項目名稱:deep-space-dive,代碼行數:7,代碼來源:LevelOne.cs

示例4: PerspexTextRenderer

 public PerspexTextRenderer(
     RenderTarget target,
     Brush foreground)
 {
     this.renderTarget = target;
     this.foreground = foreground;
 }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:7,代碼來源:PerspexTextRenderer.cs

示例5: OnRender

        public void OnRender(RenderTarget target)
        {
            if(gBorderBrush == null)
            {
                gBackgroundBrush = Brushes.Solid[0xCC555555];
                gBackgroundHoverBrush = Brushes.Solid[0xCC888888];
                gClickBrush = Brushes.Solid[0xFFFF7F00];
                gBackgroundClickedBrush = Brushes.Solid[0xCCBBBBBB];
                gBorderBrush = Brushes.White;
            }

            target.DrawTextLayout(new Vector2(Position.X + Size + 7, Position.Y - 2), mTextDraw, Brushes.White);

            var brush = gBackgroundBrush;
            if (mIsPressed)
                brush = gBackgroundClickedBrush;
            else if (mIsHovered)
                brush = gBackgroundHoverBrush;

            target.FillRectangle(mTargetRect, brush);
            target.DrawRectangle(mTargetRect, gBorderBrush);
            if (!Checked) return;

            target.DrawLine(Position + new Vector2(3, 3), Position + new Vector2(mSize - 3, mSize - 3), gClickBrush,
                mSize / 4.0f);
            target.DrawLine(new Vector2(Position.X + 3, Position.Y + mSize - 3),
                new Vector2(Position.X + mSize - 3, Position.Y + 3), gClickBrush, mSize / 4.0f);
        }
開發者ID:Linrasis,項目名稱:WoWEditor,代碼行數:28,代碼來源:Checkbox.cs

示例6: OnLoad

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
 
            // Direct2D
            var renderTargetProperties = new RenderTargetProperties()
            {
                PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore)
            };
            var hwndRenderTargetProperties = new HwndRenderTargetProperties()
            {
                Hwnd = this.Handle,
                PixelSize = new Size2(bounds.Width, bounds.Height),
                PresentOptions = PresentOptions.Immediately,
            };
            renderTarget = new WindowRenderTarget(factory, renderTargetProperties, hwndRenderTargetProperties);

            var bitmapProperties = new BitmapProperties()
            {
                PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore)
            };
            bitmap = new SharpDX.Direct2D1.Bitmap(renderTarget, new Size2(bounds.Width, bounds.Height), bitmapProperties);

            textFormat = new TextFormat(directWriteFacrtory, "Arial", FontWeight.Normal, SharpDX.DirectWrite.FontStyle.Normal, 96.0f);
            textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            textFormat.TextAlignment = TextAlignment.Center;

            solidColorBrush = new SolidColorBrush(renderTarget, Color4.White);
        }
開發者ID:dmak78,項目名稱:RoomAliveToolkit,代碼行數:29,代碼來源:ProjectorForm.cs

示例7: Draw

        /// <summary>
        /// Draws all the entities wich are visible in the viewport
        /// </summary>
        /// <param name="g">The RenderTarget used to perform the drawing operations.</param>
        public virtual void Draw(RenderTarget g)
        {
            //At the start set the matrix to the identy viewport matrix
            SetMatrixViewportID(g);
            //Start drawing all the entities.
            foreach (BaseEntity ent in VisibleEntities)
            {
                //If an entity is mirror the matrix needs to get mirrored too.
                if(ent.Mirrored)
                {
                    Matrix3x2 m = g.Transform;
                    m.ScaleVector = new Vector2(-1, 1);
                    m.TranslationVector = new Vector2(-VIEWPORT.X + ent.X + ent.Width + ent.X, -VIEWPORT.Y);
                    g.Transform = m;
                    /*
                    Vector2 mirroredviewPortTranslation = new Vector2(-VIEWPORT.X + ent.X + ent.Width + ent.X, -VIEWPORT.Y);
                    ViewportIDMatrixMirror.TranslationVector = mirroredviewPortTranslation;
                    g.Transform = ViewportIDMatrixMirror;
                    */
                }

                //Actual drawing of the entity
                ent.Draw(g);

                //If the entity was mirrored then the matrix needs to be reset back to the identity viewport matrix.
                if (ent.Mirrored)
                    SetMatrixViewportID(g);
            }
            if (Config.DEBUG_MODE == DebugMode.DISPLAY_HITBOX)
            {
                Quad.Draw(g);
            }
            g.Transform = Matrix.Identity;
        }
開發者ID:Harrum,項目名稱:TestGamePlsIgnore,代碼行數:38,代碼來源:RunnableComponent.cs

示例8: Direct2D1DrawingContext

 public Direct2D1DrawingContext(Factory factory, RenderTarget target)
 {
     this.factory = factory;
     this.target = target;
     this.target.BeginDraw();
     this.stack = new Stack<object>();
 }
開發者ID:modulexcite,項目名稱:Avalonia,代碼行數:7,代碼來源:Direct2D1DrawingContext.cs

示例9: OnUpdateTarget

        public void OnUpdateTarget(RenderTarget target)
        {
            foreach (var pair in mBrushes)
                pair.Value.OnUpdateBrush(pair.Key, target);

            mTarget = target;
        }
開發者ID:Linrasis,項目名稱:WoWEditor,代碼行數:7,代碼來源:Brushes.cs

示例10: CreateDrawingTarget

        /**
            Create a drawing target from an already existing RenderTarget.

            Note that the RenderTarget must use the the same Factory the
            drawing backend does.
        **/
        public IDrawingTarget CreateDrawingTarget(RenderTarget renderTarget)
        {
            var width = renderTarget.Size.Width;
            var height = renderTarget.Size.Height;

            var state = new DrawingState();
            var transform = new DrawingTransform();
            var drawingTarget = new DrawingTarget(state, transform, renderTarget, (int)Math.Floor(width), (int)Math.Floor(height));

            var target = new DrawingTargetSplitter(
                this,
                state,
                transform,
                drawingTarget,
                drawingTarget,
                drawingTarget,
                drawingTarget,
                drawingTarget,
                () =>
                {
                    drawingTarget.Dispose();
                });

            var pixelAligner = PixelAligningDrawingTarget.Create(target, target.Dispose, state, transform);
            return pixelAligner;
        }
開發者ID:pragmatrix,項目名稱:CrossUI,代碼行數:32,代碼來源:DrawingBackend.cs

示例11: beginDraw

        public IDisposable beginDraw(out IDrawingContext context)
        {
            var surface = _texture.AsSurface();

            var rtProperties = new RenderTargetProperties()
            {
                DpiX = 96,
                DpiY = 96,
                Type = RenderTargetType.Default,
                PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)
            };

            var renderTarget = new RenderTarget(_factory, surface, rtProperties);

            var c = new RenderTargetDrawingContext(renderTarget, _width, _height);
            context = c;

            renderTarget.BeginDraw();

            return new DisposeAction(() =>
                {
                    renderTarget.EndDraw();

                    c.Dispose();
                    renderTarget.Dispose();
                    surface.Dispose();
                });
        }
開發者ID:fundeveloper,項目名稱:CrossUI,代碼行數:28,代碼來源:BitmapDrawingContext.cs

示例12: CreateDirectBrush

        private BitmapBrush CreateDirectBrush(
            ImageBrush brush,
            RenderTarget target,
            Bitmap image, 
            Rect sourceRect, 
            Rect destinationRect)
        {
            var tileMode = brush.TileMode;
            var scale = brush.Stretch.CalculateScaling(destinationRect.Size, sourceRect.Size);
            var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale);
            var transform = Matrix.CreateTranslation(-sourceRect.Position) *
                Matrix.CreateScale(scale) *
                Matrix.CreateTranslation(translate);

            var opts = new BrushProperties
            {
                Transform = transform.ToDirect2D(),
                Opacity = (float)brush.Opacity,
            };

            var bitmapOpts = new BitmapBrushProperties
            {
                ExtendModeX = GetExtendModeX(tileMode),
                ExtendModeY = GetExtendModeY(tileMode),                
            };

            return new BitmapBrush(target, image, bitmapOpts, opts);
        }
開發者ID:shahid-pk,項目名稱:Perspex,代碼行數:28,代碼來源:ImageBrushImpl.cs

示例13: CleanUp

        public void CleanUp(RenderTarget target, Graphics g, Map map)
        {
            target.EndDraw();

            var hdc = (IntPtr)target.Tag;
            g.ReleaseHdc(hdc);
        }
開發者ID:lishxi,項目名稱:_SharpMap,代碼行數:7,代碼來源:DeviceContextRenderTargetFactory.cs

示例14: Render

        public static void Render(RenderTarget pRender, float pPercent)
        {
            if (Loading) return;

            pRender.BeginDraw();
            currentLevel.Render(pRender, pPercent);
            pRender.EndDraw();
        }
開發者ID:jonathandlo,項目名稱:deep-space-dive,代碼行數:8,代碼來源:GameController.cs

示例15: LoadFromFile

 /// <summary>
 /// Loads a Direct2D Bitmap from a file using System.Drawing.Image.FromFile(...)
 /// </summary>
 /// <param name="renderTarget">The render target.</param>
 /// <param name="file">The file.</param>
 /// <returns>A D2D1 Bitmap</returns>
 public static Bitmap LoadFromFile(RenderTarget renderTarget, string file)
 {
     // Loads from file using System.Drawing.Image
     using (var bitmap = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(file))
     {
         return LoadFromImage(renderTarget, file, bitmap);
     }
 }
開發者ID:lltcggie,項目名稱:StageMapEditor,代碼行數:14,代碼來源:ImageLoader.cs


注:本文中的SharpDX.Direct2D1.RenderTarget類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。