Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
- namespace ColorShadesAndTints
- {
- public partial class Form1 : Form
- {
- List<Color> colorList = new List<Color>();
- Color myColor;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- int l = 1;
- int t = 40;
- Graphics g = e.Graphics;
- foreach (Color c in colorList) {
- using (SolidBrush b = new SolidBrush(c)) {
- g.FillRectangle(b, l, t, 30, 30);
- l = l + 30;
- if (l > 600)
- {
- l = 1;
- t = t + 30;
- }
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- ColorDialog c = new ColorDialog();
- if (c.ShowDialog() == DialogResult.OK)
- {
- myColor = c.Color;
- getShadesAndTints(myColor);
- Invalidate();
- }
- }
- private void getShadesAndTints(Color c)
- {
- int i; Double m;
- int r; int g; int b;
- for (i = 1; i < 21; i++)
- {
- m = i * 0.1;
- r = (int)(c.R * m); if (r > 255) r = 255;
- g = (int)(c.G * m); if (g > 255) g = 255;
- b = (int)(c.B * m); if (b > 255) b = 255;
- colorList.Add(Color.FromArgb(r, g, b));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement