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 / gist:5559283
Last active March 1, 2020 02:12
[Illustrator][JavaScript] アンカーポイントとコントロールポイントの座標(3次ベジェ)をJSONで書き出す
(function () {
$.writeln('----------------------------------------');
var layer = app.activeDocument.activeLayer;
// アクティブドキュメント取得しておく
var actDoc = activeDocument;
var sel = actDoc.selection;
@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 / gist:5840156
Last active January 30, 2016 16:54
[Objective-C] カメラロールからムービーを選択する
/*--------------------------------------------------------------------------------
カメラロールからムービーを選択する
--------------------------------------------------------------------------------*/
- (void)chooseMovie{
// フォトライブラリが使えるか確認
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
// 使える
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
@ikekou
ikekou / gist:6493006
Created September 9, 2013 08:37
[Objective-C] 1回だけ使うタイマーみたいな書き方
[self performSelector:@selector(timerHandler) withObject:nil afterDelay:1.0];
@ikekou
ikekou / gist:5992631
Created July 13, 2013 23:55
[jade][php] jadeでhtmlタグとかphpタグとか、エンコードしたくないものを書く場合
// !が重要。テキスト部分に関しては特に何もしなくても大丈夫。属性値部分は=だけだとエンコードされちゃう。
a(href!='<?php echo $foo; ?>') <?php echo $foo; ?>