Skip to content

Instantly share code, notes, and snippets.

@VictorWesterlund
Last active January 26, 2021 00:31
Show Gist options
  • Save VictorWesterlund/b4f279d45708196a92a4ddc7a677ff44 to your computer and use it in GitHub Desktop.
Save VictorWesterlund/b4f279d45708196a92a4ddc7a677ff44 to your computer and use it in GitHub Desktop.
Generate a signed HEX video tape for crtjs using random RGB values
import random
def rand():
dec = random.randint(0,255)
tohex = str(hex(dec).split("x")[-1])
if(dec < 16):
tohex = "0" + tohex
return tohex
def randomColor():
pixel = rand() + rand() + rand()
return f"\"#{pixel}\""
# ----
file = open("data.json","a+")
file.write("[")
# 3 Seconds of 64x64px@10fps uncompressed video (~7MB)
for x in range(737280):
file.write(randomColor() + ",")
file.write(randomColor())
file.write("]")
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment