All pastes #291032 Raw Edit

Mine

public text v1 · immutable
#291032 ·published 2006-12-24 17:56 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Text;
using System.Windows.Forms;

namespace Example
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Creates the Point[] list for polygon creation.
        /// </summary>
        /// <returns></returns>
        private Point[] IconPathPoint()
        {
            //all coords are for 32x32 dim playfield.
            int mtr = 10;
            Point[] pathPoint = {
            new Point(17 * mtr, 15 * mtr), new Point(20 * mtr, 12 * mtr),
            new Point(21 * mtr, 12 * mtr), new Point(24 * mtr, 15 * mtr),
            new Point(24 * mtr, 18 * mtr), new Point(21 * mtr, 21 * mtr),
            new Point(20 * mtr, 21 * mtr), new Point(13 * mtr, 14 * mtr),
            new Point(12 * mtr, 14 * mtr), new Point(10 * mtr, 16 * mtr),
            new Point(10 * mtr, 17 * mtr), new Point(12 * mtr, 19 * mtr),
            new Point(13 * mtr, 19 * mtr), new Point(15 * mtr, 17 * mtr),
            new Point(16 * mtr, 18 * mtr), new Point(13 * mtr, 21 * mtr),
            new Point(12 * mtr, 21 * mtr), new Point(9 * mtr, 18 * mtr),
            new Point(9 * mtr, 15 * mtr), new Point(12 * mtr, 12 * mtr),
            new Point(13 * mtr, 12 * mtr), new Point(20 * mtr, 19 * mtr),
            new Point(21 * mtr, 19 * mtr), new Point(23 * mtr, 17 * mtr),
            new Point(23 * mtr, 16 * mtr), new Point(21 * mtr, 14 * mtr),
            new Point(20 * mtr, 14 * mtr), new Point(18 * mtr, 16 * mtr),
            new Point(17 * mtr, 15 * mtr),
            };
            return pathPoint;
        }

        /// <summary>
        /// Creates the Path types array.
        /// </summary>
        /// <returns></returns>
        private Byte[] IconPathType()
        {
            byte[] pathType = {
                (byte)PathPointType.Start,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
            };
            return pathType;
        }

        /// <summary>
        /// Creates the Color list for the PatGradientBrush.
        /// </summary>
        /// <returns></returns>
        private Color[] IconColorList()
        {
            Color[] colorList = new Color[7];
            colorList[0] = Color.Red;
            colorList[1] = Color.Blue;
            colorList[2] = Color.Green;
            colorList[3] = Color.Yellow;
            colorList[4] = Color.Green;
            colorList[5] = Color.Blue;
            colorList[6] = Color.Red;
            return colorList;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int xyDim = 250;
            Image iconImage = new Bitmap(xyDim, xyDim);
            Graphics iconGraphics = Graphics.FromImage(iconImage);
            GraphicsPath iconPathGraphics = new GraphicsPath(IconPathPoint(), IconPathType());
            PathGradientBrush iconBrush = new PathGradientBrush(iconPathGraphics);
            iconBrush.WrapMode = WrapMode.Clamp;
            iconBrush.SurroundColors = IconColorList();
            iconGraphics.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, xyDim, xyDim);
            iconGraphics.FillPath(iconBrush, iconPathGraphics);
            pictureBox1.Image = iconImage;
        }
    }
}