I made that in C++, tho it looks simple, this might let you appreciate it a little more.
Code:
void CPaintView::ShowPens(CDC* pDC)
{
//declaring variables to store the RGB values
int Red = 100, Green = 100, Blue = 100;
UINT i, positionX = 20, positionY = 20, length = 400;
for (i=0; i<10; i++) {
// 1) Create a pen, varying the size (param 1) and the color (param 2)
if(i%3 == 1){
Red = 255;
Green = 0;
Blue = 0;
}
else if(i%3 == 2){
Red = 0;
Green = 255;
Blue = 0;
}
else{
Red = 0;
Green = 0;
Blue = 255;
}
CPen MyNewPen(PS_SOLID, 8, RGB(Red,Green,Blue));
// Instead of the above, try...
/*LOGBRUSH logBrush;
logBrush.lbStyle = BS_SOLID;
logBrush.lbColor = RGB(0+(i*30),0+(i*15),0+(i*5));
CPen MyNewPen (PS_DASHDOT|PS_GEOMETRIC|PS_ENDCAP_ROUND, i*2+1, &logBrush);*/
// 2) Use
pDC->SelectObject(&MyNewPen);
pDC->MoveTo(positionX + (i * 10),positionY);
pDC->LineTo(positionX + (length - (i * 10)),positionY);
pDC->LineTo(positionX + (length - (i * 10)),positionY + (length - (i * 20)));
pDC->LineTo(positionX + (i * 10), positionY + (length - (i * 20)));
pDC->LineTo(positionX + (i * 10),positionY);
positionY += 10;
} // 3) Destroy the pen created inside the loop
positionX = 128;
positionY = 120;
length = 26;
for (i = 0; i < 2; i++){
if(i == 1){
Red = 202;
Blue = 0;
Green = 0;
}
else{
Red = 0;
Blue = 0;
Green = 0;
}
CPen MyNewPen(PS_SOLID, length, RGB(Red,Green, Blue));
pDC->SelectObject(&MyNewPen);
for (int j = 0; j < 8; j++){
positionY = 128;
for (int k = 0; k < 4; k++){
positionY = 128 + (length * (2 * k));
if(j%2 && i == 1){
pDC -> MoveTo(positionX+(j*length), positionY);
}
else if (j%2 && i == 0){
positionY += length;
pDC -> MoveTo(positionX+(j*length), positionY);
}
else if (i == 0){
pDC -> MoveTo(positionX+(j*length), positionY);
}
else{
positionY += length;
pDC -> MoveTo(positionX+(j*length), positionY);
}
pDC -> LineTo(positionX+(j*length), positionY);
}
}
}
}