cscの作法 その53
2649 ワード
概要
cscの作法、調べてみた。
ネコのイラストやってみた。
参考にしたページ
写真
サンプルコード
using System;
using System.Windows.Forms;
using System.Drawing;
class form1: Form {
form1() {
this.Text = "neko";
ClientSize = new Size(700, 500);
}
protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
g.DrawEllipse(new Pen(GetFaceBorderColor(), 5), GetFacePosition());
g.DrawPolygon(new Pen(GetFaceBorderColor(), 5), GetLeftEarPosition());
g.DrawPolygon(new Pen(GetFaceBorderColor(), 5), GetRightEarPosition());
g.FillEllipse(new SolidBrush(GetFaceColor()), GetFacePosition());
g.FillPolygon(new SolidBrush(GetFaceColor()), GetLeftEarPosition());
g.FillPolygon(new SolidBrush(GetFaceColor()), GetRightEarPosition());
g.FillEllipse(Brushes.Black, 190, 200, 15, 50);
g.FillEllipse(Brushes.Black, 295, 200, 15, 50);
g.DrawArc(new Pen(Color.Black, 5), new Rectangle(190, 270, 60, 60), 0, 180);
g.DrawArc(new Pen(Color.Black, 5), new Rectangle(250, 270, 60, 60), 0, 180);
g.DrawLine(new Pen(Color.Black, 5), new Point(5, 210), new Point(120, 225));
g.DrawLine(new Pen(Color.Black, 5), new Point(0, 250), new Point(120, 250));
g.DrawLine(new Pen(Color.Black, 5), new Point(5, 290), new Point(120, 275));
g.DrawLine(new Pen(Color.Black, 5), new Point(380, 225), new Point(495, 210));
g.DrawLine(new Pen(Color.Black, 5), new Point(380, 250), new Point(500, 250));
g.DrawLine(new Pen(Color.Black, 5), new Point(380, 275), new Point(495, 290));
base.OnPaint(e);
}
private Color GetFaceColor() {
return Color.FromArgb(255, 221, 209, 174);
}
private Color GetFaceBorderColor() {
return Color.FromArgb(255, 182, 156, 78);
}
private Rectangle GetFacePosition() {
return new Rectangle(50, 100, 400, 280);
}
private Point[] GetLeftEarPosition() {
return new Point[] {
new Point(430, 30),
new Point(430, 210),
new Point(300, 110)
};
}
private Point[] GetRightEarPosition() {
return new Point[] {
new Point(70, 30),
new Point(70, 210),
new Point(200, 110)
};
}
[STAThread]
public static void Main() {
Application.Run(new form1());
}
}
using System;
using System.Windows.Forms;
using System.Drawing;
class form1: Form {
form1() {
this.Text = "neko";
ClientSize = new Size(700, 500);
}
protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
g.DrawEllipse(new Pen(GetFaceBorderColor(), 5), GetFacePosition());
g.DrawPolygon(new Pen(GetFaceBorderColor(), 5), GetLeftEarPosition());
g.DrawPolygon(new Pen(GetFaceBorderColor(), 5), GetRightEarPosition());
g.FillEllipse(new SolidBrush(GetFaceColor()), GetFacePosition());
g.FillPolygon(new SolidBrush(GetFaceColor()), GetLeftEarPosition());
g.FillPolygon(new SolidBrush(GetFaceColor()), GetRightEarPosition());
g.FillEllipse(Brushes.Black, 190, 200, 15, 50);
g.FillEllipse(Brushes.Black, 295, 200, 15, 50);
g.DrawArc(new Pen(Color.Black, 5), new Rectangle(190, 270, 60, 60), 0, 180);
g.DrawArc(new Pen(Color.Black, 5), new Rectangle(250, 270, 60, 60), 0, 180);
g.DrawLine(new Pen(Color.Black, 5), new Point(5, 210), new Point(120, 225));
g.DrawLine(new Pen(Color.Black, 5), new Point(0, 250), new Point(120, 250));
g.DrawLine(new Pen(Color.Black, 5), new Point(5, 290), new Point(120, 275));
g.DrawLine(new Pen(Color.Black, 5), new Point(380, 225), new Point(495, 210));
g.DrawLine(new Pen(Color.Black, 5), new Point(380, 250), new Point(500, 250));
g.DrawLine(new Pen(Color.Black, 5), new Point(380, 275), new Point(495, 290));
base.OnPaint(e);
}
private Color GetFaceColor() {
return Color.FromArgb(255, 221, 209, 174);
}
private Color GetFaceBorderColor() {
return Color.FromArgb(255, 182, 156, 78);
}
private Rectangle GetFacePosition() {
return new Rectangle(50, 100, 400, 280);
}
private Point[] GetLeftEarPosition() {
return new Point[] {
new Point(430, 30),
new Point(430, 210),
new Point(300, 110)
};
}
private Point[] GetRightEarPosition() {
return new Point[] {
new Point(70, 30),
new Point(70, 210),
new Point(200, 110)
};
}
[STAThread]
public static void Main() {
Application.Run(new form1());
}
}
以上。
Author And Source
この問題について(cscの作法 その53), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/d8db755be82ad683ebe0著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .