File: random_image.py

package info (click to toggle)
mapnik 3.1.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,548 kB
  • sloc: cpp: 144,430; python: 30,187; sh: 797; makefile: 172; xml: 140; lisp: 13
file content (15 lines) | stat: -rw-r--r-- 390 bytes parent folder | download | duplicates (5)
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 range(im.width()):
    for y in range(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')