Converting from integers to output

Krista Bailie bailies at telus.net
Wed Jul 14 01:55:49 EDT 2004


I'm sure this is so easy that it will hurt for anyone to read it, but I
really need some direction.  I'm trying to create a color chart (RGB) that
shows steps between two different colors as entered by the user.  I know the
web script must convert the values into integers, store them as variables
and then output them, but I cannot seem to establish the calculation for
this.  I'm attaching the html I've got, that works when the page is static,
and I know I need to create a fraction for each color by using the formula,
fraction = (i+1.0)/nsteps
r = (1-fraction)*red1 + fraction*red2

but the program won't recognize i... anyway, here is the html...if anyone
can give me any help I'd be so grateful!!

Thanks,
Krista

import cgi
form = cgi.FieldStorage()
print "Content-type: text/html"
print
print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Colour Blend</title>
<style type="text/css">
#blend {
  width: 10em;
  padding: 0;
  border: 1px solid black;
  margin-left: 3em;
}
.colourblock {
  width: 10em;
  height: 1em;
}
</style>
</head>
<body>
<h1>Colour Blend</h1>

<p>
Here is a mix of the two colours you specified:
</p>
<div id="blend">

<div class="colourblock" style="background-color: rgb(100.0%,10.0%,10.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,20.0%,20.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,30.0%,30.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,40.0%,40.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,50.0%,50.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,60.0%,60.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,70.0%,70.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,80.0%,80.0%)">
</div>
<div class="colourblock" style="background-color: rgb(100.0%,90.0%,90.0%)">
</div>
<div class="colourblock" style="background-color:
rgb(100.0%,100.0%,100.0%)"> </div>

</div>

</body>
</html>"""









More information about the Python-list mailing list