本文整理汇总了C#中Microsoft.Graphics.Canvas.CanvasDrawingSession类的典型用法代码示例。如果您正苦于以下问题:C# CanvasDrawingSession类的具体用法?C# CanvasDrawingSession怎么用?C# CanvasDrawingSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CanvasDrawingSession类属于Microsoft.Graphics.Canvas命名空间,在下文中一共展示了CanvasDrawingSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw( CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures )
{
lock ( PFSim )
{
var Snapshot = PFSim.Snapshot();
while ( Snapshot.MoveNext() )
{
Particle P = Snapshot.Current;
float A = Vector2.Transform( new Vector2( 0, 1 ), Matrix3x2.CreateRotation( P.ttl * 0.01f ) ).X;
Vector4 Tint = new Vector4(
P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51,
P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52,
P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53,
P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54
);
Tint.W *= A;
ScrollWind.Strength *= 0.5f;
SBatch.Draw(
Textures[ P.TextureId ]
, P.Pos, Tint
, Textures.Center[ P.TextureId ], 0, P.Scale
, CanvasSpriteFlip.None );
}
DrawWireFrames( ds );
}
}
示例2: DrawLine
private void DrawLine(CanvasControl sender, CanvasDrawingSession ds)
{
var width = (float)sender.ActualWidth;
var height = (float)sender.ActualHeight;
var middle = height / 2;
int steps = Math.Min((int)(width / 10), 30);
for (int i = 0; i < steps; ++i)
{
var mu = (float)i / steps;
var a = (float)(mu * Math.PI * 2);
var color = GradientColor(mu);
var x = width * mu;
var y = (float)(middle + Math.Sin(a) * (middle * 0.3));
var strokeWidth = (float)(Math.Cos(a) + 1) * 5;
ds.DrawLine(x, 0, x, y, color, strokeWidth);
ds.DrawLine(x, height, x, y, color, 10 - strokeWidth);
}
}
示例3: Draw
public void Draw( CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures )
{
lock ( PFSim )
{
var Snapshot = PFSim.Snapshot();
while ( Snapshot.MoveNext() )
{
Particle P = Snapshot.Current;
float A = ( P.Trait & PFTrait.IMMORTAL ) == 0 ? P.ttl * 0.033f : 1;
P.Tint.M12 = 4 * ( 1 - A );
P.Tint.M21 = 3 * A;
Vector4 Tint = new Vector4(
P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51,
P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52,
P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53,
P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54
) * 2;
Tint.W *= A * 0.125f;
SBatch.Draw( Textures[ P.TextureId ], P.Pos, Tint, Textures.Center[ P.TextureId ], 0, P.Scale * A, CanvasSpriteFlip.None );
}
DrawWireFrames( ds );
}
}
示例4: Draw
public override void Draw(CanvasDrawingSession drawingSession, bool useSpriteBatch)
{
if (!surfaceLoaded)
return;
// 保护原先画布的混合模式
var previousBlend = drawingSession.Blend;
drawingSession.Blend = blendState;
#if WINDOWS_UWP
if (useSpriteBatch)
{
// 使用 SpriteBatch 可以提高性能
using (var spriteBatch = drawingSession.CreateSpriteBatch())
{
Draw(drawingSession, spriteBatch);
}
}
else
{
Draw(drawingSession, null);
}
#else
Draw(drawingSession);
#endif
drawingSession.Blend = previousBlend;
}
示例5: Draw
public void Draw(CanvasDrawingSession drawingSession, bool useSpriteBatch)
{
if (surfaceLoaded)
{
// 保护原先画布的混合模式
var previousBlend = drawingSession.Blend;
drawingSession.Blend = CanvasBlend.SourceOver;
#if WINDOWS_UWP
if (useSpriteBatch)
{
// 使用 SpriteBatch 可以提高性能
using (var spriteBatch = drawingSession.CreateSpriteBatch())
{
Draw(drawingSession, spriteBatch);
}
}
else
{
Draw(drawingSession, null);
}
#else
Draw(drawingSession);
#endif
drawingSession.Blend = previousBlend;
}
}
示例6: TransformSession
private TransformSession(CanvasDrawingSession session, Matrix3x2 oldTransform, SvgMatrix multiply)
{
this.Session = session;
this.OldTransform = oldTransform;
var transform = new Matrix3x2((float)multiply.A, (float)multiply.B, (float)multiply.C, (float)multiply.D, (float)multiply.E, (float)multiply.F);
session.Transform = transform * session.Transform;
}
示例7: Draw
//int count;
public void Draw(CanvasDrawingSession ds, Size sizeRender, float totalTimeSeconds)
{
//count++;
//ds.DrawText(count.ToString(), new Vector2(10.0f, 10.0f), Colors.Red);
SetupText(ds);
ConfigureEffect(totalTimeSeconds);
ds.DrawImage(composite, sizeRender.ToVector2() / 2);
}
示例8: Direct2DCommandExecutor
/// <summary>
/// Конструктор.
/// </summary>
/// <param name="session">Сессия отрисовки.</param>
/// <param name="factory">Фабрика.</param>
/// <param name="splitter">Средство разбики слов.</param>
/// <param name="renderWidth">Ширина отрисовки.</param>
public Direct2DCommandExecutor(CanvasDrawingSession session, IDirect2DElementFactory factory, IWordSplitter splitter, double renderWidth)
{
if (factory == null) throw new ArgumentNullException(nameof(factory));
if (session == null) throw new ArgumentNullException(nameof(session));
if (splitter == null) throw new ArgumentNullException(nameof(splitter));
Factory = factory;
Session = session;
Splitter = splitter;
RenderWidth = renderWidth;
}
示例9: DrawIcon
// Alternative entrypoint for use by AppIconGenerator.
internal void DrawIcon(CanvasDrawingSession drawingSession, string text)
{
this.text = text;
this.fontSize = 64;
CreateFlameEffect();
SetupText(drawingSession);
ConfigureEffect(new CanvasTimingInformation());
drawingSession.DrawImage(flamePosition);
drawingSession.DrawImage(textCommandList);
}
示例10: DrawWireFrames
protected void DrawWireFrames( CanvasDrawingSession ds )
{
#if DEBUG
lock ( PFSim )
{
if ( ShowWireFrame )
{
foreach ( IForceField IFF in PFSim.Fields )
{
IFF.WireFrame( ds );
}
}
}
#endif
}
示例11: DrawCircles
private void DrawCircles(CanvasControl sender, CanvasDrawingSession ds)
{
float width = (float)sender.ActualWidth;
float height = (float)sender.ActualHeight;
float endpointMargin = Math.Min(width, height) / 8;
float controlMarginX = endpointMargin * 4;
float controlMarginY = endpointMargin * 2;
for (int i = 0; i < 25; i++)
{
Vector2[] bez = new Vector2[4];
int n = (i * 24) + 9 - (i / 2);
for (int k = 0; k < 3; k++)
{
int j = 4 - (2 * k);
bez[k].X = (0 + (((n >> (j + 1)) & 1) * (width - controlMarginX)));
bez[k].Y = (0 + (((n >> j) & 1) * (height - controlMarginY)));
}
bez[3].X = width - endpointMargin; // Collect the ends in the lower right
bez[3].Y = height - endpointMargin;
const int nSteps = 80;
const float tStep = 1.0f / nSteps;
float t = 0;
for (int step = 0; step < nSteps; step++)
{
float s = 1 - t;
float ss = s * s;
float sss = ss * s;
float tt = t * t;
float ttt = tt * t;
float x = (sss * bez[0].X) + (3 * ss * t * bez[1].X) + (3 * s * tt * bez[2].X) + (ttt * bez[3].X);
float y = (sss * bez[0].Y) + (3 * ss * t * bez[1].Y) + (3 * s * tt * bez[2].Y) + (ttt * bez[3].Y);
float radius = ttt * endpointMargin;
float strokeWidth = (0.5f - Math.Abs(ss - 0.5f)) * 10;
ds.DrawCircle(x, y, radius, GradientColor(t), strokeWidth);
t += tStep;
}
}
}
示例12: DrawCanvasState
private void DrawCanvasState(CanvasControl canvas, CanvasDrawingSession ds, int drawCount)
{
ds.Clear(Color.FromArgb(0, 0, 0, 0));
ds.DrawLine(0, 0, (float)canvas.ActualWidth, (float)canvas.ActualHeight, Colors.Aqua);
ds.DrawLine(0, (float)canvas.ActualHeight, (float)canvas.ActualWidth, 0, Colors.Aqua);
var text = String.Format("{0}x{1}\n{2} redraws", (int)canvas.ActualWidth, (int)canvas.ActualHeight, drawCount);
ds.DrawText(
text,
0, 0,
Colors.FloralWhite,
new CanvasTextFormat()
{
VerticalAlignment = CanvasVerticalAlignment.Top,
ParagraphAlignment = ParagraphAlignment.Left,
FontSize = 10
});
}
示例13: ApplyBloomFilter
void ApplyBloomFilter(CanvasDrawingSession drawingSession)
{
// Configure effects to use the latest threshold, blur, and intensity settings.
extractBrightAreas.RedSlope =
extractBrightAreas.GreenSlope =
extractBrightAreas.BlueSlope = 1 / (1 - BloomThreshold / 100);
extractBrightAreas.RedOffset =
extractBrightAreas.GreenOffset =
extractBrightAreas.BlueOffset = -BloomThreshold / 100 / (1 - BloomThreshold / 100);
blurBrightAreas.BlurAmount = BloomBlur;
adjustBloomIntensity.RedSlope =
adjustBloomIntensity.GreenSlope =
adjustBloomIntensity.BlueSlope = BloomIntensity / 100;
// Apply the bloom effect.
drawingSession.DrawImage(bloomResult);
}
示例14: Draw
public void Draw(ICanvasAnimatedControl sender, CanvasDrawingSession drawingSession)
{
if (currentThunder == null)
{
return;
}
// 保护原先画布的混合模式
var previousBlend = drawingSession.Blend;
drawingSession.Blend = blendState;
var builder = new CanvasPathBuilder(sender);
builder.BeginFigure(0, 0);
for (int i = 0; i < currentThunder.LifeLong; i++)
{
builder.AddLine(currentThunder.Path[i].X, currentThunder.Path[i].Y);
}
builder.EndFigure(CanvasFigureLoop.Open);
builder.SetSegmentOptions(CanvasFigureSegmentOptions.ForceRoundLineJoin);
// Draw the particle.
var path = CanvasGeometry.CreatePath(builder);
var NormalizeLifeTime = currentThunder.TimeSinceStart / currentThunder.Duration;
byte opacity = (byte)((NormalizeLifeTime - 1) * (NormalizeLifeTime - 1) * 255);
CanvasCommandList cl = new CanvasCommandList(sender);
using (CanvasDrawingSession clds = cl.CreateDrawingSession())
{
clds.DrawGeometry(path, currentThunder.Position, Color.FromArgb((byte)(0.75f * opacity), 255, 255, 255), 6 * currentThunder.Luminace);
}
var lightAmount = 20.6f * currentThunder.Luminace * (NormalizeLifeTime - 1) * (NormalizeLifeTime - 1);
blur.Source = cl;
blur.BlurAmount = lightAmount;
drawingSession.DrawImage(blur);
drawingSession.DrawGeometry(path, currentThunder.Position, Color.FromArgb(opacity, 255, 240, 180), 2 * currentThunder.Luminace);
drawingSession.Blend = previousBlend;
if (NormalizeLifeTime > 1)
{
currentThunder = null;
}
}
示例15: DrawRectangle
private void DrawRectangle(CanvasControl sender, CanvasDrawingSession ds)
{
var width = (float)sender.ActualWidth;
var height = (float)sender.ActualHeight;
int steps = Math.Min((int)(width / 10), 20);
for (int i = 0; i < steps; ++i)
{
var mu = (float)i / steps;
var color = GradientColor(mu);
mu *= 0.5f;
var x = mu * width;
var y = mu * height;
var xx = (1 - mu) * width;
var yy = (1 - mu) * height;
ds.DrawRectangle(x, y, xx - x, yy - y, color, 2.0f);
}
}