2

I have experimented with this pattern but I would like to assign a percent of how much sign '+' will appear. Ways that I have found to do this are related to numbers and I'm having a hard time getting an idea of how to do this.

This is my code... Let's say that I want to sign '+' to appear 20% and a sign '-' to appear 80% but still to be random distribution.

from PIL import Image, ImageDraw
import operator, random

im = Image.new('RGBA', (2000, 2000), (0,0,0)) 
draw = ImageDraw.Draw(im)

operator = {
    '+': operator.add,
    '-': operator.sub
}
step = 50
w, h = im.size
for n in range (step-step,w+w,step):
    for x in range (step-step,h+h,step):
        z = random.choice(list(operator.keys()))
        line = draw.line((n+100,x,n,operator[z](x,100)), fill=(255,255,255), width=4)
im

Thanks in advance!

Firefoxer
  • 265
  • 3
  • 15

0 Answers0