What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Off Topic
Posts: 43
Joined: 07 Oct 2017, 20:57

What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

29 Dec 2017, 16:11

I'm looking for a way to generate semi-random hex values for a GUI:
Hex2.gif
Hex2.gif (834.01 KiB) Viewed 3214 times
You'll probably see that the colors above have an easy pattern to them. I've tried replicating this through looping Random and reading from a string, but I'm new to Random and strings in general, and though I do have it working I don't feel it's very good:
Hex1.gif
Hex1.gif (1.13 MiB) Viewed 3214 times
It will often stick to one key, repeat exact patterns or roll itself into FFFFFF even after NewSeed. I know I'm doing something wrong because it does this even when rolling a single color. What would be a better way to roll for colors than what I'm doing below?

Code: Select all

; Random Color
+F22::

	Char1 = ABCDEF
	VarNum  = 0

	Random, ArrSelect, 1, 3 ; Select arrangement/harmony rules

	; Example Arrangements
		; 1 - F0F0F0, 3C3C3C
		; 2 - AA00FF, DD33CC
		; 3 - 00FF00, 33CC33

		If (ArrSelect = 1){

			Loop, 2
			{
			++VarNum
			Random, IntChar, 0, 1  ; For character or integer
			Random, CharPos, 1, 6  ; Randomize start position for character string

				If (IntChar = 0) { ;  If 0, produce an integer
					Random, RandInt, 0, 9  
					U%VarNum% = %RandInt%

				} Else {           ;  If 1, produce a character
					; SubStr(CharHex, %CharPos%, 1) 
					StringMid, CharHex, Char1, %CharPos%, 1  
					U%VarNum% = %CharHex%
				}

			}

			RollRes = %U1%%U2%%U1%%U2%%U1%%U2%
			; GuiControl, , TextA, %RollRes%	
			; GuiControl, +Background%HexColor%, Rshifter
			MsgBox %U1%%U2%%U1%%U2%%U1%%U2%

		} Else If (ArrSelect = 2){

			Loop, 3
			{
			++VarNum
			Random, IntChar, 0, 1  ; For character or integer
			Random, CharPos, 1, 6  ; Randomize start position for character string

				If (IntChar = 0) { ;  If 0, produce an integer
					Random, RandInt, 0, 9  
					U%VarNum% = %RandInt%

				} Else {           ;  If 1, produce a character
					SubStr(CharHex, %CharPos%, 1)
					U%VarNum% = %CharHex%
				}

			}

			RollRes = %U1%%U1%%U2%%U2%%U3%%U3%
			; GuiControl, , TextA, %RollRes%	
			; GuiControl, +Background%RollRes%, Rshifter
			MsgBox = %U1%%U1%%U2%%U2%%U3%%U3%

		} Else If (ArrSelect = 3){

			Loop, 2
			{
			++VarNum
			Random, IntChar, 0, 1  ; For character or integer
			Random, CharPos, 1, 6  ; Randomize start position for character string

				If (IntChar = 0) { ;  If 0, produce an integer
					Random, RandInt, 0, 9  
					U%VarNum% = %RandInt%

				} Else {           ;  If 1, produce a character
					SubStr(CharHex, %CharPos%, 1) 
					U%VarNum% = %CharHex%
				}

			}
			
			RollRes = %U1%%U1%%U2%%U2%%U1%%U1%
		 	; GuiControl, , TextA, %RollRes%	
			; GuiControl, +Background%RollRes%, Rshifter
			MsgBox %U1%%U1%%U2%%U2%%U1%%U1%
		}
	
	Return
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

29 Dec 2017, 16:52

- These examples may help to simplify your code.

Code: Select all

q::
;any random colour
Loop, 5
{
	Random, vRand, 0, 0xFFFFFF
	MsgBox, % Format("{:06X}", vRand)
}

;any random colour (equivalent to the previous example)
Loop, 5
{
	Random, vRand1, 0, 255
	Random, vRand2, 0, 255
	Random, vRand3, 0, 255
	MsgBox, % Format("{:02X}{:02X}{:02X}", vRand1, vRand2, vRand3)
}

