Guest User

Untitled

a guest
Jan 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10.  
  11. namespace VisualStudioLogo
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.  
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         protected override void OnPaint(PaintEventArgs e)
  22.         {
  23.             base.OnPaint(e);
  24.             GraphicsPath gp = new GraphicsPath();
  25.             gp.AddPolygon(new Point[]{
  26.             new Point(0,30),
  27.             new Point(30,0),
  28.             new Point(60,0),
  29.             new Point(73,15),
  30.             new Point(88,0),
  31.             new Point(115,0),
  32.             new Point(140,30),
  33.             new Point(140,53),
  34.             new Point(108,90),
  35.             new Point(82,90),
  36.             new Point(67,73),
  37.             new Point(50,90),
  38.             new Point(30,90),
  39.             new Point(0,60)
  40.             });
  41.             gp.AddPolygon(new Point[]{
  42.             new Point(30,30),
  43.             new Point(20,40),
  44.             new Point(32,55),
  45.             new Point(43,43)
  46.             });
  47.             gp.AddPolygon(new Point[]{
  48.             new Point(110,30),
  49.             new Point(125,45),
  50.             new Point(115,55),
  51.             new Point(100,40)
  52.             });
  53.             e.Graphics.DrawPath(Pens.Black, gp);
  54.             //maken van een region uit het path
  55.             Region rgn = new Region(gp);
  56.             LinearGradientBrush brush = new LinearGradientBrush(new Point(0,0),
  57.                                                                 new Point(100,100),
  58.                                                                 Color.Yellow,
  59.                                                                 Color.Yellow);
  60.             //vul de region op met een brush
  61.             e.Graphics.FillRegion(brush, rgn);
  62.             brush.Dispose();
  63.  
  64.             //Markern gebied voor rode kleur
  65.             GraphicsPath gpr = new GraphicsPath();
  66.             gpr.AddPolygon(new Point[]{
  67.                 new Point(88,0),
  68.                 new Point(115,0),
  69.                 new Point(115,25),
  70.                 new Point(50,90),
  71.                 new Point(30,90),
  72.                 new Point(30,55)
  73.             });
  74.             e.Graphics.DrawPath(Pens.Black, gpr);
  75.  
  76.             //Markern gebied voor blauwe kleur
  77.             GraphicsPath gpb = new GraphicsPath();
  78.             gpb.AddPolygon(new Point[]{
  79.                 new Point(30,54),
  80.                 new Point(30,90),
  81.                 new Point(0,60),
  82.                 new Point(20,40)  
  83.             });
  84.             gpb.AddPolygon(new Point[]{
  85.                 new Point(115,0),
  86.                 new Point(110,30),
  87.                 new Point(125,45),
  88.                 new Point(140,30)
  89.             });
  90.             e.Graphics.DrawPath(Pens.Black, gpb);
  91.  
  92.             //Markern gebied voor groene kleur
  93.             GraphicsPath gpg = new GraphicsPath();
  94.             gpg.AddPolygon(new Point[]{
  95.                 new Point(20,40),
  96.                 new Point(0,60),
  97.                 new Point(0,30),  
  98.                 new Point(30,0),
  99.                 new Point(30,30)
  100.             });
  101.             gpg.AddPolygon(new Point[]{
  102.                 new Point(140,30),
  103.                 new Point(140,53),
  104.                 new Point(108,90),
  105.             new Point(115,55),
  106.  
  107.             });
  108.             e.Graphics.DrawPath(Pens.Black, gpg);
  109.  
  110.  
  111.             //maken region en vullen rood
  112.             e.Graphics.DrawPath(Pens.Black, gpr);
  113.             LinearGradientBrush rbrush = new LinearGradientBrush(new Point(0, 0),
  114.                                                                  new Point(100, 100),
  115.                                                                  ControlPaint.LightLight(Color.Red),
  116.                                                                  Color.Red);
  117.             e.Graphics.FillRegion(rbrush, new Region(gpr));
  118.             rbrush.Dispose();
  119.  
  120.             //maken region en vullen blauw
  121.             e.Graphics.DrawPath(Pens.Black, gpb);
  122.             LinearGradientBrush bbrush = new LinearGradientBrush(new Point(0, 0),
  123.                                                                  new Point(100, 100),
  124.                                                                  ControlPaint.LightLight(Color.Blue),
  125.                                                                  Color.Blue);
  126.             e.Graphics.FillRegion(bbrush, new Region(gpb));
  127.             bbrush.Dispose();
  128.  
  129.             //maken region en vullen groen
  130.             e.Graphics.DrawPath(Pens.Black, gpg);
  131.             LinearGradientBrush gbrush = new LinearGradientBrush(new Point(0, 0),
  132.                                                                  new Point(100, 100),
  133.                                                                  ControlPaint.LightLight(Color.Green),
  134.                                                                  Color.Green);
  135.             e.Graphics.FillRegion(gbrush, new Region(gpg));
  136.             gbrush.Dispose();
  137.  
  138.             base.OnPaint(e);
  139.         }
  140.  
  141.        
  142.     }
  143. }
Add Comment
Please, Sign In to add comment