Skip to content

Instantly share code, notes, and snippets.

@abarth500
Created May 30, 2012 02:16
Show Gist options
  • Save abarth500/2832860 to your computer and use it in GitHub Desktop.
Save abarth500/2832860 to your computer and use it in GitHub Desktop.
receiver on JavaScript
//メッセージはココで受信
//チャンネル削除
msg = msg.substring(msg.indexOf(":")+1);
//カンマで分けて配列へ
fields = msg.split(",");
//注:サーバから来たデータは文字列として扱われているため、
//数値を送った場合使用時はparseInt等で数値化する。
if(X > -1){
ctx.strokeStyle = 'rgb(254, 254, 254)';
ctx.beginPath();
ctx.moveTo(X, Y);
ctx.lineTo(parseInt(fields[0]), parseInt(fields[1]));
/* 三角形を線で描画 */
ctx.stroke();
}
X = parseInt(fields[0]);
Y = parseInt(fields[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment