From 352f86018ba739d2d221b39c1171f652f045dd06 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 11 Jul 2020 22:42:48 +0200 Subject: [PATCH] center grid overlay --- area.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/area.js b/area.js index 0dea931..a6a2172 100644 --- a/area.js +++ b/area.js @@ -277,18 +277,22 @@ var DrawingArea = new Lang.Class({ cr.save(); Clutter.cairo_set_source_color(cr, this.gridColor); - let [gridX, gridY] = [this.gridGap, this.gridGap]; - while (gridX < this.monitor.width) { + let [gridX, gridY] = [0, 0]; + while (gridX < this.monitor.width / 2) { cr.setLineWidth((gridX / this.gridGap) % 5 ? this.gridInterlineWidth : this.gridLineWidth); - cr.moveTo(gridX, 0); - cr.lineTo(gridX, this.monitor.height); + cr.moveTo(this.monitor.width / 2 + gridX, 0); + cr.lineTo(this.monitor.width / 2 + gridX, this.monitor.height); + cr.moveTo(this.monitor.width / 2 - gridX, 0); + cr.lineTo(this.monitor.width / 2 - gridX, this.monitor.height); gridX += this.gridGap; cr.stroke(); } - while (gridY < this.monitor.height) { + while (gridY < this.monitor.height / 2) { cr.setLineWidth((gridY / this.gridGap) % 5 ? this.gridInterlineWidth : this.gridLineWidth); - cr.moveTo(0, gridY); - cr.lineTo(this.monitor.width, gridY); + cr.moveTo(0, this.monitor.height / 2 + gridY); + cr.lineTo(this.monitor.width, this.monitor.height / 2 + gridY); + cr.moveTo(0, this.monitor.height / 2 - gridY); + cr.lineTo(this.monitor.width, this.monitor.height / 2 - gridY); gridY += this.gridGap; cr.stroke(); }