Fix for drawing grid

This commit is contained in:
piotrpekala7 2020-06-17 17:30:11 +02:00
parent 1a8701d845
commit c7dc56babd
2 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<svg id="map" #svg class="map" preserveAspectRatio="none" movingCanvas zoomingCanvas>
<filter id="grayscale"><feColorMatrix id="feGrayscale" type="saturate" values="0" /></filter>
<defs>
<pattern id="gridDrawing" attr.width="{{project.drawing_grid_size}}" attr.height="{{project.drawing_grid_size}}" patternUnits="userSpaceOnUse">
<pattern attr.x="{{drawingGridX}}" attr.y="{{drawingGridY}}" id="gridDrawing" attr.width="{{project.drawing_grid_size}}" attr.height="{{project.drawing_grid_size}}" patternUnits="userSpaceOnUse">
<path attr.d="M {{project.drawing_grid_size}} 0 L 0 0 0 {{project.drawing_grid_size}}" fill="none" stroke="silver" attr.stroke-width="{{gridVisibility}}"/>
</pattern>
</defs>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -66,6 +66,8 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy {
public nodeGridX: number = 0;
public nodeGridY: number = 0;
public drawingGridX: number = 0;
public drawingGridY: number = 0;
constructor(
private graphDataManager: GraphDataManager,
@ -206,6 +208,9 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy {
updateGrid() {
this.nodeGridX = (this.project.scene_width/2 - (Math.floor(this.project.scene_width/2 / this.project.grid_size) * this.project.grid_size));
this.nodeGridY = (this.project.scene_height/2 - (Math.floor(this.project.scene_height/2 / this.project.grid_size) * this.project.grid_size));
this.drawingGridX = (this.project.scene_width/2 - (Math.floor(this.project.scene_width/2 / this.project.drawing_grid_size) * this.project.drawing_grid_size));
this.drawingGridY = (this.project.scene_height/2 - (Math.floor(this.project.scene_height/2 / this.project.drawing_grid_size) * this.project.drawing_grid_size));
}
@HostListener('window:resize', ['$event'])