;each R/G/B value has one of 3 possible values
oArray := [0,128,255]
Loop, 5
{
	Random, vRand1, 1, 3
	Random, vRand2, 1, 3
	Random, vRand3, 1, 3
	MsgBox, % Format("{:02X}{:02X}{:02X}", oArray[vRand1], oArray[vRand2], oArray[vRand3])
}

;patterns of the form 'AABBCC' e.g. AA00FF
Loop, 5
{
	Random, vRand1, 0, 15
	Random, vRand2, 0, 15
	Random, vRand3, 0, 15
	MsgBox, % Format("{:02X}{:02X}{:02X}", vRand1*16+vRand1, vRand2*16+vRand2, vRand3*16+vRand3)
}

;patterns of the form 'ABABAB' e.g. 272727 (shades of grey)
Loop, 5
{
	Random, vRand, 0, 255
	MsgBox, % Format("{:02X}{1:02X}{1:02X}", vRand)
}
return
- Btw I love the moustache guy in your other posts and your avatar. Do you have a website with image/video examples? Cheers.
- [EDIT:] Added a third example.
- [EDIT:] Helgef said something about new seed here:
[Script] Roll The Dice - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 78#p191478
- [EDIT:] There are now 5 examples.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

30 Dec 2017, 11:19

If you want only "nice" colors it is easier to use hls color values.

Code: Select all

;DllCall( "shlwapi\ColorRGBToHLS", UInt,RGB, UIntP,h, UIntP,l, UIntP,s )

loop 100
{
Random,h,0,160
Random,l,80,120
Random,s,180,240

gui,color,% Format("{1:#x}", DllCall( "shlwapi\ColorHLSToRGB", UInt,h, UInt,l, UInt,s ))
Gui, show,w200 h200

sleep 300
}

esc::exitapp
User avatar
Off Topic
Posts: 43
Joined: 07 Oct 2017, 20:57

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

30 Dec 2017, 20:36

PenPalThanks.gif
PenPalThanks.gif (1.07 MiB) Viewed 3148 times
Pretty fantastic help from both of you and I don't see any point in not using everything. Not sure if I can accept more than one answer, wish I could've settled on a secondary neutral gesture (like upvote) sooner than the time it takes to reply. I wanted to try and digest this before responding, admittedly I'm still not sure what Format() is doing just yet.
jeeswg wrote: - Btw I love the moustache guy in your other posts and your avatar. Do you have a website with image/video examples? Cheers.
- [EDIT:] Added a third example.
- [EDIT:] Helgef said something about new seed here:
[Script] Roll The Dice - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 78#p191478
- [EDIT:] There are now 5 examples.
Thanks! That emoticon set was one of the first things I'd illustrated, and I trust you'll keep that a secret.

Image :: Send, {joke}

Unfortunately I'm just a hobbyist and don't have a website, but none of it would compare with what I'm doing with AHK right now anyway. I'm really enjoying AHK for drawing and do not mind shamelessly trading graphics for any help with code because I'm only two months into AHK and programming in general but it's amazing and proving to be really valuable. You've already been very helpful so feel free to knock if you're in need of something.

I'm still having trouble with one of them:

Code: Select all

q::
; 	;patterns of the form 'ABABAB' e.g. 272727 (shades of grey)
; 	Loop, 5
; 	{
		Random, vRand, 0, 255
		; MsgBox, % Format("{:02X}{1:02X}{1:02X}", vRand)

		c1 := Format("{:02X}{1:02X}", vRand)
		c2 := Format("{2:02X}{1:02X}", vRand)
		c3 := Format("{2:02X}{:02X}", vRand)
		c4 := Format("{1:02X}{:02X}", vRand)
		c5 := Format("{:02X}{:02X}", vRand)

		MsgBox %c1%`n%c2%`n%c3%`n%c4%`n%c5%
; 	}
Return
I don't really understand what's going on just yet. I've been able to stumble my way through the others:

