Skip to content

Instantly share code, notes, and snippets.

@matsurai25
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save matsurai25/0f5457989eb3db61bcf7 to your computer and use it in GitHub Desktop.

Select an option

Save matsurai25/0f5457989eb3db61bcf7 to your computer and use it in GitHub Desktop.
// 配列の中からランダムな色を出す処理
// 16進数のカラーコードを[1,1,1,1]の形に直す
function color16(rgb){
c = 1/256;
red =parseInt(rgb.substring(0, 2), 16);
green =parseInt(rgb.substring(2, 4), 16)
blue =parseInt(rgb.substring(4, 6), 16)
return [c*red,c*green,c*blue,1];
}
// 適当なカラーコードの配列
ColorArray = ["f25076","f05187","836FFF","ff89aa","fd5939","ffc6d6"];
//ランダムに選ぶ
max = ColorArray.length-1;
key = Math.round(random(0,max));
//出力
color16(ColorArray[key])
//フレームのランダムカラー取得
var RandomColor = comp("_global").layer("gData").effect("RandomColor")("カラー")
//デフォルト(白)
var c = [1,1,1,1];
if(time>outPoint-3){
//終了3秒前
var key = (outPoint-time)/3;
c[0] = key;
c[1] = RandomColor[1]+key;
c[2] = RandomColor[2]+key;
c[3] = RandomColor[3]+key;
}else if(time>inPoint+3){
//2秒以降は白に
c = [1,1,1,1]
}else if(time>inPoint+2){
//2秒以降は徐々に白に
var key = time-2;
c[0] = key;
c[1] = RandomColor[1]+key;
c[2] = RandomColor[2]+key;
c[3] = RandomColor[3]+key;
}else if(time>inPoint+1){
//1秒以降はR切って青に
c[0] = 0;
c[1] = RandomColor[1];
c[2] = RandomColor[2];
c[3] = RandomColor[3];
}
//出力
c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment