JSFiddle - React, Tailwind, and code Playground

by ethertank

HTML

<canvas id='world'></canvas>

JavaScript

CanvasRenderingContext2D.prototype.すごいメソッド = function(x,y,X,Y) {
    this.save();
    
    var grd  = this.createLinearGradient(x, y, X, Y);
    grd.addColorStop(   0, "yellow");
    grd.addColorStop( .33, "orange");
    grd.addColorStop( .66, "red");
    grd.addColorStop(   1, "purple");
    this.fillStyle = grd;
    
    this.fillRect(x,y,X,Y);
    this.restore();
};

CanvasRenderingContext2D.prototype.すごいプロパティ = this;

var C = document.getElementById("world");
var c = C.getContext("2d");




c.すごいメソッド(10,10,50,50);

console.log(c.すごいプロパティ);

c.fillRect(60,60,50,50);//ちゃんと初期値の黒に戻ってるか確認