Sg2.9
converting letters into colours
Recent RSS
converting letters into colours
From:  Linda Becker
Date:  22. October 2006, 16:51

I am working on a 'translation' project. The idea is to assign numbers to single letters, which can then be added together and converted into a colour using the computer.
Cant find stuff on how to best do that. Has anybody some advice or suggestions that could help to achieve that conversion.

Re: converting letters into colours
Date:  22. October 2006, 21:46

I would work it out on paper before you begin programming it.. Define the steps.. Define which values letters have.. Experiment in the color picker in Photoshop/Illustrator.

you could even do it in Excel..
Or what about 26 photoshop layers (layer names -> letters) with colors in them, by turning the different layers on and off you could create a color..
Or set up a paper based system to work things out..

When the system is working, scripting it could (depending on what you want to do) be relatively easy..

If you need someone to script it for you, work your idea out in detail first.

A little code to help you on your way:

This code converts 'abbcd' to:
red=8 green=10 blue=7

//the letters and their values
var alphabet = {
	a: {r:5,g:0,b:0},
	b: {r:0,g:5,b:0},
	c: {r:0,g:0,b:5},
	d: {r:3,g:0,b:2}
}

//change this variable to the word you want to convert
var translateMe = "abbcd";

var theColor={r:0,g:0,b:0};
var l = translateMe.length;

for(var i=0; i<l; i++){
	var letterColor=alphabet[translateMe[i]];
	theColor.r+=letterColor.r;
	theColor.g+=letterColor.g;
	theColor.b+=letterColor.b;
}

print("red="+theColor.r+" green="+theColor.g+" blue="+theColor.b)

The script is attached below, copy it into your Scriptographer scripts folder, reload the scripts, click on colortest.js and press play. The resulting value will be in the Scriptographer output window.

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Newton Curve 08.09.11