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/env python | |
import pygame | |
import math | |
def draw_aacircle(surface, color, pos, radius, width=0): | |
r, g, b = color | |
position_x, position_y = pos | |
alpha_max = 255 |
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
""" Run a task in a background thread. | |
python3 -m pip install tornado --user | |
python3 tornado_thread.py | |
curl http://localhost:8888/2 | |
See `run_on_executor` documentation: | |
https://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.run_on_executor | |
See for another approach: |
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/env python | |
# like the testsprite.c that comes with sdl, this pygame version shows | |
# lots of sprites moving around. | |
import pygame, sys, os | |
from pygame.locals import * | |
from random import randint | |
from time import time | |
import gc | |
import pygame.joystick |
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
""" | |
Show a light for every beat. | |
Show the BPM as text. | |
Use 4/4 timing. Four beats to a bar. | |
Press space until the BPM gets to what you want. | |
""" | |
import time | |
import os | |
import pygame as pg |
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
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c | |
index b4ad6c7..2d50486 100644 | |
--- a/src/audio/SDL_wave.c | |
+++ b/src/audio/SDL_wave.c | |
@@ -445,7 +445,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc, | |
} | |
/* 2 Uint32's for chunk header+len, plus the lenread */ | |
headerDiff += lenread + 2 * sizeof(Uint32); | |
- } while ( (chunk.magic == FACT) || (chunk.magic == LIST) ); | |
+ } while ( (chunk.magic == FACT) || (chunk.magic == LIST) || (chunk.magic == BEXT) ); |
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
class Portmidi < Formula | |
desc "Cross-platform library for real-time MIDI I/O" | |
homepage "https://sourceforge.net/projects/portmedia/" | |
url "https://downloads.sourceforge.net/project/portmedia/portmidi/217/portmidi-src-217.zip" | |
sha256 "08e9a892bd80bdb1115213fb72dc29a7bf2ff108b378180586aa65f3cfd42e0f" | |
revision 1 | |
bottle do | |
cellar :any | |
sha256 "c8f2755fd775064c282da84d666336d9125c6e70082975ffdc0867dee60b5802" => :high_sierra |
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 os | |
import pygame as pg | |
main_dir = os.path.split(os.path.abspath(__file__))[0] | |
# data_dir = os.path.join(main_dir, 'data') | |
data_dir = main_dir | |
def show(image): | |
screen = pg.display.get_surface() | |
screen.fill((0, 255, 255)) |
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
""" Some examples for generating and converting sounds for pygame. | |
Python 2.7, 3.6 | |
Shows: | |
- a simple 'square wave' generated | |
- resampling sample rates (eg, 8363 to 44100) | |
- using built in python array for making pygame.Sound samples. | |
- samples at different bit sizes | |
- converting from signed 8 to signed 16bit |
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 pygame | |
pygame.init() | |
pygame.display.set_mode((500, 400), 0, 32) | |
while True: | |
for event in pygame.event.get(): | |
print(event) |
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
#circle.py | |
import pygame | |
def draw_outlined_circle2(surf, color, origin, radius, thickness): | |
width = radius * 2 + thickness * 2 | |
background = (0, 0, 0, 0) | |
circle = pygame.Surface((width, width)).convert_alpha() | |
rect = circle.get_rect() | |
circle.fill(background) | |
pygame.draw.circle(circle, color, rect.center, radius) |