Skip to content
← Back to Community
Color Search
Profile icon
Roar123

Color Search

Hi everyone, I made a program which allows you to search for colors. This was a very cool project for me to do as I used a webscraper to scrape all the color data into a json and used readchar instead of input to enable the updating search feature.

Make sure your console view is large enough so you can see the search results properly.

How to use

Let's say you're creating a website and need the perfect color for your header. You'd like a color which is pretty medium, but are not sure which one to pick. Start by searching medium and you'll see a list of colors which contain 'medium' in their name.

Screenshot 2020-06-19 at 1.45.22 PM
Oh cool, I want to use medium spring green in my project. Type the color you would like to use into the search bar and then hit enter.

Screenshot 2020-06-19 at 1.47.26 PM

Nice right!

How I made it

First of all, I needed to create a dictionary with the color name as the key and a dictionary with the hex and rgb values as the value. Since the data is correlated and jsons are cool, dictionaries were the perfect choice.

I created a webscraper to scrape the color table on rapidtables.com. If you want to see the code, click here. The webscraper formats the data and dumps it into a json file.

Now that the color dictionary was complete, I focused on the search functionality. I wanted the search results to update every time the user pressed a key so input() wasn't going to cut it.

Instead, I used readchar which is a library that handles single keypresses. Using this, I could update the search results at each keypress, clearing the screen in between.

Since I was using readchar and not input, I had to check if the user entered "Enter" or "Backspace" and respond accordingly. Quick trick: to figure out the codes for keys like enter and backspace, use this.

import readchar key = readchar.readkey() print(key.split("\\"))

Turns out that splitting at the forward slash gives you the code. Note that there are 2 's because you need to escape it.

I also used the RGB ANSI escape code to color the unicode box.

Color Search: https://repl.it/@Roar123/Color-Search
Colors Webscraper: https://repl.it/@Roar123/Colors-Webscraper

Voters
Profile icon
FrankieBanks
Profile icon
Camillede6
Profile icon
jayda710
Profile icon
noelcherian
Profile icon
dillonjoshua68
Profile icon
pr0p3rno0b10
Profile icon
SelenaYang1
Profile icon
Jakman
Profile icon
ElijahNik
Profile icon
ZanderSlack1
Comments
hotnewtop
Profile icon
techgeek680

😳 WOW! I NEED THIS

Profile icon
Roar123

@techgeek680 Great to hear that!

Profile icon
zplusfour

@techgeek680 me too!

Profile icon
techgeek680
Profile icon
zplusfour
Profile icon
DynamicSquid
Profile icon
CodeLongAndPros

@DynamicSquid Squid green

Profile icon
Roar123
Profile icon
DynamicSquid

@CodeLongAndPros SQUID PINK

Profile icon
CodeLongAndPros

@DynamicSquid SQUID should be a unicode modifer

Profile icon
DynamicSquid

@CodeLongAndPros I would love to see that

Profile icon
CodeLongAndPros

@DynamicSquid I had an idea about that. Would you like to work on it tomorrow?

Profile icon
DynamicSquid
Profile icon
CodeLongAndPros

@DynamicSquid Color transforms on a bw image.

Profile icon
zplusfour
Profile icon
thenullified
Profile icon
Roar123

@ZDev1 Awesome!

Profile icon
zplusfour
Profile icon
zplusfour
Profile icon
BlueComet

Wow this is pretty cool! My favorite feature is how it shows possible colors. At first you want one color but then you see 20 cooler colors.

Profile icon
Roar123
Profile icon
AtticusKuhn

Very cool. Picking colours can be such a pain in coding.

Profile icon
BhaskarRana

I have recently created an online color picker using simple HTML, CSS, and JavaScript. It took me around a week to complete it and I actually spent several hours to achieve it.
Here is the link:
https://programmersportal.com/html-color-picker/

Please do like if you find it nice.

Profile icon
thenullified

i need to bookmark this...

Profile icon
Bookie0

Cool!

Profile icon
CodeLongAndPros

Happy Pi!

Profile icon
Roar123
Profile icon
awesome10

interesting...

Profile icon
[deleted]

Cool!