Code: Select all

+F21::
Roll2:
	;patterns of the form 'AABBCC' e.g. AA00FF
	prevAct = "row"
	thisRow = "0"
	; Loop, 5
	; {
		Random, vRand1, 0, 15
		Random, vRand2, 0, 15
		Random, vRand3, 0, 15
		c1 := Format("{:02X}{:02X}{:02X}", vRand1*16+vRand1, vRand2*16+vRand2, vRand3*16+vRand3)
		c2 := Format("{:02X}{:02X}{:02X}", vRand2*16+vRand2, vRand1*16+vRand1, vRand3*16+vRand3)
		c3 := Format("{:02X}{:02X}{:02X}", vRand3*16+vRand3, vRand2*16+vRand2, vRand1*16+vRand1)
		c4 := Format("{:02X}{:02X}{:02X}", vRand3*16+vRand3, vRand1*16+vRand1, vRand2*16+vRand2)
		c5 := Format("{:02X}{:02X}{:02X}", vRand2*16+vRand2,,vRand3*16+vRand3, vRand1*16+vRand1)
		c6 := Format("{:02X}{:02X}{:02X}", vRand1*16+vRand1, vRand3*16+vRand3, vRand2*16+vRand2)
		; MsgBox %c1%`n%c2%`n%c3%`n%c4%`n%c5%`n%c6%
		;
		GuiControl, , BG, Under_rowC.png
		;
		Shift1 = %c1%
		Shift2 = %c2%
		Shift3 = %c3%
		Shift4 = %c4%
		Shift5 = %c5%
		Shift6 = %c6%
		;
		Gosub, GuiRoll2
		Return
The above will successfully give six variations, but in the ABABAB example, I can't produce BABABA yet. I only get ABABAB, ABABAB, ABAB[fluke], AB[fluke]AB, ABABAB, ABABAB, ABABAB, etc. and I can only ABABAB, never BABABA so far. Is this something I can get more help with? Also, read that post with Helgef and I've removed NewSeed, the new code works very well without it.
noname wrote:If you want only "nice" colors it is easier to use hls color values.

Code: Select all

;DllCall( "shlwapi\ColorRGBToHLS", UInt,RGB, UIntP,h, UIntP,l, UIntP,s )

loop 100
{
Random,h,0,160
Random,l,80,120
Random,s,180,240

gui,color,% Format("{1:#x}", DllCall( "shlwapi\ColorHLSToRGB", UInt,h, UInt,l, UInt,s ))
Gui, show,w200 h200

sleep 300
}

esc::exitapp
I put this into a Msgbox for testing to avoid conflicting with my gui:

Code: Select all

!F21::
NoName:
	RollNum = 0
	loop 9
		{
			++RollNum
		Random,h,0,160
		Random,l,80,120
		Random,s,180,240

		c%RollNum% := Format("{1:X}", DllCall( "shlwapi\ColorHLSToRGB", UInt,h, UInt,l, UInt,s ))
			; StringMid, HexValue, % Format("{1:#x}", DllCall( "shlwapi\ColorHLSToRGB", UInt,h, UInt,l, UInt,s )), 3, 6
			; MsgBox %HexValue%
		}

		; Update Gui for values
		GuiControl, , BG, Under_pick0.png
		;
		Shift1 = %c1%
		Shift2 = %c2%
		Shift3 = %c3%
		Shift4 = %c4%
		Shift5 = %c5%
		Shift6 = %c6%
		Shift7 = %c7%
		Shift8 = %c8%
		Shift9 = %c9%
		;
		Gosub, GuiRoll1B
Return
		
GuiRoll1B:
		GuiControl, +Background%Shift1%, 1shifter
		GuiControl, +Background%Shift2%, 2shifter
		GuiControl, +Background%Shift3%, 3shifter
		GuiControl, +Background%Shift4%, 4shifter
		GuiControl, +Background%Shift5%, 5shifter
		GuiControl, +Background%Shift6%, 6shifter
		GuiControl, +Background%Shift7%, 7shifter
		GuiControl, +Background%Shift8%, 8shifter
		GuiControl, +Background%Shift9%, 9shifter
		;
		GuiControl, +Background%Shift1%, Rshifter
		GuiControl, , TextA, %Shift1%
		GuiControl, +Background%Shift2%, Gshifter
		GuiControl, , TextB, %Shift2%
		GuiControl, +Background%Shift3%, Bshifter
		GuiControl, , TextC, %Shift3%
		;
		; GuiControl, , BG, Under_pick0.png
		Sleep, 300
		GuiControl, , BG, Under_rowC.png
Return
It works very well, thank you for it. Occasionally it'll trim what I think is the first 0, and though it works when sent to Illustrator for the color, I notice the digit missing in my gui's edit boxes (seen in the gif at the very top). That hardly qualifies as a problem but I'd be curious to know if it's because I'm doing something wrong here.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)  Topic is solved

30 Dec 2017, 21:21

To clarify how Format works:

Code: Select all

;number as hex, with minimum 6 digits
Format("{:06X}", vNum)

;each number as hex, with minimum 2 digits
Format("{:02X}{:02X}{:02X}", vNum1, vNum2, vNum3)

;the number repeated 3 times as hex, with minimum 2 digits each time
;the '1' means use the 1st value
;by default the nth item in curly brackets corresponds to the nth value
Format("{:02X}{1:02X}{1:02X}", vNum)

MsgBox, % Format("{:X} {:X} {:X}", 10, 11, 12) ;A B C
MsgBox, % Format("{1:X} {2:X} {3:X}", 10, 11, 12) ;A B C ;same as line above
MsgBox, % Format("{3:X} {2:X} {1:X}", 10, 11, 12) ;C B A

;further examples here:
;Simplified Format() Command - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=13&t=38525&p=176790#p176790
If you want to use 6 numbers at some point, e.g. to do ABCDEF, but also BADCFE:

Code: Select all

Random, vRand1, 0, 15
Random, vRand2, 0, 15
Random, vRand3, 0, 15
Random, vRand4, 0, 15
Random, vRand5, 0, 15
Random, vRand6, 0, 15

;use this to get ABCDEF BADCFE:
;Loop, 6
;	vRand%A_Index% := 9+A_Index

MsgBox, % Format("{:X}{:X}{:X}{:X}{:X}{:X}", vRand1, vRand2, vRand3, vRand4, vRand5, vRand6)
MsgBox, % Format("{2:X}{1:X}{4:X}{3:X}{6:X}{5:X}", vRand1, vRand2, vRand3, vRand4, vRand5, vRand6)
- Yeah, we get a bit of a delay in responses on the forum, but sometimes that's good because it means people are thinking through and testing the code.
- I like to see people's artworks, plus people always have a need for graphics at some point, especially in the Internet age, I would recommend any of the artistic users here to put a link showcasing some of their work in their profile. No hurry though, I will remember to check.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

31 Dec 2017, 03:46

but I'd be curious to know if it's because I'm doing something wrong here
Nothing wrong , but if you want to have a leading zero you can change the format string :

Code: Select all

loop 9
		{
			
		Random,h,0,160
		Random,l,80,120
		Random,s,180,240

		c%A_Index% := Format("{1:06X}", DllCall( "shlwapi\ColorHLSToRGB", UInt,h, UInt,l, UInt,s ))

		}
		
loop 9
		list .=c%A_Index%  "`n"
msgbox %list%


https://drive.google.com/open?id=1ZD_gh ... eiIr9t1ePB i tried to it but the mp4 does not play it shows the first frame but does not stream when started.
But it looks interesting :)
User avatar
Off Topic
Posts: 43
Joined: 07 Oct 2017, 20:57

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

