public GraphicsPathTest() { _thickPen = new Pen(Microsoft.Xna.Framework.Color.Green, 15); List<CCVector2> path1 = new List<CCVector2>() { new CCVector2(50, 50), new CCVector2(100, 50), new CCVector2(100, 100), new CCVector2(50, 100), }; _gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed); path1.Reverse(); for (int i = 0; i < path1.Count; i++) path1[i] = new CCVector2(path1[i].X + 100, path1[i].Y); _gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed); for (int i = 0; i < path1.Count; i++) path1[i] = new CCVector2(path1[i].X, path1[i].Y + 100); _gpath2r = new GraphicsPath(_thickPen, path1); path1.Reverse(); for (int i = 0; i < path1.Count; i++) path1[i] = new CCVector2(path1[i].X - 100, path1[i].Y); _gpath2f = new GraphicsPath(_thickPen, path1); }
private void InitializePaths() { var bounds = VisibleBoundsWorldspace; var center = bounds.Center; //var center = new CCVector2(200, 200); Pen lilypadPen = new Pen(CCColor4B.Green, 15) { Alignment = PenAlignment.Center }; _lilypadPath = BuildLillyPad(center, 150, 0); _lilypadStroke = _lilypadPath.Stroke(lilypadPen, PathType.Closed); Pen outerFlowerPen = new Pen(CCColor4B.White * 0.75f, 15) { Alignment = PenAlignment.Outset }; _outerFlowerStroke = BuildFlower(center, 8, 120, 100, (float)(Math.PI / 8)).Stroke(outerFlowerPen, PathType.Closed); Pen innerFlowerPen = new Pen(Microsoft.Xna.Framework.Color.MediumPurple * 0.5f, 10) { Alignment = PenAlignment.Outset }; _innerFlowerStroke = BuildFlower(center, 16, 105, 60, 0).Stroke(innerFlowerPen, PathType.Closed); }
public override void Setup (GraphicsDevice device) { _thickPen = new Pen(Color.Green, 15); List<Vector2> path1 = new List<Vector2>() { new Vector2(50, 50), new Vector2(100, 50), new Vector2(100, 100), new Vector2(50, 100), }; _gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed); path1.Reverse(); for (int i = 0; i < path1.Count; i++) path1[i] = new Vector2(path1[i].X + 100, path1[i].Y); _gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed); for (int i = 0; i < path1.Count; i++) path1[i] = new Vector2(path1[i].X, path1[i].Y + 100); _gpath2r = new GraphicsPath(_thickPen, path1); path1.Reverse(); for (int i = 0; i < path1.Count; i++) path1[i] = new Vector2(path1[i].X - 100, path1[i].Y); _gpath2f = new GraphicsPath(_thickPen, path1); }
protected override void DisposeManaged() { if (_data != null) { _data.FillInvalidated -= HandleFillInvalidated; _data.FillGlowInvalidated -= HandleFillGlowInvalidated; _data.OutlineInvalidated -= HandleOutlineInvalidated; _data.OutlineGlowInvalidated -= HandleOutlineGlowInvalidated; _data = null; } if (_fillBrush != null) { _fillBrush.Dispose(); _fillBrush = null; } if (_fillGlowBrush != null) { _fillGlowBrush.Dispose(); _fillGlowBrush = null; } if (_outlinePen != null) { _outlinePen.Dispose(); _outlinePen = null; } if (_outlineGlowPen != null) { _outlineGlowPen.Dispose(); _outlineGlowPen = null; } base.DisposeManaged(); }
public override void Setup (GraphicsDevice device) { _flatPen = new Pen(Color.Blue, 15) { StartCap = LineCap.Flat, EndCap = LineCap.Flat }; _squarePen = new Pen(Color.Red, 15) { StartCap = LineCap.Square, EndCap = LineCap.Square }; _trianglePen = new Pen(Color.Green, 15) { StartCap = LineCap.Triangle, EndCap = LineCap.Triangle }; _invTrianglePen = new Pen(Color.Purple, 15) { StartCap = LineCap.InvTriangle, EndCap = LineCap.InvTriangle }; _arrowPen = new Pen(Color.Orange, 15) { StartCap = LineCap.Arrow, EndCap = LineCap.Arrow }; }
public WaterLilly() { Pen penOuterFlower = new Pen(Microsoft.Xna.Framework.Color.White * 0.75f, 15) { Alignment = PenAlignment.Outset }; _lilyOuterFlower = CreateFlowerGP(penOuterFlower, _origin, 8, 120, 100, (float)(Math.PI / 8)); Pen penInnerFlower = new Pen(Microsoft.Xna.Framework.Color.MediumPurple * 0.5f, 10) { Alignment = PenAlignment.Outset }; _lilyInnerFlower = CreateFlowerGP(penInnerFlower, _origin, 16, 105, 60, 0); }
public override void Setup (GraphicsDevice device) { Pen penOuterFlower = new Pen(Color.White * 0.75f, 15) { Alignment = PenAlignment.Outset }; _lilyOuterFlower = CreateFlowerGP(penOuterFlower, _origin, 8, 120, 100, (float)(Math.PI / 8)); Pen penInnerFlower = new Pen(Color.MediumPurple * 0.5f, 10) { Alignment = PenAlignment.Outset }; _lilyInnerFlower = CreateFlowerGP(penInnerFlower, _origin, 16, 105, 60, 0); }
public LineCaps() { _flatPen = new Pen(Microsoft.Xna.Framework.Color.Blue, 15) { StartCap = LineCap.Flat, EndCap = LineCap.Flat }; _squarePen = new Pen(Microsoft.Xna.Framework.Color.Red, 15) { StartCap = LineCap.Square, EndCap = LineCap.Square }; _trianglePen = new Pen(Microsoft.Xna.Framework.Color.Green, 15) { StartCap = LineCap.Triangle, EndCap = LineCap.Triangle }; _invTrianglePen = new Pen(Microsoft.Xna.Framework.Color.Purple, 15) { StartCap = LineCap.InvTriangle, EndCap = LineCap.InvTriangle }; _arrowPen = new Pen(Microsoft.Xna.Framework.Color.Orange, 15) { StartCap = LineCap.Arrow, EndCap = LineCap.Arrow }; }
public override void Setup (GraphicsDevice device) { _gradWidth = new GradientPen(Color.Lime, Color.Blue, 15); _gradLength = new PathGradientPen(Color.Lime, Color.Blue, 15); PathBuilder pathBuilder = new PathBuilder() { CalculateLengths = true }; pathBuilder.AddPath(StarPoints(new Vector2(325, 75), 5, 50, 25, 0, false)); _widthStar = pathBuilder.Stroke(_gradWidth, PathType.Open); _lengthStar = pathBuilder.Stroke(_gradLength, Matrix.CreateTranslation(0, 125, 0), PathType.Open); }
public void Initialize (Rectangle bounds, float mag) { ColorPen = new Pen(new Color(rand.Next(255), rand.Next(255), rand.Next(255))); for (int i = 0; i < Points.Length; i++) { Points[i] = new Vector2(bounds.Left + (float)rand.NextDouble() * bounds.Width, bounds.Top + (float)rand.NextDouble() * bounds.Height); Velocities[i] = new Vector2((float)(rand.NextDouble() - .5) * mag, (float)(rand.NextDouble() - .5) * mag); for (int j = 0; j < History.Count; j++) History[j][i] = Points[i]; } }
public void Initialize(CCRect bounds, float mag) { ColorPen = new Pen(new Microsoft.Xna.Framework.Color(rand.Next(255), rand.Next(255), rand.Next(255))); for (int i = 0; i < Points.Length; i++) { Points[i] = new CCVector2(bounds.MinX + (float)rand.NextDouble() * bounds.Size.Width, bounds.MaxY + (float)rand.NextDouble() * bounds.Size.Height); Velocities[i] = new CCVector2((float)(rand.NextDouble() - .5) * mag, (float)(rand.NextDouble() - .5) * mag); for (int j = 0; j < History.Count; j++) History[j][i] = Points[i]; } }
private GraphicsPath CreateFlowerGP (Pen pen, Vector2 center, int petalCount, float petalLength, float petalWidth, float rotation) { List<Vector2> points = StarPoints(center, petalCount / 2, petalLength, petalLength, rotation, false); PathBuilder builder = new PathBuilder(); builder.AddPoint(center); foreach (Vector2 point in points) { builder.AddArcByPoint(point, petalWidth / 2); builder.AddArcByPoint(center, petalWidth / 2); } return builder.Stroke(pen, PathType.Closed); }
public GradientPens() { _gradWidth = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Blue, 15); _gradLength = new PathGradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Blue, 15); PathBuilder pathBuilder = new PathBuilder() { CalculateLengths = true }; pathBuilder.AddPath(StarPoints(new CCVector2(325, 75), 5, 50, 25, 0, false)); _widthStar = pathBuilder.Stroke(_gradWidth, PathType.Open); _lengthStar = pathBuilder.Stroke(_gradLength, CCAffineTransform.Translate(CCAffineTransform.Identity, 0, 125, 0), PathType.Open); }
public override void OnEnter() { var penWidth = 6.0f; Pen pen = new Pen(new Microsoft.Xna.Framework.Color(Microsoft.Xna.Framework.Color.Blue, 92), penWidth); var bounds = VisibleBoundsWorldspace; var size = bounds.Size; var width = size.Width - penWidth; var height = size.Height - penWidth; //_cache = new Grid(12, 10).Compile(pen, 3, 3, 30 * 12, 30 * 10); _cache = new Grid(12, 10).Compile(pen, penWidth/2, penWidth/2, width, height); base.OnEnter(); }
public override void Setup (GraphicsDevice device) { _gradWidthInner = new GradientPen(Color.Lime, Color.Cyan, 15) { Alignment = PenAlignment.Inset, StartCap = LineCap.Square, EndCap = LineCap.Square }; _gradWidthCenter = new GradientPen(Color.Lime, Color.Cyan, 15) { StartCap = LineCap.Square, EndCap = LineCap.Square }; _gradWidthOuter = new GradientPen(Color.Lime, Color.Cyan, 15) { Alignment = PenAlignment.Outset, StartCap = LineCap.Square, EndCap = LineCap.Square }; Pen[] pens = new Pen[] { _gradWidthInner, _gradWidthCenter, _gradWidthOuter }; for (int i = 0; i < _gPaths.Length; i++) { PathBuilder builder = new PathBuilder(); foreach (Vector2 v in _baseCoords) builder.AddPoint(v + Offset(i)); _gPaths[i] = builder.Stroke(pens[i]); } }
public GradientPensAlignment() { _gradWidthInner = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Cyan, 15) { Alignment = PenAlignment.Inset, StartCap = LineCap.Square, EndCap = LineCap.Square }; _gradWidthCenter = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Cyan, 15) { StartCap = LineCap.Square, EndCap = LineCap.Square }; _gradWidthOuter = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Cyan, 15) { Alignment = PenAlignment.Outset, StartCap = LineCap.Square, EndCap = LineCap.Square }; Pen[] pens = new Pen[] { _gradWidthInner, _gradWidthCenter, _gradWidthOuter }; for (int i = 0; i < _gPaths.Length; i++) { PathBuilder builder = new PathBuilder(); foreach (CCVector2 v in _baseCoords) builder.AddPoint(v + Offset(i)); _gPaths[i] = builder.Stroke(pens[i]); } }
public override void Setup (GraphicsDevice device) { _bluePen = new Pen(Color.Blue, 15); _pointPen = new Pen(Color.Gray, 4); _wavePoints = new Vector2[] { new Vector2(50, 350), new Vector2(50, 400), new Vector2(150, 400), new Vector2(150, 350), new Vector2(150, 300), new Vector2(250, 300), new Vector2(250, 350), new Vector2(250, 400), new Vector2(350, 400), new Vector2(350, 350), new Vector2(350, 300), new Vector2(450, 300), new Vector2(450, 350), }; _loopPoints = new Vector2[] { new Vector2(225, 75), new Vector2(250, 50), new Vector2(275, 50), new Vector2(300, 75), new Vector2(325, 100), new Vector2(325, 125), new Vector2(300, 150), new Vector2(275, 175), new Vector2(250, 175), new Vector2(225, 150), new Vector2(200, 125), new Vector2(200, 100), }; }
public CubicBezier() { _bluePen = new Pen(Microsoft.Xna.Framework.Color.Blue, 15); _pointPen = new Pen(Microsoft.Xna.Framework.Color.Gray, 4); _wavePoints = new CCVector2[] { new CCVector2(50, 350), new CCVector2(50, 400), new CCVector2(150, 400), new CCVector2(150, 350), new CCVector2(150, 300), new CCVector2(250, 300), new CCVector2(250, 350), new CCVector2(250, 400), new CCVector2(350, 400), new CCVector2(350, 350), new CCVector2(350, 300), new CCVector2(450, 300), new CCVector2(450, 350), }; _loopPoints = new CCVector2[] { new CCVector2(225, 75), new CCVector2(250, 50), new CCVector2(275, 50), new CCVector2(300, 75), new CCVector2(325, 100), new CCVector2(325, 125), new CCVector2(300, 150), new CCVector2(275, 175), new CCVector2(250, 175), new CCVector2(225, 150), new CCVector2(200, 125), new CCVector2(200, 100), }; }
public override void Setup (GraphicsDevice device) { _starPoints1 = StarPoints(new Vector2(125, 150), 5, 100, 50, 0, false); _starPoints2 = StarPoints(new Vector2(350, 275), 5, 100, 50, 0, false); _starPoints3 = StarPoints(new Vector2(125, 400), 5, 100, 50, 0, false); _insetPen = new Pen(Color.MediumTurquoise, 10) { Alignment = PenAlignment.Inset }; _centerPen = new Pen(Color.MediumTurquoise, 10) { Alignment = PenAlignment.Center }; _outsetPen = new Pen(Color.MediumTurquoise, 10) { Alignment = PenAlignment.Outset }; _insetPath = new GraphicsPath(_insetPen, _starPoints1, PathType.Closed); _centerPath = new GraphicsPath(_centerPen, _starPoints2, PathType.Closed); _outsetPath = new GraphicsPath(_outsetPen, _starPoints3, PathType.Closed); }
public QuadraticBezier() { _bluePen = new Pen(Microsoft.Xna.Framework.Color.Blue, 15); _pointPen = new Pen(Microsoft.Xna.Framework.Color.Gray, 4); _wavePoints1 = new CCVector2[] { new CCVector2(150, 100), new CCVector2(200, 150), new CCVector2(250, 100), new CCVector2(300, 50), new CCVector2(350, 100), new CCVector2(400, 150), new CCVector2(450, 100), new CCVector2(500, 50), new CCVector2(550, 100), }; _wavePoints2 = new CCVector2[] { new CCVector2(150, 200), new CCVector2(200, 300), new CCVector2(250, 200), new CCVector2(300, 100), new CCVector2(350, 200), new CCVector2(400, 300), new CCVector2(450, 200), new CCVector2(500, 100), new CCVector2(550, 200), }; _loopPoints = new CCVector2[] { new CCVector2(250, 300), new CCVector2(350, 300), new CCVector2(350, 400), new CCVector2(350, 500), new CCVector2(250, 500), new CCVector2(150, 500), new CCVector2(150, 400), new CCVector2(150, 300), }; }
protected override void RenderContent(SpriteBatch spriteBatch) { if (_pattern == null) _pattern = BuildCanvasPattern(spriteBatch.GraphicsDevice); if (_borderPen == null) _borderPen = new Pen(new SolidColorBrush(Model.BorderColor.ToXnaColor())); if (_guidePen == null) _guidePen = new Pen(new SolidColorBrush(Model.OriginGuideColor.ToXnaColor())); ILevelGeometry geometry = LevelGeometry; Rectangle bounds = geometry.VisibleBounds.ToXnaRectangle(); Rectangle dest = new Rectangle( (int)Math.Ceiling(bounds.X * geometry.ZoomFactor), (int)Math.Ceiling(bounds.Y * geometry.ZoomFactor), (int)(bounds.Width * geometry.ZoomFactor), (int)(bounds.Height * geometry.ZoomFactor) ); spriteBatch.Draw(_pattern, dest, dest, Color.White); }
public override void Setup (GraphicsDevice device) { for (int i = 0; i < 20; i++) { if (i % 2 == 0) _wavy.Add(new Vector2(50 + i * 10, 100)); else _wavy.Add(new Vector2(50 + i * 10, 110)); } _thickBlue = new Pen(Color.Blue, 15); _thickRed = new Pen(Color.Red, 15) { EndCap = LineCap.Square, StartCap = LineCap.Square, }; _thickMagenta = new Pen(Color.Magenta, 15); _thickBlack = new Pen(Color.Black, 15); _thickDarkGray = new Pen(Color.DarkGray, 15); _thickGreen = new Pen(Color.Green, 15); _wavyPath = new GraphicsPath(_thickRed, _wavy); }
private void InitializePaths () { Vector2 center = new Vector2(200, 200); Pen lilypadPen = new Pen(Color.Green, 15) { Alignment = PenAlignment.Center }; _lilypadPath = BuildLillyPad(center, 150, 0); _lilypadStroke = _lilypadPath.Stroke(lilypadPen, PathType.Closed); Pen outerFlowerPen = new Pen(Color.White * 0.75f, 15) { Alignment = PenAlignment.Outset }; _outerFlowerStroke = BuildFlower(center, 8, 120, 100, (float)(Math.PI / 8)).Stroke(outerFlowerPen, PathType.Closed); Pen innerFlowerPen = new Pen(Color.MediumPurple * 0.5f, 10) { Alignment = PenAlignment.Outset }; _innerFlowerStroke = BuildFlower(center, 16, 105, 60, 0).Stroke(innerFlowerPen, PathType.Closed); }
public OutlineShapes() { for (int i = 0; i < 20; i++) { if (i % 2 == 0) _wavy.Add(new CCVector2(50 + i * 10, 100)); else _wavy.Add(new CCVector2(50 + i * 10, 110)); } _thickBlue = new Pen(Microsoft.Xna.Framework.Color.Blue, 15); _thickRed = new Pen(Microsoft.Xna.Framework.Color.Red, 15) { EndCap = LineCap.Square, StartCap = LineCap.Square, }; _thickMagenta = new Pen(Microsoft.Xna.Framework.Color.Magenta, 15); _thickBlack = new Pen(Microsoft.Xna.Framework.Color.Black, 15); _thickDarkGray = new Pen(Microsoft.Xna.Framework.Color.DarkGray, 15); _thickGreen = new Pen(Microsoft.Xna.Framework.Color.Green, 15); _wavyPath = new GraphicsPath(_thickRed, _wavy); }
public PenAlignmentTest() { _starPoints1 = StarPoints(new CCVector2(125, 150), 5, 100, 50, 0, false); _starPoints2 = StarPoints(new CCVector2(350, 275), 5, 100, 50, 0, false); _starPoints3 = StarPoints(new CCVector2(125, 400), 5, 100, 50, 0, false); _insetPen = new Pen(Microsoft.Xna.Framework.Color.MediumTurquoise, 10) { Alignment = PenAlignment.Inset }; _centerPen = new Pen(Microsoft.Xna.Framework.Color.MediumTurquoise, 10) { Alignment = PenAlignment.Center }; _outsetPen = new Pen(Microsoft.Xna.Framework.Color.MediumTurquoise, 10) { Alignment = PenAlignment.Outset }; _insetPath = new GraphicsPath(_insetPen, _starPoints1, PathType.Closed); _centerPath = new GraphicsPath(_centerPen, _starPoints2, PathType.Closed); _outsetPath = new GraphicsPath(_outsetPen, _starPoints3, PathType.Closed); }
public Arcs2 () { _thickPen = new Pen(Microsoft.Xna.Framework.Color.Blue, 15); }
public override void Setup (GraphicsDevice device) { _thickPen = new Pen(Color.Blue, 15); }
static Pen () { Black = new Pen(Brush.Black); Blue = new Pen(Brush.Blue); Brown = new Pen(Brush.Brown); Cyan = new Pen(Brush.Cyan); DarkBlue = new Pen(Brush.DarkBlue); DarkCyan = new Pen(Brush.DarkCyan); DarkGoldenrod = new Pen(Brush.DarkGoldenrod); DarkGray = new Pen(Brush.DarkGray); DarkGreen = new Pen(Brush.DarkGreen); DarkMagenta = new Pen(Brush.DarkMagenta); DarkOrange = new Pen(Brush.DarkOrange); DarkRed = new Pen(Brush.DarkRed); Goldenrod = new Pen(Brush.Goldenrod); Gray = new Pen(Brush.Gray); Green = new Pen(Brush.Green); LightBlue = new Pen(Brush.LightBlue); LightCyan = new Pen(Brush.LightCyan); LightGray = new Pen(Brush.LightGray); LightGreen = new Pen(Brush.LightGreen); LightPink = new Pen(Brush.LightPink); LightYellow = new Pen(Brush.LightYellow); Lime = new Pen(Brush.Lime); Magenta = new Pen(Brush.Magenta); Orange = new Pen(Brush.Orange); Pink = new Pen(Brush.Pink); Purple = new Pen(Brush.Purple); Red = new Pen(Brush.Red); Teal = new Pen(Brush.Teal); White = new Pen(Brush.White); Yellow = new Pen(Brush.Yellow); }
protected virtual void InitializeResources(GraphicsDevice device) { if (_fillBrush == null && _data.Fill != null) _fillBrush = BrushFactory.Create(device, _data.Fill); if (_fillGlowBrush == null && _data.FillGlow != null) _fillGlowBrush = BrushFactory.Create(device, _data.FillGlow); if (_outlinePen == null && _data.Outline != null) _outlinePen = PenFactory.Create(device, _data.Outline); if (_outlineGlowPen == null && _data.OutlineGlow != null) _outlineGlowPen = PenFactory.Create(device, _data.OutlineGlow); }
private void HandleOutlineInvalidated(object sender, EventArgs e) { if (_outlinePen != null) { _outlinePen.Dispose(); _outlinePen = null; } }