Skip to content

Instantly share code, notes, and snippets.

View badjano's full-sized avatar
💭
unity + python + c++

Badjano badjano

💭
unity + python + c++
View GitHub Profile
@badjano
badjano / audio_gen.py
Last active January 7, 2019 08:11
Generating, playing and saving audio
import wave
import numpy as np
import pyaudio
p = pyaudio.PyAudio()
volume = 0.5 # range [0.0, 1.0]
fs = 44100 # sampling rate, Hz, must be integer
duration = 2.0 # in seconds, may be float
f = 440.0 # sine frequency, Hz, may be float
@badjano
badjano / bezier_interpolator.cs
Last active August 25, 2017 22:06
Bezier Interpolator
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
[ExecuteInEditMode]
public class CurveTrackGenerator : MonoBehaviour
{
[SerializeField] private Color _color;
[SerializeField, Range(1f, 10f)] private float _momentum = 3;
@badjano
badjano / parallel_test.py
Created January 9, 2018 19:47
Simple example of threading using all cpu threads available
from threading import Thread, Lock
from multiprocessing import cpu_count
from queue import Queue
import math
import random
lock = Lock()
def do_work(name, t):
import requests
def generate_ppo(symbol="NEO", short=16, long=18, signal=9, persistence=2):
return {
"gekkoConfig": {
"watch": {
"exchange": "binance",
"currency": "BTC",
"asset": symbol
@badjano
badjano / quaternion_functions.shader
Created August 7, 2018 02:26
Quaternion GLSL functions
float4 qmul(float4 q1, float4 q2)
{
return float4(
q2.xyz * q1.w + q1.xyz * q2.w + cross(q1.xyz, q2.xyz),
q1.w * q2.w - dot(q1.xyz, q2.xyz)
);
}
float3 rotate_vector(float4 r, float3 v) {
@badjano
badjano / Cloud.shader
Created August 8, 2018 00:06
Unity cloud shader
Shader "ShaderMan/Clouds"
{
Properties{
_Color("Sky Color", Color) = (0.6, 0.7, 0.8, 1)
_CamPosition("Camera Position", Vector) = (0,0,0,0)
_CamRotation("Camera Rotation", Vector) = (0,0,0,0)
_Rotation("Camera Rotation", float) = 0
_Iterations("Cloud Iterations", Range(100,750)) = 170
@badjano
badjano / imgconvimg.py
Last active October 19, 2018 23:06
ImageConvolutionImage
from PIL import ImageFilter, Image
from math import floor, sqrt, tanh
from threading import Thread, Lock
from multiprocessing import cpu_count
from queue import Queue
import time
import pygame
lock = Lock()
q = Queue()
@badjano
badjano / threading.cs
Created October 30, 2018 03:49
Unity threading example
using System;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
public class TerrainChunk : MonoBehaviour
{
private MeshFilter _meshFilter;
private MeshCollider _meshColllider;
@badjano
badjano / pixel_sort.py
Created November 14, 2018 22:32
Pixel Sorting
import random
from PIL import ImageFilter, Image
import os
def randomize(data, width, height, chunk_count):
new_data = []
for i in range(height):
chunk = int(width / chunk_count)
for j in range(chunk_count):
@badjano
badjano / sprite_sheet.py
Created November 23, 2018 00:53
Sprite Sheet Patcher
from math import floor
from PIL import Image
def make_sprite_sheet(folder):
files = ["%s/bkfire%04d.png" % (folder, a) for a in range(1, 65)]
images = [Image.open(a) for a in files]
width, height = images[0].size