Last active
July 24, 2020 07:42
-
-
Save mvolfik/bc928b6334edcca9f3049eb9941ea324 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Canvas tweaks | |
// @namespace https://mvolfik.github.io/ | |
// @version 0.4 | |
// @description Try to take over the world! | |
// @author matjey | |
// @match http://i.protab.cz/mazec/live/ | |
// @downloadURL https://gist.githubusercontent.com/mvolfik/bc928b6334edcca9f3049eb9941ea324/raw/canvas_upgrade.user.js | |
// @grant GM_addStyle | |
// @grant unsafeWindow | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
GM_addStyle("canvas#canvas {height: auto !important; width: auto !important;} .live_container {height: auto !important;} footer {padding-bottom: 0.5vmin;}"); | |
let actual_render = render; | |
console.log(actual_render); | |
unsafeWindow.render = function render(map) { | |
actual_render(map); | |
var canvas = document.getElementById("canvas"); | |
var ctx = canvas.getContext("2d"); | |
for (let i = 0; i <= 495; i += 15) { | |
ctx.beginPath(); | |
ctx.strokeStyle = "#00CC00"; | |
ctx.lineWidth = i % 75 === 0 ? 2 : 1; | |
ctx.moveTo(i, 0); | |
ctx.lineTo(i, 495); | |
ctx.moveTo(0, i); | |
ctx.lineTo(495, i); | |
ctx.stroke() | |
} | |
ctx.fillStyle = "#00CC00"; | |
ctx.font = "10px monospace"; | |
ctx.textAlign = "center"; | |
ctx.textBaseline = "middle"; | |
for (let i = 0; i <= 32; i += 1) { | |
ctx.fillText(i.toString(), i * 15 + 7.5, 8); | |
} | |
for (let i = 1; i <= 32; i += 1) { | |
ctx.fillText(i.toString(), 7.5, i * 15 + 8); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment