Skip to content

Instantly share code, notes, and snippets.

// Draw Line https://www.shadertoy.com/view/4ljfRD
float drawLine (vec2 p1, vec2 p2, vec2 uv, float a)
{
float r = 0.;
float one_px = 1. / iResolution.x; //not really one px
// get dist between points
float d = distance(p1, p2);
// https://thebookofshaders.com/12/?lan=jp
vec2 random2( vec2 p ) {
return fract(sin(vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))))*43758.5453);
}
// https://thebookofshaders.com/edit.php#11/2d-snoise-clear.frag
vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); }
//
// Description : GLSL 2D simplex noise function
// Author : Ian McEwan, Ashima Arts
// Maintainer : ijm
vec2 random2(vec2 st){
st = vec2( dot(st,vec2(127.1,311.7)),
dot(st,vec2(269.5,183.3)) );
return -1.0 + 2.0*fract(sin(st)*43758.5453123);
}
// Gradient Noise by Inigo Quilez - iq/2013
// https://www.shadertoy.com/view/XdXGW8
float noise2(vec2 st) {
vec2 i = floor(st);
@ikekou
ikekou / closestXY.js
Last active May 19, 2020 03:44
get closest point on line with specific point
function closestXY(x0,y0,x1,y1, mx, my) {
var dx = x1 - x0;
var dy = y1 - y0;
var t = ((mx - x0) * dx + (my - y0) * dy) / (dx * dx + dy * dy);
t = Math.max(0, Math.min(1, t));
var x = lerp(x0, x1, t);
var y = lerp(y0, y1, t);
@ikekou
ikekou / CDN
Created April 14, 2015 07:36
[JavaScript][CoffeeScript] stats.js貼り付け用
https://cdnjs.cloudflare.com/ajax/libs/stats.js/r11/Stats.min.js
@ikekou
ikekou / header.php
Last active September 20, 2018 00:27
[WordPress] OGP
<!-- ここからOGP -->
<meta property="og:type" content="blog">
<?php
if (is_single()){//単一記事ページの場合
if(have_posts()): while(have_posts()): the_post();
echo '<meta property="og:description" content="'.get_post_meta($post->ID, _aioseop_description, true).'">';echo "\n";//抜粋を表示
endwhile; endif;
echo '<meta property="og:title" content="'; the_title(); echo '">';echo "\n";//単一記事タイトルを表示
echo '<meta property="og:url" content="'; the_permalink(); echo '">';echo "\n";//単一記事URLを表示
} else {//単一記事ページページ以外の場合(アーカイブページやホームなど)
@ikekou
ikekou / sample.css
Created March 28, 2015 03:59
[css] 游書体の指定をするCSS
/* 游ゴシック体 */
.sans-serif {
font-family: "游ゴシック体", "Yu Gothic", YuGothic, sans-serif;
}
/* 游明朝体 */
.serif {
font-family: "游明朝体", "Yu Mincho", YuMincho, serif;
}
@ikekou
ikekou / sample.js
Last active August 29, 2015 14:17
[javascript] requestAnimationFrameのベンダプリフィクス対応のスニペット
(function (w, r) {
w['r'+r] = w['r'+r] || w['webkitR'+r] || w['mozR'+r] || w['msR'+r] || w['oR'+r] || function(c){ w.setTimeout(c, 1000 / 60); };
})(window, 'equestAnimationFrame');
@ikekou
ikekou / index.html
Created March 24, 2015 18:31
[javascript] jQueryの読み込み
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script> (window.jQuery || document .write('<script src="js/jquery-1.11.2.min.js"><\/script>')); </script>