fix(graphsComponent): polishment
This commit is contained in:
@@ -85,6 +85,12 @@
|
|||||||
<option value="270">Links</option>
|
<option value="270">Links</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-control-label">
|
||||||
|
Skalierung
|
||||||
|
</label>
|
||||||
|
<input type="number" class="form-control" formControlName="scale" min="0" max="1" step="0.1">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-control-label">
|
<label class="form-control-label">
|
||||||
Knotenpunkte
|
Knotenpunkte
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { GuillocheDirective } from './../directives/guilloche.directive';
|
|||||||
import { CanvasService } from './../services/canvas.service';
|
import { CanvasService } from './../services/canvas.service';
|
||||||
import { Graph } from '../models/graph.model';
|
import { Graph } from '../models/graph.model';
|
||||||
import { Config } from './../models/config.model';
|
import { Config } from './../models/config.model';
|
||||||
|
import { Point } from '../models/point.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-graphs',
|
selector: 'app-graphs',
|
||||||
@@ -86,24 +87,12 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get matrix() {
|
private get matrix() {
|
||||||
const totalWidth = this.canvas.clientWidth;
|
const totalArea = Math.abs(this.canvas.clientWidth * this.canvas.clientHeight);
|
||||||
const totalHeight = this.canvas.clientHeight;
|
const totalCenter = this.centerPoint(this.canvas.clientWidth, this.canvas.clientHeight);
|
||||||
const totalArea = Math.abs(totalWidth * totalHeight);
|
|
||||||
const totalCenter = {
|
|
||||||
x: totalWidth * 0.5,
|
|
||||||
y: totalHeight * 0.5
|
|
||||||
};
|
|
||||||
|
|
||||||
const baseWidth = this.config.width;
|
|
||||||
const baseHeight = this.config.height;
|
|
||||||
const baseArea = Math.abs(this.config.width * this.config.height);
|
const baseArea = Math.abs(this.config.width * this.config.height);
|
||||||
const baseScale = Math.pow(totalArea / baseArea * env.guilloche.scale, 0.5);
|
const baseScale = Math.pow(totalArea / baseArea * this.config.scale, 0.5);
|
||||||
const baseScaledWidth = baseScale * baseWidth;
|
const baseCenter = this.centerPoint( baseScale * this.config.width, baseScale * this.config.height);
|
||||||
const baseScaledHeight = baseScale * baseHeight;
|
|
||||||
const baseCenter = {
|
|
||||||
x: baseScaledWidth * 0.5,
|
|
||||||
y: baseScaledHeight * 0.5
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start: {
|
start: {
|
||||||
@@ -116,4 +105,11 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private centerPoint(width, height): Point {
|
||||||
|
return {
|
||||||
|
x: width * 0.5,
|
||||||
|
y: height * 0.5
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,9 @@ export let ConfigForm: FormGroup = fb.group({
|
|||||||
nodes: fb.control('', Validators.compose([
|
nodes: fb.control('', Validators.compose([
|
||||||
Validators.min(1),
|
Validators.min(1),
|
||||||
Validators.max(10)
|
Validators.max(10)
|
||||||
]))
|
])),
|
||||||
|
scale: fb.control('', Validators.compose([
|
||||||
|
Validators.min(0),
|
||||||
|
Validators.max(1)
|
||||||
|
])),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ export const environment = {
|
|||||||
colors: {
|
colors: {
|
||||||
start: '#cc0045',
|
start: '#cc0045',
|
||||||
end: '#0067cc'
|
end: '#0067cc'
|
||||||
},
|
}
|
||||||
scale: 0.3
|
|
||||||
},
|
},
|
||||||
formDefaults: {
|
formDefaults: {
|
||||||
width: 10,
|
width: 10,
|
||||||
height: -20,
|
height: 10,
|
||||||
directionStart: 180,
|
directionStart: 180,
|
||||||
directionEnd: 270,
|
directionEnd: 270,
|
||||||
nodes: 1
|
nodes: 1,
|
||||||
|
scale: 0.3
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user