kirakira
by
arikui
2010-05-24 [2010/05/24 02:52:03]
kirakira
@@ -7,27 +7,27 @@
* @require http://github.com/arikui/image_processing.js/raw/master/image_processing.js
*/
-setInterval(function(style, images){
+setInterval(function(style, canvas){
var ip = arguments.callee.ip;
- if(!ip) for(var i = -1; image = images[++i];){
- try{
- ip = ImageProcessing.load(image.src);
- arguments.callee.ip = ip;
- break;
- }
- catch(e){}
+ if(!ip){
+ canvas.width = canvas.height = "3";
+ ip = new ImageProcessing(canvas);
+ arguments.callee.ip = ip;
+
+ ip.lock().each(function(px, x, y, self){
+ self.setPixel(x, y, ImageProcessing.Color.fromHex((Math.random() * 255 * 255 * 255) >> 0));
+ }).unlock().update();
}
- ip.lock().setEach(function(px){
+ ip.lock().each(function(px, x, y, self){
px = px.hsv();
- px[0] = (px[0] + 1) % 359;
- return ImageProcessing.Color.fromHsv.apply(px);
+ self.setPixel(x, y, ImageProcessing.Color.fromHsv((px[0] + 1) % 359, px[1], px[2]));
}).unlock().update();
style.backgroundPosition = "repeat";
style.backgroundImage = "url('" + ip.data() + "')";
}, 1000,
document.body.style,
- document.getElementsByTagName("img"));
+ document.createElement("canvas"));
void(0);
/*
* @title bookmarklet
* @description my bookmarklet
* @include http://*
* @license MIT License
* @private
* @require http://github.com/arikui/image_processing.js/raw/master/image_processing.js
*/
setInterval(function(style, canvas){
var ip = arguments.callee.ip;
if(!ip){
canvas.width = canvas.height = "3";
ip = new ImageProcessing(canvas);
arguments.callee.ip = ip;
ip.lock().each(function(px, x, y, self){
self.setPixel(x, y, ImageProcessing.Color.fromHex((Math.random() * 255 * 255 * 255) >> 0));
}).unlock().update();
}
ip.lock().each(function(px, x, y, self){
px = px.hsv();
self.setPixel(x, y, ImageProcessing.Color.fromHsv((px[0] + 1) % 359, px[1], px[2]));
}).unlock().update();
style.backgroundPosition = "repeat";
style.backgroundImage = "url('" + ip.data() + "')";
}, 1000,
document.body.style,
document.createElement("canvas"));
void(0);
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。