feat(graphsComponent): added expanded nodes function
This commit is contained in:
@@ -87,7 +87,13 @@
|
|||||||
<div class="dropdown-divider mb-4"></div>
|
<div class="dropdown-divider mb-4"></div>
|
||||||
<button type="submit" class="btn btn-lg btn-primary btn-block" [disabled]="configForm.invalid">Aktualisieren</button>
|
<button type="submit" class="btn btn-lg btn-primary btn-block" [disabled]="configForm.invalid">Aktualisieren</button>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<button (click)="exportSvg()" class="btn btn-secondary btn-block" [disabled]="configForm.invalid">Download</button>
|
<!-- <button (click)="exportSvg()" class="btn btn-secondary btn-block" [disabled]="configForm.invalid">Download</button> -->
|
||||||
</form>
|
</form>
|
||||||
|
<!-- <div class="form-group mt-4 text-center">
|
||||||
|
<div class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="scrollOnWheel" [value]="scrollOnWheel">
|
||||||
|
<label class="custom-control-label" for="scrollOnWheel">Beim Scrollen Skalieren</label>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
|||||||
@@ -16,27 +16,29 @@ export class AppComponent implements OnInit {
|
|||||||
public canvasParam: Param;
|
public canvasParam: Param;
|
||||||
public config: any | null;
|
public config: any | null;
|
||||||
public configForm: FormGroup;
|
public configForm: FormGroup;
|
||||||
|
public scaleOnWheel: boolean;
|
||||||
|
|
||||||
@HostListener('mousewheel', ['$event'])
|
@HostListener('mousewheel', ['$event'])
|
||||||
private onMousewheel(event) {
|
private onMousewheel(event) {
|
||||||
const delta = Math.sign(event.deltaY);
|
|
||||||
const step = env.controls.wheelStep;
|
|
||||||
|
|
||||||
this.config = {...this.configForm.value};
|
this.config = {...this.configForm.value};
|
||||||
|
|
||||||
if (delta > 0) {
|
if (this.scaleOnWheel) {
|
||||||
if (this.config.scale === 1 - step) {
|
const delta = Math.sign(event.deltaY);
|
||||||
return;
|
const step = env.controls.wheelStep;
|
||||||
}
|
|
||||||
this.config.scale += step;
|
|
||||||
} else {
|
|
||||||
if (this.config.scale === step) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.config.scale -= step;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.config.scale = Math.round(this.config.scale / step) * step;
|
if (delta > 0) {
|
||||||
|
if (this.config.scale === 1 - step) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.config.scale += step;
|
||||||
|
} else {
|
||||||
|
if (this.config.scale === step) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.config.scale -= step;
|
||||||
|
}
|
||||||
|
this.config.scale = Math.round(this.config.scale / step) * step;
|
||||||
|
}
|
||||||
this.configForm.reset({...this.config});
|
this.configForm.reset({...this.config});
|
||||||
this.updateGraphs();
|
this.updateGraphs();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,23 +65,27 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
|
|||||||
const to = this.flipflop(from);
|
const to = this.flipflop(from);
|
||||||
const startPoint = { x: this.matrix[from].x, y: this.matrix[from].y };
|
const startPoint = { x: this.matrix[from].x, y: this.matrix[from].y };
|
||||||
const endPoint = { x: this.matrix[to].x, y: this.matrix[to].y };
|
const endPoint = { x: this.matrix[to].x, y: this.matrix[to].y };
|
||||||
|
const expandedPoints = [];
|
||||||
|
|
||||||
console.error(from, '->', to);
|
for (let i = 0; i < this.config.nodes; i++) {
|
||||||
|
expandedPoints.push(this.randomPoint);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: `${from}-to-${to}`,
|
id: `${from}-to-${to}`,
|
||||||
start: {
|
start: {
|
||||||
coords: startPoint,
|
coords: startPoint,
|
||||||
direction: this.config.vectors[from],
|
direction: this.config.vectors[from],
|
||||||
color: env.guilloche.colors.start
|
color: env.guilloche.colors[from]
|
||||||
}, end: {
|
}, end: {
|
||||||
coords: endPoint,
|
coords: endPoint,
|
||||||
direction: this.config.vectors[to],
|
direction: this.config.vectors[to],
|
||||||
color: env.guilloche.colors.end
|
color: env.guilloche.colors[to]
|
||||||
},
|
},
|
||||||
stroke: this.config.stroke,
|
stroke: this.config.stroke,
|
||||||
nodes: [
|
nodes: [
|
||||||
this.vectorPoint(startPoint, this.config.vectors[from]),
|
this.vectorPoint(startPoint, this.config.vectors[from]),
|
||||||
|
...expandedPoints,
|
||||||
this.vectorPoint(endPoint, this.config.vectors[to])
|
this.vectorPoint(endPoint, this.config.vectors[to])
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@@ -123,21 +127,39 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
|
|||||||
y: totalCenter.y - baseCenter.y
|
y: totalCenter.y - baseCenter.y
|
||||||
},
|
},
|
||||||
width: baseWidthScaled,
|
width: baseWidthScaled,
|
||||||
height: baseHeightScaled
|
height: baseHeightScaled,
|
||||||
|
center: totalCenter
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private vectorPoint(point: Point, direction: number) {
|
private vectorPoint(point: Point, direction: number) {
|
||||||
const range = this.Δ(this.matrix.start, this.matrix.end) * this.config.vectors.range;
|
const range = this.Δ(this.matrix.start, this.matrix.end) * this.config.vectors.range;
|
||||||
|
|
||||||
console.log('graphs component(vectorPoint)', point, direction);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: range * Math.sin(Math.PI * direction) + point.x,
|
x: range * Math.sin(Math.PI * direction) + point.x,
|
||||||
y: range * Math.cos(Math.PI * direction) + point.y
|
y: range * Math.cos(Math.PI * direction) + point.y
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get randomPoint() {
|
||||||
|
const overlap = env.guilloche.overlap;
|
||||||
|
const x = {
|
||||||
|
min: this.matrix.center.x - this.matrix.width * overlap,
|
||||||
|
max: this.matrix.center.x + this.matrix.width * overlap
|
||||||
|
};
|
||||||
|
const y = {
|
||||||
|
min: this.matrix.center.y - this.matrix.height * overlap,
|
||||||
|
max: this.matrix.center.y + this.matrix.height * overlap
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(this.matrix.center);
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: Random.randomUniform(x.min, x.max)(),
|
||||||
|
y: Random.randomUniform(y.min, y.max)()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate distance between to points with coordinates.
|
* Calculate distance between to points with coordinates.
|
||||||
* @param a
|
* @param a
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ export const environment = {
|
|||||||
colors: {
|
colors: {
|
||||||
start: '#f16363',
|
start: '#f16363',
|
||||||
end: '#5eb1bd'
|
end: '#5eb1bd'
|
||||||
}
|
},
|
||||||
|
overlap: 3
|
||||||
},
|
},
|
||||||
controls: {
|
controls: {
|
||||||
wheelStep: 0.01
|
wheelStep: 0.01
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ export const environment = {
|
|||||||
colors: {
|
colors: {
|
||||||
start: '#cc0045',
|
start: '#cc0045',
|
||||||
end: '#0067cc'
|
end: '#0067cc'
|
||||||
}
|
},
|
||||||
|
overlap: 1.4
|
||||||
},
|
},
|
||||||
controls: {
|
controls: {
|
||||||
wheelStep: 0.01
|
wheelStep: 0.01
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="de-DE">
|
<html lang="de-DE">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>NlsNg6D3jsGuilloche</title>
|
<title>Random Guilloche Generator</title>
|
||||||
<base href="/">
|
<base href="/">
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|||||||
Reference in New Issue
Block a user