31 Dec 2017, 19:12

jeeswg wrote:To clarify how Format works:

Code: Select all

;number as hex, with minimum 6 digits
Format("{:06X}", vNum)

;each number as hex, with minimum 2 digits
Format("{:02X}{:02X}{:02X}", vNum1, vNum2, vNum3)

;the number repeated 3 times as hex, with minimum 2 digits each time
;the '1' means use the 1st value
;by default the nth item in curly brackets corresponds to the nth value
Format("{:02X}{1:02X}{1:02X}", vNum)

MsgBox, % Format("{:X} {:X} {:X}", 10, 11, 12) ;A B C
MsgBox, % Format("{1:X} {2:X} {3:X}", 10, 11, 12) ;A B C ;same as line above
MsgBox, % Format("{3:X} {2:X} {1:X}", 10, 11, 12) ;C B A

;further examples here:
;Simplified Format() Command - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=13&t=38525&p=176790#p176790
Image

I understood it when put like that. So:

Code: Select all

+F21:
	Random, vRand1, 0, 15
	Random, vRand2, 0, 15

	; ABABAB / BABABA / BBBBBB / AABBBB / BBAAAA / AAAAAA
		c1 := Format("{:X}{:X}{1:X}{:X}{1:X}{:X}", vRand1, vRand2)
		c2 := Format("{2:X}{1:X}{:X}{1:X}{:X}{1:X}", vRand1, vRand2)
		c3 := Format("{2:X}{2:X}{2:X}{2:X}{2:X}{2:X}", vRand1, vRand2)
		c4 := Format("{2:X}{2:X}{1:X}{1:X}{1:X}{1:X}", vRand1, vRand2)
		c5 := Format("{:X}{1:X}{:X}{2:X}{2:X}{2:X}", vRand1, vRand2)
		c6 := Format("{1:X}{1:X}{1:X}{1:X}{1:X}{1:X}", vRand1, vRand2)	
		; MsgBox %c1%`n%c2%`n%c3%`n%c4%`n%c5%`n%c6%		
		;
		Loop 6
			Shift%A_Index% := c%A_Index%
		;
		Gosub, GuiRoll2
Return


Or:

Code: Select all

Random, vRand1, 0, 15
	Random, vRand2, 0, 15

	; AABBBB/ BBAAAA / AAAABB / BBBBAA / AABBAA / BBAABB
		c1 := Format("{:X}{1:X}{:X}{2:X}{2:X}{2:X}", vRand1, vRand2)
		c2 := Format("{2:X}{2:X}{1:X}{1:X}{1:X}{1:X}", vRand1, vRand2)
		c3 := Format("{:X}{1:X}{1:X}{1:X}{2:X}{2:X}", vRand1, vRand2)
		c4 := Format("{2:X}{2:X}{2:X}{2:X}{1:X}{1:X}", vRand1, vRand2)
		c5 := Format("{:X}{1:X}{:X}{2:X}{1:X}{1:X}", vRand1, vRand2)
		c6 := Format("{2:X}{2:X}{1:X}{1:X}{:X}{2:X}", vRand1, vRand2)	
		; MsgBox %c1%`n%c2%`n%c3%`n%c4%`n%c5%`n%c6%	
