How to select N Colors from the Spectrum? - colors

Given the RGB color white #ffffff, how would one split this into N colors?
Imagine a Rainbow, it has 7 colors.
How would one programatically yield these 7 colors? If you can arrive at 7 colors in this known spectrum, how would one yield say 70 colors of this spectrum in the same relative order? Meaning that this rainbow would contain 10 "steps" between Orange and Yellow for example. The Orange and Yellow are no longer side by side but separated by an interpolation of color between them.

Related

How to get a color by substracting the other from their combination?

I have a table like this one: https://docs.google.com/spreadsheets/d/1Kn4vfbHwpif7u-6ZTznFpBJFNHhnStETPIQVyQq8xgY/edit#gid=0 with bottom / top color and the Red, Green, Blue (RGB) of the result (where it states 'Preparation' for the bottom color means the canvas so essentially its the RGB of the top color - those rows are the 'single colors').
I am looking for a relation between the double colors and the single colors. E.g. could I somehow subtract one color from their combination and get the other? Either by using the RGB values or using the images in some software?
Note that the type/formula/function/relation that I am looking for will be only for specific single colors and their combinations which I have already measured (do not care if it is valid beyond the dataset that I am working with)

Can I find a semi-transparent layer's colour and transparency using before and after values?

I have two images, one is a portion of an original image, the other is the whole of the original image covered by a uniform semi-transparent colour layer (in this case orange).
Can I use the colour difference between pixels from the first and second images to reverse engineer the colour and transparency of the covering, and if so can I then use it to find the original colour of a pixel without an uncovered equivalent? Is there just a nice single button solution within GIMP or do I need to do some actual programming/maths? I have basically no experience with image manipulation so any help would be appreciated.
Here are the uncovered and covered RGB values to help explain (and the missing value at the bottom).
Colour
Base
+Transparent
Colour 1
#179fb7
#f8b76f
Colour 2
#2fafc8
#f8bf6f
Colour 3
#3fc8d8
#f8c877
Colour 4
#578f08
#f8b73f
Colour 5
#6faf2f
#f8bf47
Colour 6
#87c847
#f8c84f
Colour 7
#9fd85f
#f8c857
Colour 8
#d0bf47
#f8bf4f
Colour 9
#8f9f1f
#f8b747
Colour 10
#6faf2f
#f8d077
Colour 11
?
#f8d06f
I assume you can find every possible colour-transparency pair that would cause the transformation for each row and the plot each as a line to find the intersection point, but I don't know enough about how colour works to do that.

How to color only the backbone nitrogen atom in PyMOL?

I have a cartoon representation of a structure. On this structure I want to show the backbone nitrogens colored. I tried
select bb, name n
then tried to color bb by representation and element
But, unfortunately, none of the options seem to give colors. Could you please let me know how to only color the backbone nitrogen?
Thanks
The cartoon representation inside a protein is an average over three atoms in each amino acid: the C alpha and the amide bond's C and N atom. I'm not sure how you imagine it should look if only the "N part" of this representation should be colored.
Be aware: the cartoon's color is determined through the C alpha, so coloring the N will do nothing, however, if you color the C alpha (name CA), you will color the full cartoon.
if you want to have a helix with alternating colors, you should take a look at
spectrum which allows an alternating color of the cartoon. Maybe you could fiddle something together with it.
E.g. a 9mer peptide would have red white and blue alternating on each amino acid like this:
spectrum count, red white blue red white blue red white blue red white blue red white blue red white blue red white blue red white blue red white blue, 9merselection

How to pick good contrast RGB colors programmatically?

