Share your repls and programming experiences

← Back to all posts
Color Search
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.


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.

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.

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
jayda710
noelcherian
dillonjoshua68
pr0p3rno0b10
SelenaYang1
Jakman
ElijahNik
ZanderSlack1
JonathanCokely
zplusfour
Comments
hotnewtop
techgeek680

😳 WOW! I NEED THIS

Roar123

@techgeek680 Great to hear that!

zplusfour

@techgeek680 me too!

techgeek680

:) @ZDev1

zplusfour
DynamicSquid

wat

CodeLongAndPros

@DynamicSquid Squid green

Roar123
DynamicSquid

@CodeLongAndPros SQUID PINK

CodeLongAndPros

@DynamicSquid SQUID should be a unicode modifer

DynamicSquid

@CodeLongAndPros I would love to see that

CodeLongAndPros

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

DynamicSquid
CodeLongAndPros

@DynamicSquid Color transforms on a bw image.

zplusfour

I was making this:


And now:


:DDD

thenullified

nice @ZDev1

Roar123

@ZDev1 Awesome!

zplusfour
zplusfour
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.

Roar123
AtticusKuhn

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

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.

thenullified

i need to bookmark this...

Bookie0

Cool!

CodeLongAndPros

Happy Pi!

Roar123
awesome10

interesting...

[deleted]

Cool!