Knowing this part makes a big difference in what I'm specifically trying to go for, especially in adding more digits, because it looks like Harmony Rules inside Illustrator follow something I can now replicate with Format() thanks to your description. I'll mark this solved, thanks for all of it!
noname wrote: Nothing wrong , but if you want to have a leading zero you can change the format string :

Code: Select all

loop 9
 {
 
 Random,h,0,160
 Random,l,80,120
 Random,s,180,240

 c%A_Index% := Format("{1:06X}", DllCall( "shlwapi\ColorHLSToRGB", UInt,h, UInt,l, UInt,s ))

 }
 
loop 9
 list .=c%A_Index% "`n"
msgbox %list%


i tried to it but the mp4 does not play it shows the first frame but does not stream when started.
But it looks interesting :)
Here's the simplest result:

Code: Select all

!F21::
	GuiControl, , BG, Under_pick0.png
	
	loop 9
			{
				
			Random,h,0,160
			Random,l,80,120
			Random,s,180,240

			c%A_Index% := Format("{1:06X}", DllCall( "shlwapi\ColorHLSToRGB", UInt,h, UInt,l, UInt,s ))

			}
			
	loop 9
		Shift%A_Index% := c%A_Index%
		
	Gosub, GuiRoll1B
Return
Works very vell! Sorry about that past link but thanks, it's a screen recording of AHK drawing in Adobe Illustrator, if you're still interested:
Spoiler
So now the only problem I have is unrelated to the main topic, and I don't know if it's enough to make a new topic for or if I should just post here while I have the chance. I noticed how both of you were using A_Index within loops and it's a much better solution, I was trying to update everything in my own script by doing that and came across a problem I haven't had yet. I'm not sure how to use it with the following:

