random background image

  • /*
     * @title random background image
     * @description 
     * @include http://*
     * @license MIT License
     */
    
    setInterval(function(style, canvas){
      canvas.setAttribute("width", 10);
      canvas.setAttribute("height", 10);
    
      var context = canvas.getContext("2d");
    
      for(var y = 0; y < 10; y++) for(var x = 0; x < 10; x++){
        context.fillStyle = "rgb(" + [
          (Math.random() * 255) >> 0,
          (Math.random() * 255) >> 0,
          (Math.random() * 255) >> 0
        ] + ")";
        context.fillRect(x, y, x + 1, y + 1);
      }
    
      style.backgroundPosition = "repeat";
      style.backgroundImage = "url('" + canvas.toDataURL() + "')";
    }, 1000, document.body.style, document.createElement("canvas"));
    void(0);
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/05/16 00:43:45 - 2010-05-16
  2. 2010/05/16 00:37:57 - 2010-05-16