GMK Posted October 13, 2016 Share Posted October 13, 2016 Let's say I have a font size at any given pixels. In a certain program, the auto-sized box given this font size has a height that can be calculated using the following formula: Global $iPixels = 100 Global $iBoxHeight = $iPixels + Int($iPixels / 5) + 14 ; $iBoxHeight = 134 I can't for the life of me figure out how to find the pixels, given the height, or if it's even possible. Any help would be greatly appreciated. Thanks! Link to comment Share on other sites More sharing options...
jchd Posted October 13, 2016 Share Posted October 13, 2016 Can you test this: $iPixels = Round(($iBoxHeight - 14) * 5 / 6) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
GMK Posted October 13, 2016 Author Share Posted October 13, 2016 It's close, but not exact. #include <Array.au3> Global Enum $ePx, $eBoxHeight, $ePxCalculated Global $aArray[100][3] For $iRow = 0 To 99 $aArray[$iRow][$ePx] = $iRow + 1 $aArray[$iRow][$eBoxHeight] = $aArray[$iRow][$ePx] + Int($aArray[$iRow][$ePx] / 5) + 14 $aArray[$iRow][$ePxCalculated] = Round(($aArray[$iRow][$eBoxHeight] + 1 - 14) * 5 / 6) Next _ArrayDisplay($aArray) Link to comment Share on other sites More sharing options...
GMK Posted October 13, 2016 Author Share Posted October 13, 2016 Thank you, by the way. Link to comment Share on other sites More sharing options...
GMK Posted October 13, 2016 Author Share Posted October 13, 2016 I found some help here. $iPixels = Ceiling(($iBoxHeight * 5 - 70) / 6) Thanks, @jchd! Link to comment Share on other sites More sharing options...
jchd Posted October 13, 2016 Share Posted October 13, 2016 Yup, I wasn't sure about the rounding direction. Both equation yield the same result before rounding (ceil vs. floor). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
aleph01 Posted October 14, 2016 Share Posted October 14, 2016 (edited) If my algebra still works, $iBoxHeight = $iPixels + Int($iPixels / 5) + 14 I translate to H = P + (P/5) + 14 H-14 = P + (P/5) H-14 = 1.2P (H-14)/ 1.2 = P or in your variables, = ($iHeight - 14) / 1.2 = $iPixels Substituting the numbers, (134-14)/1.2 = $iPixels ; (Height-14) / 1.2 = Pixels 120/1.2 = $iPixels 100 = $iPixels Use (Height-14) / 1.2 = Pixels That's the math. You can work on rounding to whole numbers if necessary. Hope you can follow that. Hope I didn't make a mistake; it's been a long time., but I think that's right. Good luck, _aleph_ Edited October 14, 2016 by aleph01 spelling correction Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
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