Skip to content

Instantly share code, notes, and snippets.

@AfroThundr3007730
Created March 14, 2023 01:49
Show Gist options
  • Save AfroThundr3007730/c693fa16f081734eb2f5ad01df79bbe3 to your computer and use it in GitHub Desktop.
Save AfroThundr3007730/c693fa16f081734eb2f5ad01df79bbe3 to your computer and use it in GitHub Desktop.
Draws a grid of conigurable size
#!/usr/bin/python
from PIL import Image
def draw_grid(size_x=1920, size_y=1080, grid_x=3, grid_y=3, border=2, img_x=0, img_y=0):
if img_x == 0 or img_y == 0:
img_x, img_y = size_x, size_y
img = Image.new('RGB', (img_x, img_y), 'white')
pixels = img.load()
tile_x = size_x / grid_x
tile_y = size_y / grid_y
for x in range(img.size[0]):
for y in range(img.size[1]):
if (x % tile_x <= border or tile_x - x % tile_x <= border or
y % tile_y <= border or tile_y - y % tile_y <= border):
pixels[x, y] = (0, 0, 0)
if x >= size_x or y >= size_y:
pixels[x, y] = (127, 127, 127)
img.show()
draw_grid(3840, 2112, 3, 3, 1, 3840, 2160)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment