This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import os | |
def crop_image_to_square(img_path, output_path): | |
with Image.open(img_path) as img: | |
width, height = img.size | |
size = min(width, height) | |
left = (width - size) / 2 | |
top = (height - size) / 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
import os | |
# rename the input xml file to gamelist~.xml | |
if os.path.exists('gamelist.xml'): | |
os.rename('gamelist.xml', 'gamelist~.xml') | |
# parse the input xml file (now gamelist~.xml) | |
tree = ET.parse('gamelist~.xml') | |
root = tree.getroot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add these two lines to the top of any imported module | |
from py5 import * | |
cs = get_current_sketch() | |
class Amoeba(): | |
def __init__(self, x, y): | |
self.location = Py5Vector(x, y) | |
def display(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add these two lines to the top of any imported module | |
from py5 import * | |
cs = get_current_sketch() | |
class Amoeba(): | |
def __init__(self, x, y): | |
self.location = Py5Vector(x, y) | |
def display(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
TO BEGIN: | |
1. download the web xr emulator plugin for firefox/chrome: | |
* https://addons.mozilla.org/en-US/firefox/addon/webxr-api-emulator/ | |
* https://chrome.google.com/webstore/detail/webxr-api-emulator/ | |
mjddjgeghkdijejnciaefnkjmkafnnje | |
2. run an https web server using servez: https://greggman.github.io/servez/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
processing.py sketch based on: | |
https://natureofcode.com/book/chapter-9-the-evolution-of-code/ | |
''' | |
#1. TEST OUT STRING MODULE ################################################### | |
import string | |
print(string.ascii_letters) | |
print(string.ascii_letters[25]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# live version: | |
# https://editor.computiful.org/tabreturn/sketches/F6dumhqW0 | |
class Amoeba(object): | |
def __init__(self, x, y): | |
print('amoeba initialized') | |
self.x = x | |
self.y = y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
up_pressed = False | |
left_pressed = False | |
down_pressed = False | |
right_pressed = False | |
x = 150 | |
y = 150 | |
speed = 5 | |
def setup(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# mp4museum.org by julius schmiedel 2019 | |
import os | |
import sys | |
import glob | |
from subprocess import Popen, PIPE | |
import RPi.GPIO as GPIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://en.wikipedia.org/wiki/3D_projection#Perspective_projection | |
from rotations import * | |
# pyramid coordinates | |
a1 = [0.0, 0.0, 50.0] # the 3D position of a point A that is to be projected | |
a2 = [0.0, 100.0, 50.0] | |
a3 = [100.0, 100.0, 50.0] | |
a4 = [100.0, 0.0, 50.0] | |
a5 = [50.0, 50.0, 125.0] |
NewerOlder