Code: Select all

		GuiControl, +Background%Shift1%, 1shifter
		GuiControl, +Background%Shift2%, 2shifter
		GuiControl, +Background%Shift3%, 3shifter
		GuiControl, +Background%Shift4%, 4shifter
		GuiControl, +Background%Shift5%, 5shifter
		GuiControl, +Background%Shift6%, 6shifter
		GuiControl, +Background%Shift7%, 7shifter
		GuiControl, +Background%Shift8%, 8shifter
		GuiControl, +Background%Shift9%, 9shifter
Since this will error and return black backgrounds:

Code: Select all

Loop 9
		GuiControl, +BackgroundShift%A_Index%, %A_Index%shifter
I would need something like this:

Code: Select all

Loop 9
		GuiControl, +Background%Shift%A_Index%%, %A_Index%shifter
                ; or
                ; GuiControl, +Background%Shift(%A_Index%)%, %A_Index%shifter
But I'm not sure how to implement that or where to look in the docs. Is achieving this simple enough to get another response for future reference?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

31 Dec 2017, 19:30

Something I didn't actually know about Format:
Format
https://autohotkey.com/docs/commands/Format.htm
Omit the index to use the next input value in the sequence (even if it has been used earlier in the string).
Although I would probably include the index anyway, to make it more readable, and to align the text.

Code: Select all

q:: ;Format function: the nth blank, will use the nth value
MsgBox, % Format("{},{},{},{}", "a") ;a,{},{},{}
MsgBox, % Format("{},{},{},{}", "a", "b") ;a,b,{},{}
MsgBox, % Format("{},{1},{},{}", "a", "b") ;a,a,b,{}
MsgBox, % Format("{},{1},{},{2}", "a", "b") ;a,a,b,b
MsgBox, % Format("{},{1},{},{2},{}", "a", "b") ;a,a,b,b,{}
return
For your loop, I would do one of these two:

Code: Select all

Loop 9
	GuiControl, % "+Background" Shift%A_Index%, %A_Index%shifter

Loop 9
	GuiControl, % "+Background" Shift%A_Index%, % A_Index "shifter"
Btw. very nice the software in the video, the polygons, webs and snowflakes. Is that the same software as in the image at the top, (i.e. both Adobe Illustrator,) what are your main image/video tools? Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Off Topic
Posts: 43
Joined: 07 Oct 2017, 20:57

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

31 Dec 2017, 21:02

jeeswg wrote:For your loop, I would do one of these two:

Code: Select all

Loop 9
 GuiControl, % "+Background" Shift%A_Index%, %A_Index%shifter

Loop 9
 GuiControl, % "+Background" Shift%A_Index%, % A_Index "shifter"
Very good, thank you! That solves everything on my end, and noted on omitting the index.
jeeswg wrote:Btw. very nice the software in the video, the polygons, webs and snowflakes. Is that the same software as in the image at the top, (i.e. both Adobe Illustrator,) what are your main image/video tools? Cheers.
Yes, I use Adobe Illustrator and After Effects. Everything I've shown so far has been from (and for) Illustrator, from the 3 guis in that gif to those emoticons and my avatar, but any animation that isn't a screencast is done with After Effects. Using AHK in conjunction with the two changes everything about the whole process:
Spoiler
Speaking of, this relates to how I'm trying to animate. I purposefully made my latest gui with a fly-out/fly-in animation (it's fully rigged, can produce brand new animations for it in minutes at any fps) and was using the previous ++Rollcount method within a Loop:

