WildByDesign Posted yesterday at 09:24 PM Posted yesterday at 09:24 PM Either I had too much coffee today or possibly not enough, but the math part of my brain is not working right now. 😆 With _WinAPI_SetLayeredWindowAttributes there is a Transparency level of 0 to 255. I would like to simplify what the user needs to enter in an INI file with a value of 0 to 100, representing percentage. So if a user enters 100, that would need to convert to 255 in a math function. 0 would obviously be 0. But it is the whole math thing that is escaping me right now. Could someone please point me in the right direction for this? Thank you
Solution argumentum Posted yesterday at 09:29 PM Solution Posted yesterday at 09:29 PM 255/100 = 2.55 ? then 100 * 2.55 = 255 ? Multiply the 0 to 100 by 2.55 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
WildByDesign Posted yesterday at 09:33 PM Author Posted yesterday at 09:33 PM Your math is always sharp. Thank you so much. argumentum and WarMan 2
argumentum Posted yesterday at 09:54 PM Posted yesterday at 09:54 PM ConsoleWrite( myPercentThing(200) & @CRLF) ConsoleWrite( myPercentThing(100) & @CRLF) ConsoleWrite( myPercentThing(50) & @CRLF) ConsoleWrite( myPercentThing(0) & @CRLF) ConsoleWrite( myPercentThing(-1000) & @CRLF) Func myPercentThing($vDecimal) $vDecimal = ($vDecimal < 0 ? 0 : $vDecimal) $vDecimal = ($vDecimal > 100 ? 100 : $vDecimal) Return Ceiling($vDecimal * 2.55) ; round up EndFunc 0 visibility is totally transparent. Make a minimum of 50 🤔 donnyh13 and WildByDesign 2 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
WildByDesign Posted yesterday at 10:00 PM Author Posted yesterday at 10:00 PM That is really neat. Thank you for sharing. I can tell from this (and many of your previous functions) that you truly enjoy doing great things with math.
Somerset Posted 23 hours ago Posted 23 hours ago The starting digit is 0 not 1, so it is 256 levels of transparency. argumentum and WildByDesign 1 1
WildByDesign Posted 23 hours ago Author Posted 23 hours ago 9 minutes ago, Somerset said: The starting digit is 0 not 1, so it is 256 levels of transparency. You are absolutely right. So that would make the multiplier 2.56 then. Thanks for the heads up on that one.
argumentum Posted 22 hours ago Posted 22 hours ago (edited) 1 hour ago, WildByDesign said: So that would make the multiplier 2.56 then Would be ( 2.55 * n ) + 1 But "Transparency: A number in the range 0 - 255. The lower the number, the more transparent the window will become. 255 = Solid, 0 = Invisible." 0x00 to 0xFF Always doublecheck everything. Anyone can misremember or be just plain wrong. Me, you, @TheSaint ... anyone 1 hour ago, Somerset said: The starting digit is 0 not 1, so it is 256 levels of transparency. And @Somerset can say something that is true Edited 22 hours ago by argumentum TheSaint 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Somerset Posted 21 hours ago Posted 21 hours ago I've done enough editing of image files to know a few things. If you are going to have % of transparency you should have a small input section from 0 - 255 as exacting levels of transparency. Most people cannot tell the difference of 1% to about 5% level of transparency, but some might want the option to have exacting levels for better control. 42 minutes ago, argumentum said: And @Somerset can say something that is true Don't presume that about me. I don't like to lie as much as stretching the truth so far that is snaps back on me like a rubber band that has broke from the stress. WildByDesign, SOLVE-SMART, TheSaint and 1 other 1 3
argumentum Posted 21 hours ago Posted 21 hours ago 20 minutes ago, Somerset said: Most people cannot tell the difference of 1% to about 5% level of transparency, but some might want the option to have exacting levels for better control. True. I rather enter a value between 0 and 255 than 0 to 100 because, why dumbify something when there is no need. Spoiler #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("slider", 220, 100, 100, 200) GUISetBkColor(0x00E0FFFF) ; will change background color Local $idSlider1 = GUICtrlCreateSlider(10, 10, 200, 20) GUICtrlSetLimit(-1, 255, 0) ; change min/max value Local $idButton = GUICtrlCreateButton("Value?", 75, 70, 70, 20) GUISetState(@SW_SHOW) GUICtrlSetData($idSlider1, 45) ; set cursor Local $idMsg ; Loop until the user exits. Do $idMsg = GUIGetMsg() If $idMsg = $idButton Then MsgBox($MB_SYSTEMMODAL, "slider1", GUICtrlRead($idSlider1), 2) EndIf Until $idMsg = $GUI_EVENT_CLOSE EndFunc ;==>Example WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
TheSaint Posted 15 hours ago Posted 15 hours ago 6 hours ago, Somerset said: Don't presume that about me. Because that can make a Pres out of U and Me ... whatever a Pres is ... maybe some kind of Trump thing. 6 hours ago, Somerset said: I don't like to lie as much as stretching the truth so far that is snaps back on me like a rubber band that has broke from the stress. Not only that, but the truth can be stretched so much it becomes unrecognizable ... that's when Oranges can be like Apples and Bananas like Sausages ... so Gastronomy suffers and we all end up with a belly ache. I don't know about you, but I prefer to not have sausages in my Fruit Salad ... or Bananas and Mash. TheDcoder and WildByDesign 2 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
UEZ Posted 14 hours ago Posted 14 hours ago (edited) A generic map function: ;Coded by UEZ build 2025-10-29 Func Map($val, $source_start, $source_stop, $dest_start, $dest_stop) Return (($val - $source_start) * ($dest_stop - $dest_start) / ($source_stop - $source_start) + $dest_start) EndFunc $iCol = Int(Map(87, 0, 100, 0, 255)) ConsoleWrite($iCol & " - 0x" & Hex($iCol, 2) & @CRLF) ;87% from color value (0 - 255) $iCol = 1 + Int(Map($iCol, 0, 255, 0, 100)) ;and back again ConsoleWrite($iCol & " - 0x" & Hex($iCol, 2) & @CRLF) Edited 14 hours ago by UEZ WildByDesign, SOLVE-SMART and Parsix 1 2 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
WildByDesign Posted 12 hours ago Author Posted 12 hours ago 1 hour ago, UEZ said: A generic map function: This is really nice. Accurate as well and with no decimal places. Thank you for sharing.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now