本文整理汇总了C#中SharpDX.Direct2D1.RenderTarget.DrawEllipse方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.DrawEllipse方法的具体用法?C# RenderTarget.DrawEllipse怎么用?C# RenderTarget.DrawEllipse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpDX.Direct2D1.RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.DrawEllipse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(RenderTarget target)
{
InitializeResources(target);
target.Transform = Matrix.Identity;
target.FillEllipse(new Ellipse(new DrawingPointF(LeftPos.X,LeftPos.Y), 20, 20), Fill);
target.DrawEllipse(new Ellipse(new DrawingPointF(LeftPos.X, LeftPos.Y), 20, 20), Stroke);
target.FillEllipse(new Ellipse(new DrawingPointF(RightPos.X, RightPos.Y), 20, 20), Fill);
target.DrawEllipse(new Ellipse(new DrawingPointF(RightPos.X, RightPos.Y), 20, 20), Stroke);
}
示例2: Run
//.........这里部分代码省略.........
// ---------------------------------------------------------------------------------------------------
// Acquire the mutexes. These are needed to assure the device in use has exclusive access to the surface
// ---------------------------------------------------------------------------------------------------
var device10Mutex = textureD3D10.QueryInterface<KeyedMutex>();
var device11Mutex = textureD3D11.QueryInterface<KeyedMutex>();
// ---------------------------------------------------------------------------------------------------
// Main rendering loop
// ---------------------------------------------------------------------------------------------------
bool first = true;
RenderLoop
.Run(form,
() =>
{
if(first)
{
form.Activate();
first = false;
}
// clear the render target to black
context.ClearRenderTargetView(renderTargetView, Colors.DarkSlateGray);
// Draw the triangle
context.InputAssembler.InputLayout = layoutColor;
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBufferColor, VertexPositionColor.SizeInBytes, 0));
context.OutputMerger.BlendState = null;
var currentTechnique = effect.GetTechniqueByName("Color");
for (var pass = 0; pass < currentTechnique.Description.PassCount; ++pass)
{
using (var effectPass = currentTechnique.GetPassByIndex(pass))
{
System.Diagnostics.Debug.Assert(effectPass.IsValid, "Invalid EffectPass");
effectPass.Apply(context);
}
context.Draw(3, 0);
};
// Draw Ellipse on the shared Texture2D
device10Mutex.Acquire(0, 100);
renderTarget2D.BeginDraw();
renderTarget2D.Clear(Colors.Black);
renderTarget2D.DrawGeometry(tesselatedGeometry, solidColorBrush);
renderTarget2D.DrawEllipse(new Ellipse(center, 200, 200), solidColorBrush, 20, null);
renderTarget2D.EndDraw();
device10Mutex.Release(0);
// Draw the shared texture2D onto the screen, blending the 2d content in
device11Mutex.Acquire(0, 100);
var srv = new ShaderResourceView(device11, textureD3D11);
effect.GetVariableByName("g_Overlay").AsShaderResource().SetResource(srv);
context.InputAssembler.InputLayout = layoutOverlay;
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBufferOverlay, VertexPositionTexture.SizeInBytes, 0));
context.OutputMerger.BlendState = blendStateTransparent;
currentTechnique = effect.GetTechniqueByName("Overlay");
for (var pass = 0; pass < currentTechnique.Description.PassCount; ++pass)
{
using (var effectPass = currentTechnique.GetPassByIndex(pass))
{
System.Diagnostics.Debug.Assert(effectPass.IsValid, "Invalid EffectPass");
effectPass.Apply(context);
}
context.Draw(4, 0);
}
srv.Dispose();
device11Mutex.Release(0);
swapChain.Present(0, PresentFlags.None);
});
// dispose everything
vertexBufferColor.Dispose();
vertexBufferOverlay.Dispose();
layoutColor.Dispose();
layoutOverlay.Dispose();
effect.Dispose();
shaderByteCode.Dispose();
renderTarget2D.Dispose();
swapChain.Dispose();
device11.Dispose();
device10.Dispose();
textureD3D10.Dispose();
textureD3D11.Dispose();
factory1.Dispose();
adapter1.Dispose();
sharedResource.Dispose();
factory2D.Dispose();
surface.Dispose();
solidColorBrush.Dispose();
blendStateTransparent.Dispose();
device10Mutex.Dispose();
device11Mutex.Dispose();
}
示例3: Render2D
/// <summary>
/// render the circle to specific render target of Direct2D1
/// </summary>
/// <param name="renderTarget"></param>
public void Render2D( RenderTarget renderTarget , Brush brush)
{
// if the brush is dirty renew it
if ( m_isLineColorBrushDirty ) {
// clean the color brush
if ( m_lineColorBrush != null )
m_lineColorBrush.Dispose();
// allocate a new one
m_lineColorBrush = new SolidColorBrush( renderTarget, m_circleColor );
// clean the flag
m_isLineColorBrushDirty = false;
}
// check if we use other color
if ( m_useDefaultColor || m_lineColorBrush == null) {
renderTarget.DrawEllipse(m_Ellipse, brush);
} else {
// draw
renderTarget.DrawEllipse(m_Ellipse, m_lineColorBrush, m_lineWidth);
}
}