Is there anything wrong with using decimal values for the colors in an RGBA color string?

I am using canvas in Javascript and I have some code that looks like this at the moment: const color = [ 0.3, 0.25, 0.12 ]; // in the actual code this is returned from a function const r = Math.floor(color[0] * 255); const g = Math.floor(color[1] * 255); const b = Math.floor(color[2] * 255);… Read More Is there anything wrong with using decimal values for the colors in an RGBA color string?

Pandas – calculating difference in two hex integer color values

I am attempting to calculate differences in integer hex values. My df as formatted as such: import pandas as pd data = [[‘0xD8E3ED’, 2043441], [‘0xF7F4EB’, 912788],[‘0x000000’,6169]] df = pd.DataFrame(data, columns=[‘c_code’, ‘occurence’]) df[‘value’] = df[‘c_code’].apply(int, base=16) Now I would like to add a color difference to my df with help from coldiff.py I am able to… Read More Pandas – calculating difference in two hex integer color values

Recreate colormap based on colorscale in matplotlib

I have an image of a color scale I filter out the actual color scale by using import cv2 import numpy as np colorbar = cv2.imread(‘colorbar-scheme-elevation.png’, cv2.IMREAD_UNCHANGED) colorbar = cv2.cvtColor(colorbar, cv2.COLOR_BGRA2BGR) hsv = cv2.cvtColor(colorbar, cv2.COLOR_RGB2HSV) lower_gray = np.array([0, 0, 0]) upper_gray = np.array([255, 10, 255]) mask = cv2.inRange(hsv, lower_gray, upper_gray) mask = cv2.bitwise_not(mask) res =… Read More Recreate colormap based on colorscale in matplotlib