Suppose, in your program:
color A is a color we randomly select
Knowing color A, how can I pick a color B that will be in high contrast with color A?
The problem can be further reduced to: "imagine 2 squares filled with color next to one another. It should be unambiguously clear to a human eye that colors are not the same"
Example:
Black --> White
Blue --> White
There is some information in the Web Content Accessibility Guidelines (WCAG) 2.0 (http://www.w3.org/TR/2008/REC-WCAG20-20081211)
Visual contrast: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast
Contrast ratio: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
Relative luminance : http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
There's a good example in this site but he calculate where two colors are enough, not how to get them.
To choose a color with good contrast, I'd go with complementary colors: for example, choose the random color A, transform it to a HSV space, get the complementary hue.
Complementary hue: after you transform color from RGB to HSV, complementary hue will be 180 degrees appart (or 0.5, in a 0-1 normalized hue value). This site has something about it in PHP
As I was searching for a better way to do this, i stumbled across the Adobe Illustrator guide which mentions how they create complementary colors. They say:
Complement Changes each component of a color to a new value based on the sum of the highest and lowest RGB values in the selected color. Illustrator adds the lowest and highest RGB values of the current color, and then subtracts the value of each component from that number to create new RGB values. For example, suppose you select a color with an RGB value of 102 for red, 153 for green, and 51 for blue. Illustrator adds the high (153) and low (51) values, to end up with a new value (204). Each of the RGB values in the existing color is subtracted from the new value to create new complementary RGB values: 204 – 102 (the current red value) = 102 for the new red value, 204 – 153 (the current green value) = 51 for the new green value, and 204 – 51 (the current blue value) = 153 for the new blue value.
It wouldn't be too hard to do this programmatically and think this time that it might actually work for what you are trying to do.
Good Luck!

I Need to write a program to draw a graph using HP PCL 5e/HP/GL2

I have read an example and tried to duplicate it's methods but with weird results. This is a 1 shot deal so I do not want to buy a package to do this. Also, it will be executed on a Multi-Valued database in a Basic that not many programmers write in anymore.
If anyone can post a small example of this It would be most helpful. Specifically, I need a box centered on an 8x11 paper with the left 1/3 filled in Green, the center 1/3 in Yellow and the last 1/3 in Red. Then Draw a line thru 3 points within each color of the box.
Thanks.
The simplest way is to draw 3 boxes. You'll have to position each one on your own doing your own math to determine where to start the first one to make it centered etc.
First position your cursor at the top left of the first box, draw it, move to the top left of the next box, draw it, and do the same for the last. Here is some code:
<esc>&u300D<esc>*t300R<esc>*p300x300Y<esc>*r3U<esc>*v2S<esc>*c300a300b5P<esc>*p600x300Y<esc>*r3U<esc>*v3S<esc>*c300a300b5P<esc>*p900x300Y<esc>*r3U<esc>*v1S<esc>*c300a300b5P
Here is the explanation:
<esc>&u300D<esc>*t300R -- set the Unit of Measure and Resolution (in this case 300 dpi)
<esc>*p300x300Y -- move cursor to 300x 300y (1 inch x 1 inch)
<esc>*r3U<esc>*v2S -- set the color palette to RGB and use color 2 (green)
<esc>*c300a300b5P -- draw a box that is 300 wide and 300 tall, use current fill pattern
<esc>*p600x300Y -- move cursor to 600x 300y
<esc>*r3U<esc>*v3S -- set the color palette to RGB use color 3 (yellow)
<esc>*c300a300b5P -- draw a box that is 300 wide and 300 tall, use current fill pattern
<esc>*p900x300Y -- move cursor to 900x 300y
<esc>*r3U<esc>*v1S -- set the color palette to RGB use color 1 (red)
<esc>*c300a300b5P -- draw a box that is 300 wide and 300 tall, use current fill pattern
Here are the other colors and palettes, keep in mind this is the simple way, you can specify your own RGB etc.
RGB Palette
<esc>*r3U<esc>*v1S - Red
<esc>*r3U<esc>*v2S - Green
<esc>*r3U<esc>*v3S - Yellow
<esc>*r3U<esc>*v4S - Blue
<esc>*r3U<esc>*v5S - Magenta
<esc>*r3U<esc>*v6S - Cyan
CMYK Palette
<esc>*r-3U<esc>*v1S - Cyan
<esc>*r-3U<esc>*v2S - Magenta
<esc>*r-3U<esc>*v3S - Blue
<esc>*r-3U<esc>*v4S - Yellow
<esc>*r-3U<esc>*v5S - Green
<esc>*r-3U<esc>*v6S - Red
<esc>*r-3U<esc>*v7S - Black
Problem Solved: The error of my thinking was that it was a difference between 300 dpi and 600 dpi so I was dividing by 2 and the answer appeared almost correct. The Real problem was a difference between 3oo dpi and 720 Decipoints. The real factor needed to be 2.4 and now it works perfectly.

Resources