define(function(require) {
    var init = require('init');

    var draw = require('./draw');
    var fill = require('./fill');
    var selectArea = require('./selectArea');
    var copy = require('./copy');
    var paste = require('./paste');
    var loadImage = require('./loadImage');
    var colors = document.getElementById('colors').childNodes;
    for (var i = 0, color; color = colors[i]; i++) {
        if (color.nodeName.toLowerCase() != 'div') continue;
        color.addEventListener('click', function (e) {
            var style = e.target.getAttribute('style');
            var color = style.match(/background:(#......)/)[1];
            context.strokeStyle = color;
            context.fillStyle = color;
        },false);
    };


    var canvas = init.getCanvas();
    var context = init.getContext();

    // canvasに対する操作
    // draw関係
    canvas.addEventListener('mousedown', function() {
        draw.mouseDown();
    });
    canvas.addEventListener('mousemove', function(e) {
        draw.mouseMove(e);
    });
    canvas.addEventListener('mouseup', function() {
        draw.mouseUp();
    });

    document.getElementById('draw').addEventListener('click', function(){
    });

    document.getElementById('erase').addEventListener('click', function(){

    });
    document.getElementById('fill').addEventListener('click', function(){
        fill.call();
    });
    document.getElementById('select-area').addEventListener('click', function(){
        selectArea.call();
    });
    document.getElementById('copy').addEventListener('click', function(){
        copy.call();
    });
    document.getElementById('paste').addEventListener('click', function(){
        paste.call();
    });
    document.getElementById('load-image').addEventListener('click', function(){
        loadImage.call();
    });
});

@@ -276,24 +276,419 @@
 loadImage');
+%0A%0A    var canvas = init.getCanvas();%0A    var context = init.getContext();%0A    %0A    // canvas%E3%81%AB%E5%AF%BE%E3%81%99%E3%82%8B%E6%93%8D%E4%BD%9C%0A    // draw%E9%96%A2%E4%BF%82%0A    canvas.addEventListener('mousedown', function() %7B%0A        draw.mouseDown();%0A    %7D);%0A    canvas.addEventListener('mousemove', function(e) %7B%0A        draw.mouseMove(e);%0A    %7D);%0A    canvas.addEventListener('mouseup', function() %7B%0A        draw.mouseUp();%0A    %7D);%0A    %0A    //%E7%B7%9A%E3%81%AE%E8%89%B2%E3%82%92%E5%A4%89%E3%81%88%E3%82%8B%E5%87%A6%E7%90%86
 %0A    var col
@@ -1138,379 +1138,8 @@
 %7D;%0A%0A
-%0A    var canvas = init.getCanvas();%0A    var context = init.getContext();%0A%0A    // canvas%E3%81%AB%E5%AF%BE%E3%81%99%E3%82%8B%E6%93%8D%E4%BD%9C%0A    // draw%E9%96%A2%E4%BF%82%0A    canvas.addEventListener('mousedown', function() %7B%0A        draw.mouseDown();%0A    %7D);%0A    canvas.addEventListener('mousemove', function(e) %7B%0A        draw.mouseMove(e);%0A    %7D);%0A    canvas.addEventListener('mouseup', function() %7B%0A        draw.mouseUp();%0A    %7D);%0A%0A
     

edit main.js