Maxime Posted March 12, 2022 Posted March 12, 2022 Hello I am looking to transform a Hex color to the nearest color in Ansi256 can someone help me, thanks
Moderators Melba23 Posted March 12, 2022 Moderators Posted March 12, 2022 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
argumentum Posted March 12, 2022 Posted March 12, 2022 4 minutes ago, Maxime said: ... can someone help me ... https://www.ditig.com/256-colors-cheat-sheet so, the hex is the RGB in 0xRR, 0xGG, 0xBB, so that the rgb(RR,GG,BB) is 0xRRGGBB. So in hex, FF is 255 Decimal. Zero is zero. Its simple really. Unless you explain your limitation in code, I don't know what else to tell you. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting
Maxime Posted March 12, 2022 Author Posted March 12, 2022 hello, in fact in hex I have a palette of 16,777,216 colors. I would like by entering a value to give me the color closest to the palette of 256 colors
argumentum Posted March 12, 2022 Posted March 12, 2022 ...this is above my experience level. Surely someone more knowledgeable will come along to answer your post. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting
Maxime Posted March 12, 2022 Author Posted March 12, 2022 for example when i have #008000 the result is color 2 in Xterm Number #008001 the result is color 2 in Xterm Number
Maxime Posted March 12, 2022 Author Posted March 12, 2022 i find https://codegolf.stackexchange.com/questions/156918/rgb-to-xterm-color-converter but is not in autoit language
Nine Posted March 12, 2022 Posted March 12, 2022 (edited) #include <color.au3> Local $rgb = 0x8A9B7C Local $r = _ColorGetRed($rgb), $g = _ColorGetGreen($rgb), $b = _ColorGetBlue($rgb) Local $color = Round(($r*6/256)*36) + Round(($g*6/256)*6) + Round($b*6/256) ConsoleWrite($color & @CRLF) RGB is pretty much the same as 256 colors, except the span is smaller... edit : ofc it will depend on which terminal you are displaying it (your link refer to XTERM) Edited March 12, 2022 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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