from reportlab.graphics.shapes import *
my_path='G:\\My drive\\testing\\pypdf2\\my_pdf.pdf'
d=Drawing(600,600)
import random
for rd in range(0,300,10):
if(rd%20==0):
d.add(Circle(300,300,300-rd,fillColor=[1,0,0]))
else:
d.add(Circle(300,300,300-rd,fillColor=[0,1,0]))
from reportlab.graphics import renderPDF
renderPDF.drawToFile(d,my_path,'')
from reportlab.graphics.shapes import *
my_path='G:\\My drive\\testing\\pypdf2\\my_pdf.pdf'
d=Drawing(1200,1200)
import random
for rd in range(0,600,20):
r=random.random()
g=random.random()
b=random.random()
d.add(Circle(600,600,600-rd,fillColor=[r,g,b]))
from reportlab.graphics import renderPDF
renderPDF.drawToFile(d,my_path,'')

w,h=620,620
Full code is here.
from reportlab.graphics.shapes import *
my_path='G:\\My drive\\testing\\pypdf2\\my_pdf.pdf'
w,h=620,620
d = Drawing(w,h)
import random
for rd in range(0,int(w/2),20):
r=random.uniform(0,1)
g=random.uniform(0,1)
b=random.uniform(0,1)
d.add(Rect(rd, rd, w-(rd*2), h-(rd*2), fillColor=[r,g,b]))
from reportlab.graphics import renderPDF
renderPDF.drawToFile(d, my_path, '')
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.