本文整理汇总了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);
}
示例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;
}
示例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);
}
示例4: PerspexTextRenderer
public PerspexTextRenderer(
RenderTarget target,
Brush foreground)
{
this.renderTarget = target;
this.foreground = foreground;
}
示例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);
}
示例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);
}
示例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;
}
示例8: Direct2D1DrawingContext
public Direct2D1DrawingContext(Factory factory, RenderTarget target)
{
this.factory = factory;
this.target = target;
this.target.BeginDraw();
this.stack = new Stack<object>();
}
示例9: OnUpdateTarget
public void OnUpdateTarget(RenderTarget target)
{
foreach (var pair in mBrushes)
pair.Value.OnUpdateBrush(pair.Key, target);
mTarget = target;
}
示例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;
}
示例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();
});
}
示例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);
}
示例13: CleanUp
public void CleanUp(RenderTarget target, Graphics g, Map map)
{
target.EndDraw();
var hdc = (IntPtr)target.Tag;
g.ReleaseHdc(hdc);
}
示例14: Render
public static void Render(RenderTarget pRender, float pPercent)
{
if (Loading) return;
pRender.BeginDraw();
currentLevel.Render(pRender, pPercent);
pRender.EndDraw();
}
示例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);
}
}