question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a ruler for the grid

See original GitHub issue

A ruler would be useful to check part dimensions before exporting.

This proof of concept kind of works:

diff --git a/src/moto/space.js b/src/moto/space.js
index 06589e0..6711326 100644
--- a/src/moto/space.js
+++ b/src/moto/space.js
@@ -248,13 +248,29 @@
             h = y / 2,
             d = z / 2,
             zp = -d - platformZOff + gridZOff,
-            majors = [], minors = unitMinor ? [] : null, i;
+            majors = [], minors = unitMinor ? [] : null, i,
+            labelSize = gridUnitMinor * 1.5,
+            canvasScale = 4,
+            canvasPadding = 10,
+            xLabelsMesh,
+            xLabelCanvas = document.createElement('canvas'),
+            xLabelCtx = xLabelCanvas.getContext('2d');
+
+        xLabelCanvas.width = x * canvasScale + canvasPadding * 2 * canvasScale;
+        xLabelCanvas.height = labelSize * canvasScale;
+        xLabelCtx.scale(canvasScale, canvasScale);
+        xLabelCtx.fillStyle = '#333333';
+        xLabelCtx.font = labelSize + 'px monospace';
+        xLabelCtx.textAlign = 'center';
+        xLabelCtx.textBaseline = 'top';
+
         for (i = -xo; i <= xo; i += unitMinor) {
             let oh = isRound ? Math.sqrt(1-(i/xo)*(i/xo)) * h : h,
                 dM = Math.abs(i % unitMajor);
             if (i < -w || i > w) continue;
             if (dM < 1 || Math.abs(unitMajor - dM) < 0.1) {
                 majors.append({x:i, y:-oh, z:zp}).append({x:i, y:oh, z:zp});
+                xLabelCtx.fillText('' + (i + w), i + xo + canvasPadding, 0)
             } else {
                 minors.append({x:i, y:-oh, z:zp}).append({x:i, y:oh, z:zp});
             }
@@ -273,6 +289,18 @@
         if (minors) gridView.add(makeLinesFromPoints(minors, gridColorMinor || 0xcccccc, 1));
         if (oldGridView) Space.scene.remove(oldGridView);
         Space.scene.add(gridView);
+
+        xLabelsMesh = new THREE.Mesh(
+            new THREE.PlaneGeometry(x + canvasPadding * 2, labelSize),
+            new THREE.MeshBasicMaterial({
+                transparent: true,
+                map: new THREE.CanvasTexture(xLabelCanvas),
+            })
+        );
+        xLabelsMesh.position.x = 0;
+        xLabelsMesh.position.y = - h - labelSize;
+        xLabelsMesh.position.z = zp;
+        gridView.add(xLabelsMesh);
     }
 
     function setOrigin(x, y, z) {

screenshot-1603833769

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
juodumascommented, Oct 29, 2020

Thanks for this project and for merging. The ruler will be useful to us.

2reactions
juodumascommented, Oct 28, 2020

Makes sense. Will see what I can do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grid Ruler
It allow you to creates vertical and horizontal grids, Photoshop style. It has a ruler to measure distance between your grids too.
Read more >
Rulers, grids, and guides in Photoshop Elements
In Adobe Photoshop Elements, learn how to use rulers, grids, and guides to help you position items such as selections, layers, and shapes....
Read more >
Ruler and Grid - SAi Cloud
Rulers appear along the top and left side of the main screen to help you measure and align objects. As you move the...
Read more >
Using rulers, grids, and guides - Corel
To display the ruler, grid, or guides · Choose the View menu, and select one of the following: · Rulers · Grid ·...
Read more >
Tips for Grids, Guides, and Ruler Options in Photoshop
Discover everything about working with Grid, Guides, and Ruler Shortcuts in ... To add a guide using the rulers, click in the ruler...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found