本文整理汇总了C#中IGraphics类的典型用法代码示例。如果您正苦于以下问题:C# IGraphics类的具体用法?C# IGraphics怎么用?C# IGraphics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IGraphics类属于命名空间,在下文中一共展示了IGraphics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(IGraphics graphics)
{
int drawX = (int)Math.Round(X);
int drawY = (int)Math.Round(Y);
graphics.SetColor(255, r, g, b);
graphics.DrawObject(Image.BigExplosion, drawX, drawY, 64, 64, animation / 4, animation % 4, angle);
}
示例2: Draw
public override void Draw(int size, int x, int y, IGraphics g, Pen pen, Brush brush)
{
int s2 = size/2;
Point[] points = new[]{new Point(x - s2, y), new Point(x, y - s2), new Point(x + s2, y), new Point(x, y + s2)};
g.FillPolygon(brush, points);
g.DrawPolygon(pen, points);
}
示例3: Draw
/// <summary>
/// Advances the time position and draws the current frame of the animation.
/// </summary>
/// <param name="gameTime">A game time</param>
/// <param name="spriteBatch">A graphics</param>
/// <param name="position">A position</param>
/// <param name="spriteEffects">To flip an image</param> NOT USED
public void Draw(GameTime gameTime, IGraphics spriteBatch, PointF position, bool spriteEffects)
{
if (AnimTexture == null)
{
throw new NotSupportedException("No animation is currently playing.");
}
// Process passing time.
this.time += (float)gameTime.ElapsedTime.TotalSeconds;
while (this.time > AnimTexture.FrameTime)
{
this.time -= AnimTexture.FrameTime;
// Advance the frame index; looping or clamping as appropriate.
if (AnimTexture.IsLooping)
{
this.FrameIndex = (this.FrameIndex + 1) % AnimTexture.FrameCount;
}
else
{
this.FrameIndex = Math.Min(this.FrameIndex + 1, AnimTexture.FrameCount - 1);
}
}
// Draw the current frame.
this.DrawFrame(spriteBatch, position, this.FrameIndex);
}
示例4: Draw
protected virtual void Draw (IGraphics g, int startIndex, int length, float thickness)
{
g.BeginEntity (this);
if (length == 0) {
}
else if (length == 1) {
var p = _points [startIndex];
var r = thickness / 2;
g.FillOval (p.X - r, p.Y - r, thickness, thickness);
}
else {
g.BeginLines (true);
var end = startIndex + length;
for (var i = startIndex; i < end - 1; i++) {
g.DrawLine (
_points [i].X,
_points [i].Y,
_points [i + 1].X,
_points [i + 1].Y,
thickness);
}
g.EndLines ();
}
}
示例5: Draw
public override void Draw(int size, float x, float y, IGraphics g, Pen2 pen, Brush2 brush)
{
int s2 = size/2;
Point2[] points = {new Point2(x - s2, y), new Point2(x, y - s2), new Point2(x + s2, y), new Point2(x, y + s2)};
g.FillPolygon(brush, points);
g.DrawPolygon(pen, points);
}
示例6: PaintImp
/// <summary>
/// Paints the fragment
/// </summary>
/// <param name="g">the device to draw to</param>
protected override void PaintImp(IGraphics g)
{
var offset = HtmlContainer != null ? HtmlContainer.ScrollOffset : PointF.Empty;
var rect = new RectangleF(Bounds.X + offset.X, Bounds.Y + offset.Y, Bounds.Width, Bounds.Height);
if (rect.Height > 2 && RenderUtils.IsColorVisible(ActualBackgroundColor))
{
g.FillRectangle(RenderUtils.GetSolidBrush(ActualBackgroundColor), rect.X, rect.Y, rect.Width, rect.Height);
}
var b1 = RenderUtils.GetSolidBrush(ActualBorderTopColor);
BordersDrawHandler.DrawBorder(Border.Top, g, this, b1, rect);
if (rect.Height > 1)
{
var b2 = RenderUtils.GetSolidBrush(ActualBorderLeftColor);
BordersDrawHandler.DrawBorder(Border.Left, g, this, b2, rect);
var b3 = RenderUtils.GetSolidBrush(ActualBorderRightColor);
BordersDrawHandler.DrawBorder(Border.Right, g, this, b3, rect);
var b4 = RenderUtils.GetSolidBrush(ActualBorderBottomColor);
BordersDrawHandler.DrawBorder(Border.Bottom, g, this, b4, rect);
}
}
示例7: Draw
public override void Draw(IGraphics graphics)
{
int drawX = (int)Math.Round(X);
int drawY = (int)Math.Round(Y);
graphics.SetColor(255, 255, 255, 255);
graphics.DrawObject(Image.Mushi, drawX, drawY, 32, 64, type, animation % 3 == 1 ? 1 : 0, angle);
}
示例8: ClipGraphicsByOverflow
/// <summary>
/// Clip the region the graphics will draw on by the overflow style of the containing block.<br/>
/// Recursively travel up the tree to find containing block that has overflow style set to hidden. if not
/// block found there will be no clipping and null will be returned.
/// </summary>
/// <param name="g">the graphics to clip</param>
/// <param name="box">the box that is rendered to get containing blocks</param>
/// <returns>the prev region if clipped, otherwise null</returns>
public static RectangleF ClipGraphicsByOverflow(IGraphics g, CssBox box)
{
var containingBlock = box.ContainingBlock;
while (true)
{
if (containingBlock.Overflow == CssConstants.Hidden)
{
var prevClip = g.GetClip();
var rect = box.ContainingBlock.ClientRectangle;
rect.X -= 2; // atodo: find better way to fix it
rect.Width += 2;
rect.Offset(box.HtmlContainer.ScrollOffset);
rect.Intersect(prevClip);
g.SetClip(rect);
return prevClip;
}
else
{
var cBlock = containingBlock.ContainingBlock;
if (cBlock == containingBlock)
return RectangleF.Empty;
containingBlock = cBlock;
}
}
}
示例9: OnRender
/// <summary>
/// Function to render the actual map decoration
/// </summary>
/// <param name="g"></param>
/// <param name="map"></param>
protected override void OnRender(IGraphics g, Map map)
{
// Render the rosetta
base.OnRender(g, map);
var clip = g.ClipBounds;
var oldTransform = g.Transform;
var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + Size.Width*0.5f, clip.Top + Size.Height*0.5f);
g.Transform = newTransform;
var width = Size.Width;
var height = Size.Height;
var pts = new[]
{
new PointF(0f, -0.35f*height),
new PointF(0.125f*width, 0.35f*height),
new PointF(0f, 0.275f*height),
new PointF(-0.125f*width, 0.35f*height),
new PointF(0f, -0.35f*height),
};
// need to outline the needle
if (NeedleOutlineWidth>0)
{
g.DrawPolygon(new Pen(OpacityColor(NeedleOutlineColor), NeedleOutlineWidth), pts);
}
// need to outline the needle
g.FillPolygon(new SolidBrush(OpacityColor(NeedleFillColor)), pts );
g.Transform = oldTransform;
}
示例10: IndexBuffer
public IndexBuffer(IGraphics graphics)
{
_graphics = graphics as Graphics;
_graphics.MakeCurrent();
GL.GenBuffers(1, out id);
}
示例11: DrawSmoothFilledCurve
public override void DrawSmoothFilledCurve(IGraphics g, GraphPane pane, CurveItem curve, float scaleFactor)
{
base.DrawSmoothFilledCurve(g, pane, curve, scaleFactor);
// Draw the curve at the bottom of the graph.
DrawCurve(g, pane, curve, scaleFactor, GetPointsForLowPointsArray(curve));
}
示例12: Draw
/// <summary>
/// Do all rendering associated with this <see cref="CurveItem"/> to the specified
/// <see cref="Graphics"/> device. This method is normally only
/// called by the Draw method of the parent <see cref="ZedGraph.CurveList"/>
/// collection object.
/// </summary>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="pos">The ordinal position of the current <see cref="Bar"/>
/// curve.</param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
public override void Draw(IGraphics g, GraphPane pane, int pos, float scaleFactor)
{
if (IsXAxisMarker)
DrawXMarker(pane, g);
else
DrawYMarker(pane, g);
}
示例13: Run
/// <summary>
/// Run game logic here such as updating the world,
/// checking for collisions, handling input and drawing the game.
/// This method will be called as frequently as possible,
/// when the Windows message queue is empty.
/// Check GameTime to get the elapsed time since the last update.
/// </summary>
/// <param name="gameTime">Game time</param>
/// <param name="renderer">A Renderer</param>
/// <param name="keyboardState">A keyboard state</param>
public void Run(GameTime gameTime, IGraphics renderer, IControllerState keyboardState)
{
if (this.levelStat == LevelChangeStatus.NoChange)
{
if (Collisions.GetPlayerTile(this.level.Player) == TileType.Next)
{
this.level.LevelIndex++;
this.levelStat = LevelChangeStatus.Change;
}
else if (Collisions.GetPlayerTile(this.level.Player) == TileType.Back)
{
this.level.LevelIndex--;
this.levelStat = LevelChangeStatus.Change;
}
else
{
this.level.Update(gameTime, keyboardState);
this.level.Draw(gameTime, renderer);
}
}
else
{
this.level.UpdateLevel();
this.levelStat = LevelChangeStatus.NoChange;
}
}
示例14: Draw
public override void Draw(IGraphics graphics)
{
int drawX = (int)Math.Round(X);
int drawY = (int)Math.Round(Y);
graphics.SetColor(255, type == 0 ? 255 : 0, type == 1 ? 255 : 0, type == 2 ? 255 : 0);
graphics.DrawObject(Image.Teki, drawX, drawY, 32, 32, 0, 0, angle);
}
示例15: OnRenderInternal
protected override void OnRenderInternal(Map map, IPolygon polygon, IGraphics g)
{
IPoint pt = polygon.Centroid;
Point renderingOrigin = Point.Truncate(Transform.WorldtoMap(pt.Coordinate, map));
g.RenderingOrigin = new PointStruct(renderingOrigin.X, renderingOrigin.Y);
base.OnRenderInternal(map, polygon, g);
}