Canvas で遊んでみる 3

昨日の 画像回転 bookmarklet を 0度から360度の任意の値に対応した。

javascript:(function(){var l=location.href;var deg=prompt("0-360","");location.href='data:text\/html;charset=utf8,<html><head><script type="text\/javascript" src="http:\/\/labo.higeorange.com\/js\/rotate.js"><\/script><\/head><body onload="draw(\''+l+'\','+deg+')"><canvas id="canvas"><\/canvas><\/body><\/html>'})();


JavaScript の部分が長くなったので外部化している。
http://labo.higeorange.com/js/rotate.js

使いかた

画像を開いた状態で上記のブックマークレットを発動させると プロンプトがでるので回転させたい値を入力。ただし 0 〜 360 の間の値。



三角関数つかうなんて久しぶり過ぎて混乱しまくった。

追記

opera.postError() を消しわすれてため Firefox でうまく動かない問題を修正。