本文整理汇总了C#中Microsoft.Graphics.Canvas.CanvasDrawingSession.FillRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasDrawingSession.FillRectangle方法的具体用法?C# CanvasDrawingSession.FillRectangle怎么用?C# CanvasDrawingSession.FillRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Graphics.Canvas.CanvasDrawingSession
的用法示例。
在下文中一共展示了CanvasDrawingSession.FillRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoEffect
private void DoEffect(CanvasDrawingSession ds, Size size, float amount, Windows.UI.Color glowColor, Windows.UI.Color fillColor, double expandAmount)
{
var offset = (float)expandAmount / 2;
//using (var textLayout = CreateTextLayout(ds, size))
using (var cl = new CanvasCommandList(ds))
{
using (var clds = cl.CreateDrawingSession())
{
clds.FillRectangle(0, 0, (float)size.Width, (float)size.Height, glowColor);
}
glowEffectGraph.Setup(cl, amount);
ds.DrawImage(glowEffectGraph.Output, offset, offset);
ds.FillRectangle(offset, offset, (float)size.Width, (float)size.Height, fillColor);
}
}
示例2: Draw
public void Draw(CanvasDrawingSession ds, int frameCounter, float width, float height)
{
Size sz = sourceBitmap.Size;
double sourceSizeScale = (Math.Sin(frameCounter * 0.03) * 0.3) + 0.7;
Point center = new Point(Math.Sin(frameCounter * 0.02), (Math.Cos(frameCounter * 0.01)));
center.X *= (1 - sourceSizeScale) * sz.Width * 0.5;
center.Y *= (1 - sourceSizeScale) * sz.Height * 0.5;
center.X += sz.Width * 0.5;
center.Y += sz.Height * 0.5;
Rect sourceRect = new Rect(
center.X - sz.Width * sourceSizeScale * 0.5,
center.Y - sz.Height * sourceSizeScale * 0.5,
sz.Width * sourceSizeScale,
sz.Height * sourceSizeScale);
UpdateSourceRectRT(sourceRect);
var format = new CanvasTextFormat()
{
FontSize = 14,
HorizontalAlignment = CanvasHorizontalAlignment.Right,
VerticalAlignment = CanvasVerticalAlignment.Center,
WordWrapping = CanvasWordWrapping.Wrap
};
float y = 0;
float labelX = width / 2 - 5;
float imageX = width / 2 + 5;
float entryHeight = (float)sourceBitmap.Bounds.Height;
float margin = 14;
Rect labelRect = new Rect(0, y, labelX, entryHeight);
ds.DrawText(string.Format("Source image {0} DPI", sourceBitmap.Dpi), labelRect, Colors.White, format);
ds.FillRectangle(imageX, y, (float)sz.Width, (float)sz.Height, fillPattern);
ds.DrawImage(showSourceRectRT, imageX, y, showSourceRectRT.Bounds, 1, CanvasImageInterpolation.NearestNeighbor);
y += entryHeight + margin;
labelRect.Y = y;
ds.DrawText("D2D DrawBitmap (emulated dest rect)", labelRect, Colors.White, format);
ds.FillRectangle(imageX, y, (float)sz.Width, (float)sz.Height, fillPattern);
ds.DrawImage(sourceBitmap, imageX, y, sourceRect);
y += (float)sourceBitmap.Bounds.Height + 14;
labelRect.Y = y;
ds.DrawText("D2D DrawImage", labelRect, Colors.White, format);
ds.FillRectangle(imageX, y, (float)sz.Width, (float)sz.Height, fillPattern);
ds.DrawImage(sourceEffect, imageX, y, sourceRect);
}
示例3: DrawTextWithBackground
private void DrawTextWithBackground(CanvasDrawingSession ds, CanvasTextLayout layout, double x, double y)
{
var backgroundRect = layout.LayoutBounds;
backgroundRect.X += x;
backgroundRect.Y += y;
backgroundRect.X -= 20;
backgroundRect.Y -= 20;
backgroundRect.Width += 40;
backgroundRect.Height += 40;
ds.FillRectangle(backgroundRect, Colors.White);
ds.DrawTextLayout(layout, (float)x, (float)y, Colors.Black);
}
示例4: Draw
void Draw(CanvasDrawingSession drawingSession, string text, Size size)
{
// Background gradient.
using (var brush = CanvasRadialGradientBrush.CreateRainbow(drawingSession, 0))
{
brush.Center = size.ToVector2() / 2;
brush.RadiusX = (float)size.Width;
brush.RadiusY = (float)size.Height;
drawingSession.FillRectangle(0, 0, (float)size.Width, (float)size.Height, brush);
}
// Text label.
var label = string.Format("{0}\n{1:0} x {2:0}", text, size.Width, size.Height);
drawingSession.DrawText(label, size.ToVector2() / 2, Colors.Black, textLabelFormat);
}
示例5: DrawSubregions
private void DrawSubregions(CanvasDrawingSession ds)
{
for (int x = 0; x < Width; x++)
{
for (int y = 0; y < Height; y++)
{
ds.FillRectangle(new Rect(x * Statics.MapResolution, y * Statics.MapResolution, Statics.MapResolution, Statics.MapResolution), MasterOvergroundRoomList[x, y].ProtoSubregion.Color);
}
}
}
示例6: Draw
public void Draw(CanvasAnimatedDrawEventArgs args, CanvasDrawingSession ds, float width, float height)
{
drawCount++;
const int maxEntries = 120;
updatesPerDraw.Enqueue(updatesThisDraw);
while (updatesPerDraw.Count > maxEntries)
updatesPerDraw.Dequeue();
ds.Antialiasing = CanvasAntialiasing.Aliased;
var barWidth = width / (float)maxEntries;
const float heightPerUpdate = 10.0f;
float barBottom = height * 0.25f;
int maxUpdates = 0;
int maxIndex = -1;
int index = 0;
foreach (int update in updatesPerDraw)
{
float barHeight = update * heightPerUpdate;
Color color = Colors.Gray;
if ((Math.Max(0, drawCount - maxEntries) + index) % 60 == 0)
color = Colors.White;
ds.FillRectangle(barWidth * index, height - barHeight - barBottom, barWidth, barHeight + barBottom, color);
if (update > maxUpdates)
{
maxIndex = index;
maxUpdates = update;
}
index++;
}
if (maxUpdates > 0)
{
var y = height - maxUpdates * heightPerUpdate - barBottom;
ds.DrawLine(0, y, width, y, Colors.White, 1, maxStroke);
ds.DrawText(
maxUpdates.ToString(),
0,
height - maxUpdates * heightPerUpdate - barBottom,
Colors.White,
new CanvasTextFormat()
{
FontSize = heightPerUpdate * 2,
HorizontalAlignment = CanvasHorizontalAlignment.Left,
VerticalAlignment = CanvasVerticalAlignment.Bottom
});
}
using (var textFormat = new CanvasTextFormat()
{
FontSize = width * 0.05f,
HorizontalAlignment = CanvasHorizontalAlignment.Left,
VerticalAlignment = CanvasVerticalAlignment.Top
})
{
float y = 1;
ds.DrawText("Updates per Draw", 1, y, Colors.White, textFormat);
y += textFormat.FontSize * 2;
textFormat.FontSize *= 0.6f;
ds.DrawText(string.Format("{0} total updates", args.Timing.UpdateCount), 1, y, Colors.Red, textFormat);
y += textFormat.FontSize * 1.2f;
ds.DrawText(string.Format("{0} total draws", drawCount), 1, y, Colors.Green, textFormat);
}
updatesThisDraw = 0;
}
示例7: DrawSourceGraphic
void DrawSourceGraphic(PerDeviceResources resources, CanvasDrawingSession ds, float offset)
{
var source = GetSourceBitmap(resources);
if (source != null)
{
// We can either draw a precreated bitmap...
ds.DrawImage(source, offset, offset);
}
else
{
// ... or directly draw some shapes.
ds.FillRectangle(offset, offset, testSize, testSize, Colors.Gray);
ds.DrawLine(offset, offset, offset + testSize, offset + testSize, Colors.Red);
ds.DrawLine(offset + testSize, offset, offset, offset + testSize, Colors.Red);
ds.DrawRectangle(offset + 0.5f, offset + 0.5f, testSize - 1, testSize - 1, Colors.Blue);
ds.DrawText("DPI test", new Vector2(offset + testSize / 2), Colors.Blue, resources.TextFormat);
resources.AddMessage("DrawingSession ->\n");
}
}
示例8: DrawSquare
private void DrawSquare(CanvasControl sender, CanvasDrawingSession ds)
{
var width = (float) sender.ActualWidth;
var height = (float) sender.ActualHeight;
var stroke = this.defaultStroke;
var min = Math.Min(width, height);
min -= stroke * 2;
var rect = new Rect(stroke, stroke, min, min);
ds.FillRectangle(rect, ForegroundColor);
ds.DrawRectangle(rect, GlowColor, stroke);
}
示例9: DrawStuff
void DrawStuff(CanvasDrawingSession ds)
{
int horizontalLimit = (int)m_canvasControl.ActualWidth;
int verticalLimit = (int)m_canvasControl.ActualHeight;
const float thickStrokeWidth = 80.0f;
DrawnContentType drawnContentType = (DrawnContentType)m_drawnContentTypeCombo.SelectedValue;
ds.Clear(NextRandomColor());
Rect rect;
Vector2 point;
float radiusX;
float radiusY;
switch (drawnContentType)
{
case DrawnContentType.Clear_Only:
break;
case DrawnContentType.Bitmap:
if (m_bitmap_tiger != null)
{
ds.DrawImage(m_bitmap_tiger, NextRandomPoint(horizontalLimit, verticalLimit).ToVector2());
}
else
{
DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2);
}
break;
case DrawnContentType.Effect_Blur:
if (m_bitmap_tiger != null)
{
GaussianBlurEffect blurEffect = new GaussianBlurEffect();
blurEffect.StandardDeviation = 2.0f;
blurEffect.Source = m_bitmap_tiger;
ds.DrawImage(blurEffect, NextRandomPoint(horizontalLimit, verticalLimit).ToVector2());
}
else
{
DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2);
}
break;
case DrawnContentType.Line_Thin:
ds.DrawLine(
NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
NextRandomColor());
break;
case DrawnContentType.Line_Thick:
ds.DrawLine(
NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
NextRandomColor(),
thickStrokeWidth);
break;
case DrawnContentType.Rectangle_Thin:
ds.DrawRectangle(
NextRandomRect(horizontalLimit, verticalLimit),
NextRandomColor());
break;
case DrawnContentType.Rectangle_Thick:
ds.DrawRectangle(
NextRandomRect(horizontalLimit, verticalLimit),
NextRandomColor(),
thickStrokeWidth);
break;
case DrawnContentType.Rectangle_Filled:
ds.FillRectangle(
NextRandomRect(horizontalLimit, verticalLimit),
NextRandomColor());
break;
case DrawnContentType.RoundedRectangle_Thin:
NextRandomRoundedRect(horizontalLimit, verticalLimit, out rect, out radiusX, out radiusY);
ds.DrawRoundedRectangle(
rect, radiusX, radiusY,
NextRandomColor());
break;
case DrawnContentType.RoundedRectangle_Thick:
NextRandomRoundedRect(horizontalLimit, verticalLimit, out rect, out radiusX, out radiusY);
ds.DrawRoundedRectangle(
rect, radiusX, radiusY,
NextRandomColor(),
thickStrokeWidth);
break;
case DrawnContentType.Ellipse_Thin:
NextRandomEllipse(horizontalLimit, verticalLimit, out point, out radiusX, out radiusY);
ds.DrawEllipse(
point, radiusX, radiusY,
NextRandomColor());
break;
//.........这里部分代码省略.........
示例10: DrawViaImageBrush
void DrawViaImageBrush(CanvasDrawingSession ds)
{
imageBrush.Image = WrapSourceWithIntermediateImage(mainDeviceResources, CurrentIntermediate);
imageBrush.SourceRectangle = new Rect(0, 0, testSize, testSize);
imageBrush.Transform = Matrix3x2.CreateTranslation(testOffset, testOffset);
ds.FillRectangle(testOffset, testOffset, testSize, testSize, imageBrush);
mainDeviceResources.AddMessage("CanvasImageBrush ->\nCanvasControl (dpi: {0})", ds.Dpi);
}
示例11: DrawBars
private void DrawBars(IBin[] bins, CanvasDrawingSession session, CanvasControl canvas)
{
if (bins.Length == 0)
{
return;
}
double[] binValues = bins.Select(b => b.Value).ToArray();
double[] secondaryValues = null;
if (ShowSecondary)
{
secondaryValues = bins.Select(b => b.SecondaryValue).ToArray();
}
if (!DrawPrimaryFirst && ShowSecondary)
{
double[] temp = binValues;
binValues = secondaryValues;
secondaryValues = temp;
}
double maxBarHeight = canvas.ActualHeight - (BarPadding.Top + BarPadding.Bottom) - LabelSize.Height;
int binCount = binValues.Length;
double barWidth = canvas.ActualWidth / binCount;
double maxValue = MaxValue;
if (maxValue == 0)
{
maxValue = binValues.Max();
if (secondaryValues != null)
{
maxValue = Math.Max(maxValue, secondaryValues.Max());
}
}
double minValue = MinValue;
if (minValue > 0)
{
maxValue = Math.Max(minValue, maxValue);
}
double valueFactor = Math.Max(maxBarHeight / maxValue, 0);
Color barColor = BarColor;
Color secondaryBarColor = SecondaryBarColor;
Color highlightColor = HighlightBarColor;
for (int barIndex = 0; barIndex < binValues.Length; barIndex++)
{
double value = binValues[barIndex];
double left = barIndex * barWidth;
Rect r = new Rect();
r.X = left + BarPadding.Left;
r.Width = Math.Max(barWidth - (BarPadding.Left + BarPadding.Right), 0.1);
if (secondaryValues != null)
{
double secondaryValue = secondaryValues[barIndex];
r.Height = secondaryValue * valueFactor;
r.Y = maxBarHeight + BarPadding.Top - r.Height;
session.FillRectangle(r, secondaryBarColor);
}
r.Height = value * valueFactor;
r.Y = maxBarHeight + BarPadding.Top - r.Height;
if (bins[barIndex].IsHighlighted)
{
session.FillRectangle(r, highlightColor);
}
else
{
session.FillRectangle(r, barColor);
}
}
}
示例12: Clear
/// <summary>
/// Clears the raindrop region.
/// </summary>
/// <param name="force">param force force stop</param>
/// <returns>returns Boolean true if the animation is stopped</returns>
public bool Clear(RainyDay rainyday, CanvasDrawingSession context, bool force=false)
{
context.Blend = CanvasBlend.Copy;
context.FillRectangle(x - r - 1, y - r - 2, 2 * r + 2, 2 * r + 2, Colors.Transparent);
context.Blend = CanvasBlend.SourceOver;
if (force)
{
terminate = true;
return true;
}
if (rainyday == null)
{
return true;
}
if ((y - r > rainyday.Height) || (x - r > rainyday.Width) || (x + r < 0))
{
// over edge so stop this drop
return true;
}
return false;
}
示例13: DrawHistogram
void DrawHistogram(CanvasDrawingSession drawingSession, Size size, EffectChannelSelect channelSelect, CanvasLinearGradientBrush brush)
{
const int binCount = 64;
const float graphPower = 0.25f; // Nonlinear scale makes the graph show small changes more clearly.
float[] histogram = CanvasImage.ComputeHistogram(hueEffect, bitmap.Bounds, drawingSession, channelSelect, binCount);
var w = (float)size.Width / binCount;
var h = (float)size.Height;
for (int i = 0; i < binCount; i++)
{
var x = i * w;
var y = (1 - (float)Math.Pow(histogram[i], graphPower)) * h;
brush.StartPoint = new Vector2(x, y);
brush.EndPoint = new Vector2(x, h);
drawingSession.FillRectangle(x, y, w, h - y, brush);
}
}
示例14: DrawRectangleInternal
private static void DrawRectangleInternal(
CanvasDrawingSession ds,
Color brush,
Color pen,
CanvasStrokeStyle ss,
bool isStroked,
bool isFilled,
ref Rect2 rect,
double strokeWidth)
{
if (isFilled)
{
ds.FillRectangle(
(float)rect.X,
(float)rect.Y,
(float)rect.Width,
(float)rect.Height,
brush);
}
if (isStroked)
{
ds.DrawRectangle(
(float)rect.X,
(float)rect.Y,
(float)rect.Width,
(float)rect.Height,
pen,
(float)strokeWidth,
ss);
}
}
示例15: DrawTextOverWhiteRectangle
private static void DrawTextOverWhiteRectangle(CanvasDrawingSession ds, Vector2 paddedTopLeft, CanvasTextLayout textLayout)
{
var bounds = textLayout.LayoutBounds;
var rect = new Rect(bounds.Left + paddedTopLeft.X, bounds.Top + paddedTopLeft.Y, bounds.Width, bounds.Height);
ds.FillRectangle(rect, Colors.White);
ds.DrawTextLayout(textLayout, paddedTopLeft, Colors.Black);
}