Code: Select all

GuiRWipe:
	Gui, Show, w311 h%fullH2% NoActivate
	Gosub, GuiHide

; Couldn't replicate the results through .gif
	; GuiControl, , BG, XRightIn.gif
	; Sleep, %FPSfull%
	; GuiControl, , BG, sUnderDebug3.png

	;Loop
		Wipe = 0
		GuiControl, , BG, XRightIn_0000%Wipe%.png
		Loop, 10
		{
			++Wipe
				GuiControl, , BG, XRightIn_0000%Wipe%.png
				Sleep, %SleepNum2%
		}
		Loop, 7
		{
			++Wipe
				GuiControl, , BG, XRightIn_000%Wipe%.png
				Sleep, %SleepNum2%
		}

	Gosub, GuiShow
	GuiControl, , BG, bg_Dark.png
	Sleep, 50
	WinActivate, %mainProg%
	Gosub, RefreshGUI
Return
I'd like it to look smooth like so:
Scrolling.gif
Scrolling.gif (130.52 KiB) Viewed 3076 times
But it is not smooth like so. Ideally I'd like to just place that as a gif into it for reliable display, but that doesn't work for me (and I wouldn't be able to precisely control the timing of everything, rigged). But I don't know of any optimal frames per second to Sleep equivalent and what will translate correctly (on either side, what fps I should be rendering png sequences as, what Sleep value would be equivalent without burdening the processing too much), I don't get correct or consistent results near the Sleep, 40-50 range for 24/25 fps. There are too many open variables here that I don't know if it's a Hz thing the way it'll glitch or not, but it does pretty often. So I'm trying to manually animate using loops and png sequences here, and I've replaced the above code with this:

Code: Select all

Loop, 17
                {
				If (A_Index <= 9)
				GuiControl, , BG, XRightIn_0000%A_Index%.png
				Else
				GuiControl, , BG, XRightIn_000%A_Index%.png
				
				Sleep, %SleepNum2%
		}
Which does work, but "Sleep, 40" doesn't display 25 fps correctly and I don't know what to do about it or where to go from there. Any references or things you guys know of, or any better ways to do this? I want to utilize animation a lot and would love a reliable/trustworthy method. I'd also like to be able to turn my cursor into a sword or a pen or an animated cartoon (through .CUR or .ANI or whatever's needed, I'll render as) but Adobe Illustrator changes the cursors natively and I can only find a very complicated thread about changing System Cursors (which is awesome, but only I want to change it temporarily, Sleep, and change it back as a part of the animation) but that is super peripheral.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

31 Dec 2017, 21:21

- I don't really have much to say re. the smooth scrolling. So I would hope someone might be able to chip in with something.
- Possibly I would try creating hBitmaps when the script loads and using those, rather than reading in image files every time. In case it was reading the file that slowed things down.
- Here I use the Winapi function CopyImage to reuse the same image multiple times:
LoadPicture() from variable - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 26#p178626
- If you increase the Sleep duration to make it quite long, does it ever look smooth? I.e. what Sleep duration.
- [EDIT:] Re. cursors, this code may be useful, I know something like this is used with AccViewer/iWB2 Learner to change the cursor:

Code: Select all

; Example: Hides the mouse cursor when you press Win+C. To later show the cursor, press Win+C again.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: What would be a better way to roll for RGB color values? (AA00FF, 272727, etc.)

01 Jan 2018, 11:11

Image
You can always use BitBild to draw direct on the window , it can update to 60fps without flickering.

Here is an example but i never mixed this with a standard Gui using controls so maybe there are side effects , i mostly use a layered window to create smooth interface but it is A LOT OF WORK !!! and if smooth graphics is just a " nice side show " i would not put all the effort in it :)
Attachments
bitbild.ahk
(695.99 KiB) Downloaded 58 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder and 420 guests