Skip to content

Instantly share code, notes, and snippets.

View EncodeTheCode's full-sized avatar
💭
Coding useful tools for workflow.

EncodeTheCode

💭
Coding useful tools for workflow.
View GitHub Profile
# pip install opencv-python ffmpeg-python
# pip install pyvirtualcam --prefer-binary
import cv2
import pyvirtualcam
from pyvirtualcam import PixelFormat
import os
import sys
VIDEO_PATH = 'my_broadcast.mp4' # Replace with your actual video path
import pygame
fps = 60
x0 = (0,0,0)
grey = (30,30,30)
res = [(256,224),(256,240),(320,224),(320,240),(352,240),(368,240),(384,224),(384,240),(512,224),(512,240),(640,224),(640,240),(320,480),(640,480),(800,600),(1024,768),(1280,800),(1280,900),(1366,768)]
cur_res = res[18]
class BitmapFont:
def __init__(self, font_image, char_width, char_height):
import pygame
fps = 60
x0 = (0,0,0)
grey = (30,30,30)
res = [(256,224),(256,240),(320,224),(320,240),(352,240),(368,240),(384,224),(384,240),(512,224),(512,240),(640,224),(640,240),(320,480),(640,480),(800,600),(1024,768),(1280,800),(1280,900),(1366,768)]
cur_res = res[18]
class BitmapFont:
def __init__(self, font_image, char_width, char_height):
import pygame
fps = 60
x0 = (0,0,0)
grey = (30,30,30)
res = [(256,224),(256,240),(320,224),(320,240),(352,240),(368,240),(384,224),(384,240),(512,224),(512,240),(640,224),(640,240),(320,480),(640,480),(800,600),(1024,768),(1280,800),(1280,900),(1366,768)]
cur_res = res[18]
class BitmapFont:
def __init__(self, font_image, char_width, char_height):
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height):
self.font_image = pygame.image.load(font_image).convert()
self.char_width = char_width
self.char_height = char_height
self.font_image.set_colorkey((0, 0, 0)) # Black = transparent
self.char_map = self.build_char_map()
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height):
self.font_image = pygame.image.load(font_image).convert()
self.char_width = char_width
self.char_height = char_height
self.font_image.set_colorkey((0, 0, 0)) # Black background made transparent
# Define the mapping from characters to their index in the bitmap
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height, chars_per_row, chars_per_col):
self.font_image = pygame.image.load(font_image) # Load the bitmap font image
self.char_width = char_width # Width of each character
self.char_height = char_height # Height of each character
self.chars_per_row = chars_per_row # How many characters per row in the bitmap
self.chars_per_col = chars_per_col # How many characters per column in the bitmap
self.char_map = self.create_char_map() # Map each character to a grid position in the bitmap
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height, num_chars):
self.font_image = pygame.image.load(font_image) # Load the bitmap font image
self.char_width = char_width # Width of each character
self.char_height = char_height # Height of each character
self.num_chars = num_chars # Total number of characters in the bitmap
self.character_images = self.extract_characters() # Extract and process each character
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Top-down Shadows with Gradient Fading and Interactive Lighting</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Top-down Shadows with Gradient Fading and Interactive Lighting</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>