Advertisement
jamespharaoh

grid-of-greys.py

Nov 20th, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. #!/bin/env python3
  2. print ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>")
  3. print ("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">")
  4. print ("<svg width=\"17.6mm\" height=\"17.6mm\" viewBox=\"0 0 17.6mm 17.6mm\" xmlns=\"http://www.w3.org/2000/svg\">")
  5. for y in range (16):
  6.         for x in range (16):
  7.                 value = 255 - y * 16 - x
  8.                 fill = f"#{value:02x}{value:02x}{value:02x}"
  9.                 print (f"<rect x=\"{x * 1.1}mm\" y=\"{y * 1.1}mm\" width=\"1.1mm\" height=\"1.1mm\" fill=\"{fill}\"/>")
  10. print ("</svg>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement