Search the Community
Showing results for tags 'kaleidoscope'.
-
A simple endless kaleidoscope made on a RichEdit control (hit esc to exit) Idea is from this link: http://www.calormen.com/jsbasic/ select the "Rod's Color Pattern" demo and run it on the Apple 2 emulator on that web page to see the original Apple II version. ; Idea from this link: http://www.calormen.com/jsbasic/ ; get the "Rod's Color Pattern" from the "Select a sample..." combo and run it ; #include <GuiRichEdit.au3> #include <GUIConstants.au3> HotKeySet("{ESC}", "_TheEnd") ; Global $iHwidth = 40, $iVheight = 40; width and height of screen Global $sBuffer = _StringReplay(_StringReplay(" ", $iHwidth + 1) & @CRLF, $iVheight) ;to fill the RichEdit Global $sChar = " " Global Const $aApplesoft_color[16] = [ _ ; LoRes colors in Applesoft basic 0x000000, _ ; 0x0 = 00 = Black 0XFF00FF, _ ; 0x1 = 01 = Magenta 0X0000A0, _ ; 0x2 = 02 = Dark Blue 0X800080, _ ; 0x3 = 03 = Purple 0X006400, _ ; 0x4 = 04 = Dark Green 0X808080, _ ; 0x5 = 05 = Grey 0X0000CD, _ ; 0x6 = 06 = Medium Blue 0XADD8E6, _ ; 0x7 = 07 = Light Blue 0XA52A2A, _ ; 0x8 = 08 = Brown 0XFFA500, _ ; 0x9 = 09 = Orange 0XD3D3D3, _ ; 0xA = 10 = Light Grey 0XFFC0CB, _ ; 0xB = 11 = Pink 0X008000, _ ; 0xC = 12 = Green 0XFFFF00, _ ; 0xD = 13 = Yellow 0X00FFFF, _ ; 0xE = 14 = Aqua 0xFFFFFF]; ; 0xF = 15 = White Global $MyGui = GUICreate("", 335, 630, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $WS_EX_COMPOSITED, $WS_EX_LAYERED)) $hGlass = GUICtrlCreateLabel("", 0, 0, 335, 630, -1, $GUI_WS_EX_PARENTDRAG) ; Protect the RichEdit and allows to drag the GUI around GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; This is like a glass over the underlying RichEdit GUICtrlSetCursor(-1, 2) ; Cursor is an arrow (instead of the default I-beam) ; ; This RichEdit is used to simulate the LoRes Graphic of tha Apple 2 (40x40 pixels) Global $hGR = _GUICtrlRichEdit_Create($MyGui, $sBuffer, 0, 0, 335, 630, BitOR($ES_READONLY, $ES_MULTILINE)) _GUICtrlRichEdit_SetSel($hGR, 0, -1) _GUICtrlRichEdit_SetFont($hGR, 10, "Courier new") _GUICtrlRichEdit_SetBkColor($hGR, 0xffffff) GUISetState() ; Main loop ; --------- While 1 For $W = 3 To 50 For $x = 19 To 1 Step -1 For $y = 19 To 0 Step -1 $xy = $x + $y $iColor = Mod(Int($y * 3 / ($x + 3) + $x * $W / 12), 16) $sChar = ChrW(32 + $iColor) ; comment this if you don't want chars (only color) If $iColor > 15 Then $iColor = 15 Print($sChar, $x, $xy, $iColor) Print($sChar, $xy, $x, $iColor) Print($sChar, 40 - $x, 40 - $xy, $iColor) Print($sChar, 40 - $xy, 40 - $x, $iColor) Print($sChar, $xy, 40 - $x, $iColor) Print($sChar, 40 - $x, $xy, $iColor) Print($sChar, $x, 40 - $xy, $iColor) Print($sChar, 40 - $xy, $x, $iColor) Next Next Next WEnd ; Print a char to Htab (Horiz. pos), Vtab (Vert pos) on the RichEdit ; ------------------------------------------------------------------ Func Print($sChar = "", $iHtab = 1, $iVtab = 1, $iColor = 0xffffff) _GUICtrlRichEdit_SetSel($hGR, GetAbsPos($iHtab, $iVtab), GetAbsPos($iHtab, $iVtab) + 1, True) _GUICtrlRichEdit_SetCharBkColor($hGR, $aApplesoft_color[$iColor]) _GUICtrlRichEdit_ReplaceText($hGR, $sChar, False) EndFunc ;==>Print ; From Htab Vtab (1 based) to Absolute position within the RichEdit ; ----------------------------------------------------------------- Func GetAbsPos($iHtab = 1, $iVtab = 1, $iScreenWidth = $iHwidth) Return ($iVtab - 1) * ($iScreenWidth + 2) + $iHtab EndFunc ;==>GetAbsPos ; returns one or more chars replicated n times ; Example: ConsoleWrite(_StringReplay('*', 5) & @CRLF) Func _StringReplay($sChars = "", $iRepeats = 0) $sChars = String($sChars) $iRepeats = Int(Abs(Number($iRepeats))) Return StringReplace(StringFormat('%' & $iRepeats & 's', ""), " ", $sChars) EndFunc ;==>_StringReplay Func _TheEnd() If WinActive("[ACTIVE]") = $MyGui Then _GUICtrlRichEdit_Destroy($hGR) Exit EndIf EndFunc ;==>_TheEnd
- 14 replies