Last active
February 23, 2022 01:17
-
-
Save harryhare/92537ecc382e9580a4111976a8f6a5a0 to your computer and use it in GitHub Desktop.
dark_forest grid plugin
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
class Plugin { | |
constructor() { | |
} | |
draw(ctx) { | |
const viewport = ui.getViewport(); | |
ctx.save(); | |
//ctx.fillStyle = "red"; | |
//ctx.strokeStyle = "red"; | |
//ctx.strokeStyle = "dashed"; | |
ctx.strokeStyle = "#476b8c"; | |
ctx.lineWidth = 1; | |
var i = 0; | |
var width = ctx.canvas.width; | |
var height = ctx.canvas.height; | |
//console.log(width, "X", height); | |
var r = df.getWorldRadius(); | |
var step = 5000; | |
var left = (Math.floor(-r / step) * step); | |
var right = (Math.ceil(r / step) * step); | |
var bottom = (Math.floor(-r / step) * step); | |
var top = (Math.ceil(r / step) * step); | |
//console.log(left, right, step_x); | |
//console.log(bottom, top, step_y); | |
ctx.beginPath(); | |
for (i = left; i <= right; i += step) { | |
ctx.moveTo(viewport.worldToCanvasX(i), viewport.worldToCanvasY(bottom)); | |
ctx.lineTo(viewport.worldToCanvasX(i), viewport.worldToCanvasY(top)); | |
} | |
for (i = bottom; i <= top; i += step) { | |
ctx.moveTo(viewport.worldToCanvasX(left), viewport.worldToCanvasY(i)); | |
ctx.lineTo(viewport.worldToCanvasX(right), viewport.worldToCanvasY(i)); | |
} | |
ctx.stroke(); | |
ctx.closePath(); | |
ctx.restore(); | |
} | |
async render(container) { | |
} | |
destroy() { | |
} | |
} | |
export default Plugin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment