center grid overlay

This commit is contained in:
abakkk 2020-07-11 22:42:48 +02:00
parent 19355033ff
commit 352f86018b
1 changed files with 11 additions and 7 deletions

18
area.js
View File

@ -277,18 +277,22 @@ var DrawingArea = new Lang.Class({
cr.save(); cr.save();
Clutter.cairo_set_source_color(cr, this.gridColor); Clutter.cairo_set_source_color(cr, this.gridColor);
let [gridX, gridY] = [this.gridGap, this.gridGap]; let [gridX, gridY] = [0, 0];
while (gridX < this.monitor.width) { while (gridX < this.monitor.width / 2) {
cr.setLineWidth((gridX / this.gridGap) % 5 ? this.gridInterlineWidth : this.gridLineWidth); cr.setLineWidth((gridX / this.gridGap) % 5 ? this.gridInterlineWidth : this.gridLineWidth);
cr.moveTo(gridX, 0); cr.moveTo(this.monitor.width / 2 + gridX, 0);
cr.lineTo(gridX, this.monitor.height); 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; gridX += this.gridGap;
cr.stroke(); cr.stroke();
} }
while (gridY < this.monitor.height) { while (gridY < this.monitor.height / 2) {
cr.setLineWidth((gridY / this.gridGap) % 5 ? this.gridInterlineWidth : this.gridLineWidth); cr.setLineWidth((gridY / this.gridGap) % 5 ? this.gridInterlineWidth : this.gridLineWidth);
cr.moveTo(0, gridY); cr.moveTo(0, this.monitor.height / 2 + gridY);
cr.lineTo(this.monitor.width, 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; gridY += this.gridGap;
cr.stroke(); cr.stroke();
} }