File: rgb_random.py

package info (click to toggle)
caret 5.6.4~dfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 31,904 kB
  • ctags: 28,901
  • sloc: cpp: 378,050; python: 6,718; ansic: 5,507; makefile: 333; sh: 46
file content (32 lines) | stat: -rwxr-xr-x 772 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
#
# Create an RGB paint file with random colors
#
import os
import random
import sys

#
# Name of RGB Paint file and number of nodes in the file
#
rgbPaintFileName = "random.RGB_paint"
numberOfNodes    = 71723

#
# Create an RGB paint file with random colors
#
file = open(rgbPaintFileName, 'w')
file.write("tag-version " + str(2) + "\n")
file.write("tag-number-of-nodes " + str(numberOfNodes) + "\n")
file.write("tag-number-of-columns  " + str(1) + "\n")
file.write("tag-BEGIN-DATA\n");
for i in range(numberOfNodes): 
   node  = str(i)
   red   = str(random.random() * 255.0)
   green = str(random.random() * 255.0)
   blue  = str(random.random() * 255.0)
   line = node + " " + red + " " + green + " " + blue + "\n"
   file.write(line)

file.close()