1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#define WIN32_LEAN_AND_MEAN
#include<windows.h>
#include <Uxtheme.h> // blue frame only
#include <stdio.h>
#include <iostream>
union colour
{
unsigned int c; // occupies 4 bytes
struct
{
unsigned char r;
unsigned char g; // each occupies 1 byte
unsigned char b;
unsigned char a;
};
};
void Locate( int column, int line,int d )
{
COORD coord;
coord.Y = column;
coord.X = line;
SetConsoleCursorPosition(
GetStdHandle( STD_OUTPUT_HANDLE ),
coord
);
}
int main()
{
HWND p = GetConsoleWindow();
POINT pt;
colour clr;
int r=50;
SetWindowPos(p, HWND_TOPMOST, 100, 100, 200, 280, SWP_SHOWWINDOW); // size the window here
SetWindowTheme(p,L" ",L" ");
system("title [MOVE]");
ShowScrollBar(p, SB_BOTH, FALSE);
HDC h=GetDC(0), wh=GetDC(p);
SelectObject(wh,GetStockObject(DC_BRUSH));
SelectObject(wh,GetStockObject(DC_PEN));
while (p!=0)
{
GetCursorPos(&pt);
clr.c=GetPixel(h,pt.x,pt.y);
ShowScrollBar(p, SB_BOTH, FALSE);
SetDCBrushColor(wh,clr.c);
SetDCPenColor(wh,clr.c);
Ellipse(wh,(95-r),(70-r),(95+r),(70+r));
printf("\e[?25l"); // hide the cursor
Locate(10,3,0);
printf("Red %s"," ");
Locate(10,3,0);
printf("Red %d",clr.r);
Locate(11,3,0);
printf("Green %s"," ");
Locate(11,3,0);
printf("Green %d",clr.g);
Locate(12,3,0);
printf("Blue %s"," ");
Locate(12,3,0);
printf("Blue %d",clr.b);
Locate(13,3,0);
printf("HEX %s"," ");
Locate(13,9,0);
std::cout<<std::hex<<clr.c;
Locate(14,3,0);
printf("RAW %s"," ");
Locate(14,3,0);
printf("RAW %d",clr.c);
Locate(15,3,0);
printf("X,Y %s"," ");
Locate(15,3,0);
printf("X,Y %d ,%s %d",pt.x,"",pt.y);
Sleep(20);
}
//Wend
}
| |