Skip to content

Instantly share code, notes, and snippets.

@wieslawsoltes
Created June 3, 2015 08:58
Show Gist options
  • Save wieslawsoltes/5815d4ae0bdcae9b0583 to your computer and use it in GitHub Desktop.
Save wieslawsoltes/5815d4ae0bdcae9b0583 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace TestWinForms
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
Paint += (s, e) =>
{
var g = e.Graphics;
g.Clear(Color.White);
var gp = new GraphicsPath();
gp.FillMode = FillMode.Winding;
gp.AddBezier(new PointF(10f, 6f), new PointF(10f, 4f), new PointF(8f, 2f), new PointF(6f, 2f));
gp.CloseFigure();
var m = new Matrix();
m.Scale(60f, 60f);
var gs = g.Save();
g.MultiplyTransform(m);
var brush = new SolidBrush(Color.Black);
var pen = new Pen(Color.Red, 0.1f);
g.FillPath(
brush,
gp);
g.DrawPath(
pen,
gp);
brush.Dispose();
pen.Dispose();
var brushY = new SolidBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x00));
var penB = new Pen(Color.FromArgb(0xFF, 0x00, 0x00, 0xFF), 0.1f);
g.DrawEllipse(penB, 10f, 6f, 0.5f, 0.5f);
g.FillEllipse(brushY, 10f, 6f, 0.5f, 0.5f);
g.DrawEllipse(penB, 6f, 2f, 0.5f, 0.5f);
g.FillEllipse(brushY, 6f, 2f, 0.5f, 0.5f);
g.Restore(gs);
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment