Skip to content

Instantly share code, notes, and snippets.

@omaraflak
Last active September 26, 2023 11:42
Show Gist options
  • Save omaraflak/2e8e7042e1b388a65bbfea6aa93658c6 to your computer and use it in GitHub Desktop.
Save omaraflak/2e8e7042e1b388a65bbfea6aa93658c6 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
width = 300
height = 200
camera = np.array([0, 0, 1])
ratio = float(width) / height
screen = (-1, 1 / ratio, 1, -1 / ratio) # left, top, right, bottom
image = np.zeros((height, width, 3))
for i, y in enumerate(np.linspace(screen[1], screen[3], height)):
for j, x in enumerate(np.linspace(screen[0], screen[2], width)):
# image[i, j] = ...
print("progress: %d/%d" % (i + 1, height))
plt.imsave('image.png', image)
@happyleibniz
Copy link

the png is black

@omaraflak
Copy link
Author

omaraflak commented Sep 6, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment