Skip to content

Instantly share code, notes, and snippets.

View spacekitcat's full-sized avatar
👋

Lisa Burton spacekitcat

👋
View GitHub Profile
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import os
# The range of images to generate, which also controls the number of gradient 'stops'
imageCount = 30
# How far to increment red for each image, currently tied to imageCount as you can see
colorIncrement = 255 / imageCount
# Output folder for the images
@spacekitcat
spacekitcat / naive-ray-tracer-00.py
Last active February 28, 2021 16:23
Naive ray tracer implementation 00. It renders two spheres with inverted z values, the z value goes between 0 and 15, simulating a bounce effect.
import pygame as pg
import numpy as np
def is_exit_key(e):
return e.type == pg.KEYUP and (e.key == pg.K_ESCAPE or e.key == pg.K_q)
class GameObject:
def __init__(self, position, colour):
self.position = position
@spacekitcat
spacekitcat / music_note_distance_trainer.py
Created October 2, 2021 19:37
Learning tool designed to drill the user on the distance between random note pairs to help reinforce a sense of scale geometry.
import random
def get_notes():
return ['c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#', 'b']
def get_note_pair():
x = random.choice(range(0, len(get_notes()) - 1))
y = random.choice(range(x+1, len(get_notes())))
@spacekitcat
spacekitcat / index.html
Last active January 20, 2023 15:25
Microphone input audio visualisation demo
<html>
<!--
Performs a continuous FFT on the audio signal from the microphone and renders a simple
HTML bar chart every 50ms (although only if the signal is beyond a threshold).
License: MIT
-->
<head>
<title>Audio spectrum visualisation demo</title>
<style>
from collections import deque
CHROMATIC_SCALE = deque(['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'])
MAJOR=[0, 2, 4, 5, 7, 9, 11]
MINOR=[0, 2, 3, 5, 7, 8, 10]
def printScaleLine(scale):
scaleOutputString=''
for x in scale:
scaleOutputString = scaleOutputString + x.ljust(3)