added spaces
This commit is contained in:
@@ -74,38 +74,28 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateGraphs(): void {
|
private updateGraphs(): void {
|
||||||
const curves = [
|
const genShiftStart = this.shiftPoint(this.matrix.start, this.config.vectors.start);
|
||||||
|
const genShiftEnd = this.shiftPoint(this.matrix.end, this.config.vectors.end);
|
||||||
|
|
||||||
|
const curveList = [
|
||||||
{
|
{
|
||||||
color: env.guilloche.colors.primary,
|
color: env.guilloche.colors.primary,
|
||||||
start: {
|
start: genShiftStart.next().value,
|
||||||
point: this.matrix['start'],
|
end: genShiftEnd.next().value
|
||||||
vector: this.config.vectors.start
|
|
||||||
},
|
|
||||||
end: {
|
|
||||||
point: this.matrix['end'],
|
|
||||||
vector: this.config.vectors.end
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: env.guilloche.colors.secondary,
|
color: env.guilloche.colors.secondary,
|
||||||
start: {
|
start: genShiftEnd.next().value,
|
||||||
point: this.matrix['end'],
|
end: genShiftStart.next().value
|
||||||
vector: this.config.vectors.end
|
|
||||||
},
|
|
||||||
end: {
|
|
||||||
point: this.matrix['start'],
|
|
||||||
vector: this.config.vectors.start
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
this.graphs = [this.adjustGraph(curves[0]), this.adjustGraph(curves[1])];
|
this.graphs = curveList.map(curve => this.adjustGraph(curve));
|
||||||
console.log('graphs component (updateGraphs):', this.graphs);
|
console.log('graphs component (updateGraphs):', this.graphs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private adjustGraph(curve) {
|
private adjustGraph(curve) {
|
||||||
return Object.assign(curve, {
|
return Object.assign(curve, {
|
||||||
id: `start-to-end`,
|
|
||||||
stroke: this.config.stroke,
|
stroke: this.config.stroke,
|
||||||
nodes: [
|
nodes: [
|
||||||
this.genVectorPoint(curve.start.point, curve.start.vector),
|
this.genVectorPoint(curve.start.point, curve.start.vector),
|
||||||
@@ -186,8 +176,6 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
|
|||||||
max: this.matrix.center.y + this.matrix.height * overlap
|
max: this.matrix.center.y + this.matrix.height * overlap
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(this.matrix.center);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: Random.randomUniform(x.min, x.max)(),
|
x: Random.randomUniform(x.min, x.max)(),
|
||||||
y: Random.randomUniform(y.min, y.max)()
|
y: Random.randomUniform(y.min, y.max)()
|
||||||
@@ -203,20 +191,23 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
|
|||||||
return Math.pow(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2), 0.5);
|
return Math.pow(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2), 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private *shiftPoint(point: Point, vector) {
|
private *shiftPoint(point: Point, vector) {
|
||||||
const genShiftX = this.shiftNumber(this.config.space, point.x);
|
const genShiftX = this.shiftNumber(this.config.space, vector);
|
||||||
const genShiftY = this.shiftNumber(this.config.space, point.y);
|
const genShiftY = this.shiftNumber(this.config.space, vector);
|
||||||
|
|
||||||
return {
|
while (true) {
|
||||||
x: 0,
|
yield {
|
||||||
y: 0
|
point: {
|
||||||
};
|
x: Math.cos(Math.PI * vector) * genShiftX.next().value + point.x,
|
||||||
|
y: Math.sin(Math.PI * vector) * genShiftY.next().value + point.y,
|
||||||
|
},
|
||||||
|
vector: vector
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private *shiftNumber(num: number, space: number) {
|
private *shiftNumber(space: number, vector: number) {
|
||||||
let current = num;
|
let current = 0;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
const sign = this.flipSign();
|
const sign = this.flipSign();
|
||||||
|
|
||||||
|
|||||||
@@ -130,28 +130,12 @@ export class GuillocheDirective implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private showGrid() {
|
private showGrid() {
|
||||||
this.group.append('circle')
|
|
||||||
.attr('cx', this.graph.start.point.x)
|
|
||||||
.attr('cy', this.graph.start.point.y)
|
|
||||||
.attr('r', 20)
|
|
||||||
.attr('stroke-width', 1)
|
|
||||||
.attr('fill-opacity', 0)
|
|
||||||
.attr('stroke', this.graph.color);
|
|
||||||
|
|
||||||
this.group.append('circle')
|
|
||||||
.attr('cx', this.graph.end.point.x)
|
|
||||||
.attr('cy', this.graph.end.point.y)
|
|
||||||
.attr('r', 10)
|
|
||||||
.attr('stroke-width', 1)
|
|
||||||
.attr('fill-opacity', 0)
|
|
||||||
.attr('stroke', this.graph .color);
|
|
||||||
|
|
||||||
this.graph.nodes.forEach(point => {
|
this.graph.nodes.forEach(point => {
|
||||||
this.group.append('circle')
|
this.group.append('circle')
|
||||||
.attr('cx', point.x)
|
.attr('cx', point.x)
|
||||||
.attr('cy', point.y)
|
.attr('cy', point.y)
|
||||||
.attr('r', 5)
|
.attr('r', 3)
|
||||||
.attr('stroke-width', 1)
|
.attr('stroke-width', 0.1)
|
||||||
.attr('fill-opacity', 0)
|
.attr('fill-opacity', 0)
|
||||||
.attr('stroke', 'darkgray');
|
.attr('stroke', 'darkgray');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export const environment = {
|
|||||||
width: 10,
|
width: 10,
|
||||||
height: 16,
|
height: 16,
|
||||||
scale: 0.1,
|
scale: 0.1,
|
||||||
|
overlap: 0.8,
|
||||||
vectors: {
|
vectors: {
|
||||||
start: 1,
|
start: 1,
|
||||||
end: 0,
|
end: 0,
|
||||||
@@ -33,7 +34,6 @@ export const environment = {
|
|||||||
},
|
},
|
||||||
nodes: 2,
|
nodes: 2,
|
||||||
stroke: 1,
|
stroke: 1,
|
||||||
overlap: 1.4,
|
|
||||||
spread: 8,
|
spread: 8,
|
||||||
space: 6
|
space: 6
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user