File: random_image.py

package info (click to toggle)
mapnik 3.0.22%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 17,260 kB
  • sloc: cpp: 144,587; python: 1,426; sh: 785; makefile: 170; xml: 140; lisp: 13
file content (15 lines) | stat: -rw-r--r-- 396 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import mapnik
import random

im = mapnik.Image(256,256)

for x in xrange(0,im.width()):
    for y in xrange(0,im.height()):
        r = int(random.random() * 255)
        g = random.random() * 255
        b = random.random() * 255
        a = random.random()
        color = mapnik.Color('rgba(%i,%i,%i,%f)' % (r,g,b,a))
        im.set_pixel(x,y,color)

im.save('./benchmark/data/multicolor.png')