Hi can somebody help me randomize shapes within a loop ?



  • Hi Community
    I would wish that every shape in the loop is unique and not repeated

    is that somehow possible ?
    cheers david

    size(2000,2000)
    x,y=1000,1000
    ranp1= randint(-1000,1000)
    ranp2=randint(-1000,1000)
    ranp3=randint(-1000,1000)
    ranp4=randint(-1000,1000)
    ranp5=randint(-1000,1000)
    ranp6=randint(-1000,1000)
    ranp7=randint(-1000,1000)
    ranp8=randint(-1000,1000)
    ranp9=randint(-1000,1000)
    ranp10=randint(-1000,1000)
    ranp11=randint(-1000,1000)
    ranp12=randint(-1000,1000)
    ranp13=randint(-1000,1000)
    ranp14=randint(-1000,1000)
    ranpc=randint(-1000,1000)
    ranpc1=randint(-1000,1000)
    ranpc2=randint(-1000,1000)
    distance = 22
    
    
    
    
    
    translate(x, y)
    
    for i in range (43):
        
        translate(0,+i*distance)
        
        fill(ranpc,ranpc1,ranpc2,0.2)
        # create a new empty path
        newPath()
        # set the first oncurve point
        moveTo((0, 0))
        # line to from the previous point to a new point
        lineTo((ranp1, ranp2))
        lineTo((ranp4, ranp5))
    
        # curve to a point with two given handles
        curveTo((ranp6, ranp7), (ranp8, ranp9), (ranp10, ranp11))
    
        # close the path
        closePath()
        # draw the path
        drawPath()
    
    

  • admin

    He David

    you need to call randint in side the for loop to get a random number each time, instead you asked for a randint once! at the beginning and you are reusing that number

    for i in range(10):
        print(randint(-1000, 1000))
    

    good luck!



  • Cool thanks for your help !
    Iam really struggling to find the right information in the reference