Created
February 19, 2015 15:37
-
-
Save klmr/864a87d25c048736a11f to your computer and use it in GitHub Desktop.
GDI golf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stdafx.h isn’t needed. | |
// However, we DO need the line break after the include, | |
// even in the golf version. | |
#include <windows.h> | |
// _tmain => main; VC++ accepts both. | |
int main() | |
{ | |
HDC h = GetDC(0); | |
// Remove i++ here … | |
for (int i = 0; i < 50;){ | |
// 65793 == 0x010101; multiplying with 1…50 generates | |
// grey tones and is much shorter than RGB macro use | |
SelectObject(h, CreatePen(0, 9, i*65793)); | |
// i * 9 + 9 == i * 10 | |
// … add i++ here. | |
Rectangle(h, i * 9, i * 9, i * 10, i++ * 10); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
int main(){HDC h=GetDC(0);for(int i=0;i<50;){SelectObject(h,CreatePen(0,9,i*65793));Rectangle(h,i*9,i*9,i*10,i++*10);}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment