本文整理汇总了C#中IGraphics.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.Clear方法的具体用法?C# IGraphics.Clear怎么用?C# IGraphics.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
private void Render(IGraphics ig)
{
string s = cbWhat.Text;
if (s == "Clipping")
{
Pen pn = new Pen(Color.LightGray, 5);
Pen pn2 = new Pen(Color.Yellow);
ig.Clear(Color.Black);
GraphicsContainer cnt = ig.BeginContainer();
ig.SmoothingMode = SmoothingMode.HighQuality;
ig.SetClip(new Rectangle(35,35,120,120));
ig.DrawRectangle(pn, 5,5,45,70);
ig.DrawRectangle(pn, 15,25,90,120);
ig.DrawRectangle(pn, 50,30,100,170);
ig.DrawRectangle(pn, 5,80,180,30);
ig.DrawRectangle(pn, 75,10,40,160);
ig.EndContainer(cnt);
ig.DrawRectangle(pn2, 5,5,45,70);
ig.DrawRectangle(pn2, 15,25,90,120);
ig.DrawRectangle(pn2, 50,30,100,170);
ig.DrawRectangle(pn2, 5,80,180,30);
ig.DrawRectangle(pn2, 75,10,40,160);
}
else if (s == "Transforms")
{
ig.Clear(Color.Black);
ig.RotateTransform(15);
ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);
ig.ResetTransform();
ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);
ig.TranslateTransform(15,-5);
GraphicsContainer cnt = ig.BeginContainer();
ig.SmoothingMode = SmoothingMode.HighQuality;
ig.RotateTransform(5);
ig.FillEllipse(new SolidBrush(Color.Orange), 100,100,80,40);
ig.DrawRectangle(new Pen(Color.Orange,2), 60,80,40,40);
GraphicsContainer cnt2 = ig.BeginContainer();
ig.SmoothingMode = SmoothingMode.None;
ig.RotateTransform(5);
ig.ScaleTransform(1.1f, 1.2f);
ig.FillEllipse(new SolidBrush(Color.YellowGreen), 130,180,80,40);
ig.DrawRectangle(new Pen(Color.YellowGreen,2), 62,80,40,40);
GraphicsContainer cnt3 = ig.BeginContainer();
ig.SmoothingMode = SmoothingMode.HighQuality;
Matrix mm = new Matrix();
mm.Shear(0.3f, 0f);
ig.Transform = mm;
ig.FillEllipse(new SolidBrush(Color.Green), 180,120,80,40);
ig.DrawRectangle(new Pen(Color.Green,2), 62,84,40,40);
ig.EndContainer(cnt3);
ig.EndContainer(cnt2);
ig.FillEllipse(new SolidBrush(Color.Blue), 120,150,80,40);
ig.DrawRectangle(new Pen(Color.Blue,2), 64,80,40,40);
ig.EndContainer(cnt);
ig.FillEllipse(new SolidBrush(Color.Indigo), 80,210,80,40);
ig.DrawRectangle(new Pen(Color.Indigo,2), 66,80,40,40);
ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);
ig.ResetTransform();
ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);
}
else if (s == "Lines")
{
ig.SmoothingMode = SmoothingMode.AntiAlias;
Pen ow = new Pen(Color.Purple, 12);
ow.EndCap = LineCap.Round;
ow.StartCap = LineCap.Round;
ow.MiterLimit = 6f;
ow.LineJoin = LineJoin.Miter;
ig.SmoothingMode = SmoothingMode.None;
//.........这里部分代码省略.........
示例2: RenderMap
/// <summary>
/// Renders the map using the provided <see cref="IGraphics"/> object.
/// </summary>
/// <param name="g">the <see cref="IGraphics"/> object to use</param>
/// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param>
/// <param name="drawMapDecorations">Set whether to draw map decorations on the map (if such are set)</param>
/// <param name="drawTransparent">Set wether to draw with transparent background or with BackColor as background</param>
/// <exception cref="ArgumentNullException">if <see cref="IGraphics"/> object is null.</exception>
/// <exception cref="InvalidOperationException">if there are no layers to render.</exception>
public void RenderMap(IGraphics g, LayerCollectionType layerCollectionType, bool drawMapDecorations, bool drawTransparent)
{
if (g == null)
throw new ArgumentNullException("g", "Cannot render map with null graphics object!");
VariableLayerCollection.Pause = true;
LayerCollection lc = null;
switch (layerCollectionType)
{
case LayerCollectionType.Static:
lc = Layers;
break;
case LayerCollectionType.Variable:
lc = VariableLayers;
break;
case LayerCollectionType.Background:
lc = BackgroundLayer;
break;
}
if (lc == null || lc.Count == 0)
throw new InvalidOperationException("No layers to render");
Matrix transform = g.Transform;
lock (MapTransform)
{
g.Transform = MapTransform.Clone();
}
if (!drawTransparent)
g.Clear(BackColor);
g.PageUnit = GraphicsUnitType.Pixel;
LayerCollectionRenderer.AllowParallel = true;
using (var lcr = new LayerCollectionRenderer(lc))
{
lcr.Render(g, this);
}
/*
var layerList = new ILayer[lc.Count];
lc.CopyTo(layerList, 0);
foreach (ILayer layer in layerList)
{
if (layer.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom)
layer.Render(g, this);
}
*/
if (drawTransparent)
g.Transform = transform;
if (layerCollectionType == LayerCollectionType.Static)
{
#pragma warning disable 612,618
RenderDisclaimer(g);
#pragma warning restore 612,618
if (drawMapDecorations)
{
foreach (var mapDecoration in Decorations)
{
mapDecoration.Render(g, this);
}
}
}
VariableLayerCollection.Pause = false;
}
示例3: Draw
void Draw(IGraphics g, DrawingMode mode)
{
g.SmoothingMode = checkBoxAntialiasing.Checked ? SmoothingMode.HighQuality : SmoothingMode.None;
g.Clear(Color.White);
DrawMillimeterGridInPixels(g, tabControl1.SelectedTab.Controls[0].ClientRectangle);
g.PageUnit = GraphicsUnit.Millimeter;
var points = _noisePoints;
DrawLines(g, points, mode);
g.ResetTransform();
var path = CreateRoundedRectanglePath(new RectangleF(10, 10, 100, 40), 10);
g.FillPath(new SolidBrush(Color.FromArgb(120, Color.LightSlateGray)), path);
g.DrawPath(new Pen(Color.LightSlateGray, 0.0f), path);
g.FillPie(new SolidBrush(Color.FromArgb(120, Color.CadetBlue)), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);
g.DrawPie(new Pen(Color.CadetBlue, 0.0f), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);
//GLGraphics gl = g as GLGraphics;
//if (gl != null)
// gl.FillTextBackground = gl.FillTextBackground_glReadPixels;
g.PageUnit = GraphicsUnit.Pixel;
RectangleF rect = new RectangleF(30.0f, 15.0f, _testImage.Width, _testImage.Height);
g.DrawImage(_testImage, rect);
g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
g.PageUnit = GraphicsUnit.Millimeter;
g.HintTextBackgroundAction((gdi, textLocation, textRect) =>
{
_millimeterGridBrush.ResetTransform();
_millimeterGridBrush.TranslateTransform(-textLocation.X, -textLocation.Y);
gdi.FillRectangle(_millimeterGridBrush, textRect);
});
g.DrawString("Testovací řetězec pro odzkoušení správné implementace IGraphics - metody DrawString.",
new Font("Arial", 12.0f), Brushes.Black, new PointF(100.0f, 58.0f));
}
示例4: Draw
/// <summary>
/// Draws the sprites
/// </summary>
/// <param name="gameTime">Game time</param>
/// <param name="renderer">Graphics</param>
public void Draw(GameTime gameTime, IGraphics renderer)
{
// Draw the walls to the map buffer
this.mapGraphics.DrawImage(this.mapImage, 0, 0, this.mapImage.Width, this.mapImage.Height);
// Draw all objects to the map buffer
foreach (Sprite sprite in this.allObjects)
{
sprite.Draw(this.mapGraphics, gameTime);
}
// Clear the screen background (because it is larger than the map)
renderer.Clear(Color.Black);
// Draw the map to the screen buffer
renderer.DrawImage(this.mapBuffer, MapXoffset, MapYoffset, this.mapBuffer.Width, this.mapBuffer.Height);
// Draw the text messages to the screen buffer
this.DrawMessages(gameTime, renderer);
}