Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
unity and python is all a man needs

Badjano badjano

💭
unity and python is all a man needs
View GitHub Profile
@badjano
badjano / bezier_interpolator.cs
Last active Aug 25, 2017
Bezier Interpolator
View bezier_interpolator.cs
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 Jan 9, 2018
Simple example of threading using all cpu threads available
View parallel_test.py
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):
View backtest_compare.py
import requests
def generate_ppo(symbol="NEO", short=16, long=18, signal=9, persistence=2):
return {
"gekkoConfig": {
"watch": {
"exchange": "binance",
"currency": "BTC",
"asset": symbol
View quaternion_functions.shader
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 / imgconvimg.py
Last active Oct 19, 2018
ImageConvolutionImage
View imgconvimg.py
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 Oct 30, 2018
Unity threading example
View threading.cs
using System;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
public class TerrainChunk : MonoBehaviour
{
private MeshFilter _meshFilter;
private MeshCollider _meshColllider;
@badjano
badjano / sprite_sheet.py
Created Nov 23, 2018
Sprite Sheet Patcher
View sprite_sheet.py
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
@badjano
badjano / kmeans_palette.py
Last active Dec 14, 2018
Finding palette from image using K-Means Clustering
View kmeans_palette.py
import random
from PIL import ImageDraw, Image
from statistics import median
max_dist = pow(255, 2) + pow(255, 2) + pow(255, 2)
global_power = (2, 2, 2)
def avg(arr):
return sum(arr) / len(arr)
@badjano
badjano / audio_gen.py
Last active Jan 7, 2019
Generating, playing and saving audio
View audio_gen.py
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 / Cloud.shader
Created Aug 8, 2018
Unity cloud shader
View 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