Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    The best drone for 2026

    YouTube was down for thousands of users in the US

    Samsung teases mobile AI photography tools ahead of Unpacked

    Facebook X (Twitter) Instagram
    • Artificial Intelligence
    • Business Technology
    • Cryptocurrency
    • Gadgets
    • Gaming
    • Health
    • Software and Apps
    • Technology
    Facebook X (Twitter) Instagram Pinterest Vimeo
    Tech AI Verse
    • Home
    • Artificial Intelligence

      Read the extended transcript: President Donald Trump interviewed by ‘NBC Nightly News’ anchor Tom Llamas

      February 6, 2026

      Stocks and bitcoin sink as investors dump software company shares

      February 4, 2026

      AI, crypto and Trump super PACs stash millions to spend on the midterms

      February 2, 2026

      To avoid accusations of AI cheating, college students are turning to AI

      January 29, 2026

      ChatGPT can embrace authoritarian ideas after just one prompt, researchers say

      January 24, 2026
    • Business

      The HDD brand that brought you the 1.8-inch, 2.5-inch, and 3.5-inch hard drives is now back with a $19 pocket-sized personal cloud for your smartphones

      February 12, 2026

      New VoidLink malware framework targets Linux cloud servers

      January 14, 2026

      Nvidia Rubin’s rack-scale encryption signals a turning point for enterprise AI security

      January 13, 2026

      How KPMG is redefining the future of SAP consulting on a global scale

      January 10, 2026

      Top 10 cloud computing stories of 2025

      December 22, 2025
    • Crypto

      Wall Street Moves Into Prediction Markets With Election-Contract ETF Filings

      February 18, 2026

      Tectonic to Host Inaugural Quantum Summit at ETHDenver 2026 Focused on Post-Quantum Cryptography Readiness for Web3

      February 18, 2026

      Ki Young Ju Says Bitcoin May Need to Hit $55K Before True Recovery Begins

      February 18, 2026

      MYX Finance Is Oversold For The First Time Ever, Yet No Relief In Sight

      February 18, 2026

      Everyone is Talking about the SaaSpocalypse, But Why Does it matter for Crypto?

      February 18, 2026
    • Technology

      The best drone for 2026

      February 18, 2026

      YouTube was down for thousands of users in the US

      February 18, 2026

      Samsung teases mobile AI photography tools ahead of Unpacked

      February 18, 2026

      Texas AG sues TP-Link over purported connection to China

      February 18, 2026

      Google I/O 2026 is set for May 19 and 20

      February 18, 2026
    • Others
      • Gadgets
      • Gaming
      • Health
      • Software and Apps
    Check BMI
    Tech AI Verse
    You are at:Home»Technology»Terminals should generate the 256-color palette
    Technology

    Terminals should generate the 256-color palette

    TechAiVerseBy TechAiVerseFebruary 18, 2026No Comments5 Mins Read2 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Terminals should generate the 256-color palette
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    Terminals should generate the 256-color palette

    Terminals should generate the 256-color palette from the user’s
    base16 theme.

    If you’ve spent much time in the terminal, you’ve probably set a
    custom base16 theme. They work well. You define a handful of colors
    in one place and all your programs use them.

    The drawback is that 16 colors is limiting. Complex and color-heavy
    programs struggle with such a small palette.

    The mainstream solution is to use truecolor and gain access to 16
    million colors. But there are drawbacks:

    • Each truecolor program needs its own theme configuration.
    • Changing your color scheme means editing multiple config files.
    • Light/dark switching requires explicit support from program maintainers.
    • Truecolor escape codes are longer and slower to parse.
    • Fewer terminals support truecolor.

    The 256-color palette sits in the middle with more range than base16
    and less overhead than truecolor. But it has its own issues:

    • The default theme clashes with most base16 themes.
    • The default theme has poor readability and inconsistent contrast.
    • Nobody wants to manually define 240 additional colors.

    The solution is to generate the extended palette from your existing
    base16 colors. You keep the simplicity of theming in one place while
    gaining access to many more colors.

    If terminals did this automatically then terminal program maintainers
    would consider the 256-color palette a viable choice, allowing them
    to use a more expressive color range without requiring added
    complexity or configuration files.

    Understanding the 256-Color Palette

    The 256-color palette has a specific layout. If you are already
    familiar with it, you can skip to the next section.

    The Base 16 Colors

    The first 16 colors form the base16 palette. It contains black,
    white, and all primary and secondary colors, each with normal and
    bright variants.

    1. black
    2. red
    3. green
    4. yellow
    5. blue
    6. magenta
    7. cyan
    8. white
    9. bright black
    10. bright red
    11. bright green
    12. bright yellow
    13. bright blue
    14. bright magenta
    15. bright cyan
    16. bright white

    The 216-Color Cube

    The next 216 colors form a 6x6x6 color cube. It works like 24-bit
    RGB but with 6 shades per channel instead of 256.

    You can calculate a specific index using this formula, where R, G,
    and B range from 0 to 5:

    16 + (36 * R) + (6 * G) + B
    

    The Grayscale Ramp

    The final 24 colors form a grayscale ramp between black and white.
    Pure black and white themselves are excluded since they can be found
    in the color cube at (0, 0, 0) and (5, 5, 5).

    You can calculate specific index using this formula, where S is the
    shade ranging from 0 to 23:

    232 + S
    

    Problems with the 256-Color Palette

    Base16 Clash

    The most obvious problem with the 256-color palette is the inconsistency
    with the user’s base16 theme:

    Using a custom 256-color palette gives a more pleasing result:

    Incorrect Interpolation

    The default 216-color cube interpolates between black and each color
    incorrectly. It is shifted towards lighter shades (37% intensity
    for the first non-black shade as opposed to the expected 20%), causing
    readability issues when attempting to use dark shades as background:

    If the color cube is instead interpolated correctly, readability
    is preserved:

    Inconsistent Contrast

    The default 256-color palette uses fully saturated colors, leading
    to inconsistent brightness against the black background. Notice
    that blue always appears darker than green, despite having the same
    shade:

    If a less saturated blue is used instead then the consistent
    brightness is preserved:

    Generating the Palette

    These problems can be solved by generating the 256-color palette
    from the user’s base16 colors.

    The base16 palette has 8 normal colors which map to the 8 corners
    of the 216-color cube. The terminal foreground and background should
    be used instead of the base16 black and white.

    These colors can be used to construct the 216-color cube via trilinear
    interpolation, and the grayscale ramp with a simple background to
    foreground interpolation.

    The LAB colorspace should be used to achieve consistent apparent
    brightness across hues of the same shade.

    Solarized with RGB interpolation:

    Solarized with LAB interpolation:

    Combined image of many generated themes:

    Before and after using 256 palette generation with default colors:

    Implementation

    This code is public domain, intended to be modified and used anywhere
    without friction.

    def lerp_lab(t, lab1, lab2):
        return (
            lab1[0] + t * (lab2[0] - lab1[0]),
            lab1[1] + t * (lab2[1] - lab1[1]),
            lab1[2] + t * (lab2[2] - lab1[2]),
        )
    
    def generate_256_palette(base16, bg=None, fg=None):
        base8_lab = [rgb_to_lab(c) for c in base16[:8]]
        bg_lab = rgb_to_lab(bg) if bg else base8_lab[0]
        fg_lab = rgb_to_lab(fg) if fg else base8_lab[7]
    
        palette = [*base16]
    
        for r in range(6):
            c0 = lerp_lab(r / 5, bg_lab, base8_lab[1])
            c1 = lerp_lab(r / 5, base8_lab[2], base8_lab[3])
            c2 = lerp_lab(r / 5, base8_lab[4], base8_lab[5])
            c3 = lerp_lab(r / 5, base8_lab[6], fg_lab)
            for g in range(6):
                c4 = lerp_lab(g / 5, c0, c1)
                c5 = lerp_lab(g / 5, c2, c3)
                for b in range(6):
                    c6 = lerp_lab(b / 5, c4, c5)
                    palette.append(lab_to_rgb(c6))
    
        for i in range(24):
            t = (i + 1) / 25
            lab = lerp_lab(t, bg_lab, fg_lab)
            palette.append(lab_to_rgb(lab))
    
        return palette

    Conclusion

    The default 256-color palette has room for improvement. Considering
    its poor readability and its clash with the user’s theme, program
    authors avoid it, opting for the less expressive base16 or more
    complex truecolor.

    Terminals should generate the 256-color palette from the user’s
    base16 theme. This would make the palette a viable option especially
    considering its advantages over truecolor:

    • Access to a wide color palette without needing config files.
    • Light/dark switching capability without developer effort.
    • Broader terminal support without compatibility issues.
    Share. Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Telegram Email
    Previous ArticleGoogle Pixel 10A Rumors: Wednesday Reveal, New Colors, Preorders
    Next Article 15 years later, Microsoft morged my diagram
    TechAiVerse
    • Website

    Jonathan is a tech enthusiast and the mind behind Tech AI Verse. With a passion for artificial intelligence, consumer tech, and emerging innovations, he deliver clear, insightful content to keep readers informed. From cutting-edge gadgets to AI advancements and cryptocurrency trends, Jonathan breaks down complex topics to make technology accessible to all.

    Related Posts

    The best drone for 2026

    February 18, 2026

    YouTube was down for thousands of users in the US

    February 18, 2026

    Samsung teases mobile AI photography tools ahead of Unpacked

    February 18, 2026
    Leave A Reply Cancel Reply

    Top Posts

    Ping, You’ve Got Whale: AI detection system alerts ships of whales in their path

    April 22, 2025683 Views

    Lumo vs. Duck AI: Which AI is Better for Your Privacy?

    July 31, 2025267 Views

    6.7 Cummins Lifter Failure: What Years Are Affected (And Possible Fixes)

    April 14, 2025155 Views

    6 Best MagSafe Phone Grips (2025), Tested and Reviewed

    April 6, 2025114 Views
    Don't Miss
    Technology February 18, 2026

    The best drone for 2026

    The best drone for 2026Drones are no longer just niche toys for enthusiasts. Today’s models…

    YouTube was down for thousands of users in the US

    Samsung teases mobile AI photography tools ahead of Unpacked

    Texas AG sues TP-Link over purported connection to China

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Welcome to Tech AI Verse, your go-to destination for everything technology! We bring you the latest news, trends, and insights from the ever-evolving world of tech. Our coverage spans across global technology industry updates, artificial intelligence advancements, machine learning ethics, and automation innovations. Stay connected with us as we explore the limitless possibilities of technology!

    Facebook X (Twitter) Pinterest YouTube WhatsApp
    Our Picks

    The best drone for 2026

    February 18, 20263 Views

    YouTube was down for thousands of users in the US

    February 18, 20263 Views

    Samsung teases mobile AI photography tools ahead of Unpacked

    February 18, 20263 Views
    Most Popular

    7 Best Kids Bikes (2025): Mountain, Balance, Pedal, Coaster

    March 13, 20250 Views

    VTOMAN FlashSpeed 1500: Plenty Of Power For All Your Gear

    March 13, 20250 Views

    This new Roomba finally solves the big problem I have with robot vacuums

    March 13, 20250 Views
    © 2026 TechAiVerse. Designed by Divya Tech.
    • Home
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.