How to resolve the algorithm Greyscale bars/Display step by step in the AutoHotkey programming language
How to resolve the algorithm Greyscale bars/Display step by step in the AutoHotkey programming language
Table of Contents
Problem Statement
The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display. For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right hand side of the display. (This gives a total of 8 bars) For the second quarter down, we start with white and step down through 14 shades of gray, getting darker until we have black on the right hand side of the display. (This gives a total of 16 bars). Halfway down the display, we start with black, and produce 32 bars, ending in white, and for the last quarter, we start with white and step through 62 shades of grey, before finally arriving at black in the bottom right hand corner, producing a total of 64 bars for the bottom quarter.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Greyscale bars/Display step by step in the AutoHotkey programming language
Source code in the autohotkey programming language
h := A_ScreenHeight
w := A_ScreenWidth
pToken := gdip_Startup()
hdc := CreateCompatibleDC()
hbm := CreateDIBSection(w, h)
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
OnExit, Exit
Gui +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
hwnd := WinExist()
Gui Show, NA
columnHeight := h/4
Loop 4
{
columnY := (A_Index-1) * columnHeight
columnCount := 2**(A_Index+2)
colorgap := 255 / (columnCount-1)
columnWidth := w/ColumnCount
If (A_Index & 1)
colorComp := 0
else
colorComp := 255
,colorgap *= -1
MsgBox % colorGap * columnCount
Loop % columnCount
{
columnX := (A_Index-1) * columnWidth
pBrush := Gdip_BrushCreateSolid(QColor(colorComp, colorComp, colorComp))
Gdip_FillRectangle(G, pBrush, columnX, columnY, columnWidth, columnHeight)
Gdip_DeleteBrush(pBrush)
colorComp += colorgap
}
SetFormat, IntegerFast, hex
SetFormat, IntegerFast, D
}
UpdateLayeredWindow(hwnd, hdc, 0, 0, W, H)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Return
Esc::
Exit:
Gdip_Shutdown(pToken)
ExitApp
QColor(r, g, b){
return 0xFF000000 | (r << 16) | (g << 8) | (b)
}
You may also check:How to resolve the algorithm Runge-Kutta method step by step in the ERRE programming language
You may also check:How to resolve the algorithm Apply a callback to an array step by step in the Octave programming language
You may also check:How to resolve the algorithm Continued fraction/Arithmetic/G(matrix ng, continued fraction n) step by step in the C++ programming language
You may also check:How to resolve the algorithm Averages/Median step by step in the Zoea Visual programming language
You may also check:How to resolve the algorithm Anti-primes step by step in the Swift programming language