Skip to content

Instantly share code, notes, and snippets.

View jhorikawa's full-sized avatar

Junichiro Horikawa jhorikawa

View GitHub Profile
@jhorikawa
jhorikawa / VertexColor.shader
Created January 15, 2018 18:39
Unity Shader to visualize vertex color.
Shader "Custom/VertexColor" {
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
#pragma target 3.0
struct Input {
@jhorikawa
jhorikawa / GearGH.cs
Created February 23, 2018 16:48
Grasshopper C# component script for gear simulation.
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
/// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
/// <param name="text">String to print.</param>
private void Print(string text) { /* Implementation hidden. */ }
/// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
/// <param name="format">String format.</param>
/// <param name="args">Formatting parameters.</param>
private void Print(string format, params object[] args) { /* Implementation hidden. */ }
@jhorikawa
jhorikawa / Scanner.cs
Created January 22, 2018 17:27
Unity script for document scanning using OpenCVForUnity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using OpenCVForUnity;
public class Scanner : MonoBehaviour {
public Texture2D baseTexture;
public RawImage sourceRawImage;
public RawImage targetRawImage;
@jhorikawa
jhorikawa / gaussianblur2d.c
Created February 19, 2020 19:45
2D Gaussian Blur for Houdini using VEX
float sigma = chf("sigma");
int res = chi("res");
int resx = chi("resx");
int resy = chi("resy");
int resn = floor(res / 2.0);
float weightTotal = 0;
float valTotal = 0;
for(int i=-resn; i<=resn; i++){
for(int n=-resn; n<=resn; n++){
float ix = @ptnum % resx + i;
@jhorikawa
jhorikawa / getPinterestBoardPins.py
Last active March 9, 2023 21:32
Download Pinterest images from specific board using Python.
import pprint
import requests
import os
from urllib.request import urlopen
accessToken = "xxxxxxxxxx"
boardId = "0000000000"
folderPath = "./images"
response = requests.get(
@jhorikawa
jhorikawa / SphereDivide.cs
Created February 28, 2023 09:41
C# code for Grasshopper to divide surface with angle parameter.
private void RunScript(double ang, ref object A)
{
double dang = ang * Math.PI / 180.0;
int div1 = (int) Math.Round(Math.PI / dang);
List<Point3d> points = new List<Point3d>();
for(int i = 0; i < div1; i++){
@jhorikawa
jhorikawa / ripple.c
Created February 21, 2020 05:58
Ripple pattern on surface using VEX.
float val = noise(@P * chf("smoothness") + chf("seed"));
float ang = val * $PI * chf("num_wave");
float tval = fit(sin(ang), -1.0, 1.0, 0, 1.0);
@Cd = set(tval, tval, tval);
@P += @N * fit(tval, 0, 1.0, 0, chf("offset"));
@jhorikawa
jhorikawa / spiral.lua
Created November 13, 2020 15:09
PICO-8 source code to create animated spiral.
r=64
t=0
function _draw()
cls(1)
for n=0,6,1 do
for i=0,100,1 do
ang=3.1415/180.0*2
x1=cos((i+t)*ang)*i+r
y1=sin((i+t)*ang)*i+r
x2=cos((i+1+t)*ang)*(i+1)+r
@jhorikawa
jhorikawa / circlegrid.lua
Last active November 13, 2020 15:04
PICO-8 source code to create circle grid motion graphics.
r=128
t=0
num=4
rad=9
sp=0.5
function _draw()
cls(13)
val=sin(330/360)
nnum=ceil(num/val)
for i=0,num do
@jhorikawa
jhorikawa / orangepeel.lua
Created November 13, 2020 15:02
PICO-8 source code to create orange peel like motion graphics.
r=64
function _draw()
cls(1)
--print("abc")
num=200.0
rad=50
xss={}
yss={}
sep=3