2
0

fix(form): added mocked functionality and adjusted env vars

This commit is contained in:
2018-05-23 18:22:42 +02:00
parent 6807c81f3d
commit d42b6160e6
8 changed files with 38 additions and 5 deletions

View File

@@ -63,6 +63,12 @@
</label> </label>
<input type="number" class="form-control" formControlName="height"> <input type="number" class="form-control" formControlName="height">
</div> </div>
<div class="form-group">
<label class="form-control-label">
Duktus <small>(Strichstärke)</small>
</label>
<input type="number" class="form-control" formControlName="stroke" min="0.1" max="10" step="0.1">
</div>
<div class="form-group"> <div class="form-group">
<label class="form-control-label"> <label class="form-control-label">
Anfangsvektor Anfangsvektor
@@ -91,13 +97,16 @@
</label> </label>
<input type="number" class="form-control" formControlName="scale" min="0" max="1" step="0.01"> <input type="number" class="form-control" formControlName="scale" min="0" max="1" step="0.01">
</div> </div>
<div class="form-group"> <div class="form-group mb-4">
<label class="form-control-label"> <label class="form-control-label">
Knotenpunkte Knotenpunkte
</label> </label>
<input type="number" class="form-control" formControlName="nodes" min="1" max="10"> <input type="number" class="form-control" formControlName="nodes" min="1" max="10">
</div> </div>
<button type="submit" class="btn btn-primary" [disabled]="configForm.invalid">Aktualisieren</button> <div class="dropdown-divider mb-4"></div>
<button type="submit" class="btn btn-lg btn-primary btn-block" [disabled]="configForm.invalid">Aktualisieren</button>
<div class="dropdown-divider"></div>
<button (click)="exportSvg()" class="btn btn-secondary btn-block" [disabled]="configForm.invalid">Download</button>
</form> </form>
</aside> </aside>

View File

@@ -72,4 +72,8 @@ export class AppComponent implements OnInit {
public updateGraphs() { public updateGraphs() {
this.config = {...this.configForm.value}; this.config = {...this.configForm.value};
} }
public exportSvg() {
alert('Feature coming');
}
} }

View File

@@ -56,7 +56,6 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
private updateGraphs(): void { private updateGraphs(): void {
const matrix = this.matrix; const matrix = this.matrix;
console.log(matrix);
this.graphs = [...[{ this.graphs = [...[{
start: { start: {
@@ -67,7 +66,8 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
coords: { x: matrix.end.x, y: matrix.end.y }, coords: { x: matrix.end.x, y: matrix.end.y },
direction: this.config.directionEnd, direction: this.config.directionEnd,
color: env.guilloche.colors.end color: env.guilloche.colors.end
} },
stroke: this.config.stroke
}, { }, {
start: { start: {
coords: { x: matrix.end.x, y: matrix.end.y }, coords: { x: matrix.end.x, y: matrix.end.y },
@@ -77,7 +77,8 @@ export class GraphsComponent implements AfterViewInit, OnChanges {
coords: { x: matrix.start.x, y: matrix.start.y }, coords: { x: matrix.start.x, y: matrix.start.y },
direction: this.config.directionStart, direction: this.config.directionStart,
color: env.guilloche.colors.end color: env.guilloche.colors.end
} },
stroke: this.config.stroke
}]]; }]];
} }

View File

@@ -36,6 +36,18 @@ export class GuillocheDirective implements OnChanges {
private drawGraph(): void { private drawGraph(): void {
console.log('guilloche directive(drawGraph)', this.graph); console.log('guilloche directive(drawGraph)', this.graph);
this.group.append('path')
.attr('d', Shape.line()
.x(p => p.x)
.y(p => p.y)
.curve(Shape.curveBasis)([
this.graph.start.coords,
this.graph.end.coords
]))
.attr('stroke', 'url(#gradient)')
.attr('stroke-width', this.graph.stroke)
.attr('fill', 'none');
this.group.append('circle') this.group.append('circle')
.attr('cx', this.graph.start.coords.x) .attr('cx', this.graph.start.coords.x)
.attr('cy', this.graph.start.coords.y) .attr('cy', this.graph.start.coords.y)

View File

@@ -21,4 +21,8 @@ export let ConfigForm: FormGroup = fb.group({
Validators.min(0), Validators.min(0),
Validators.max(1) Validators.max(1)
])), ])),
stroke: fb.control('', Validators.compose([
Validators.min(0.1),
Validators.max(10)
])),
}); });

View File

@@ -11,5 +11,6 @@ export interface Graph {
direction: number; // degree between 0 and 360 direction: number; // degree between 0 and 360
color: string; // can be set in enviroment color: string; // can be set in enviroment
}; };
stroke: number; // stroke width
nodes?: Point[]; // orientation points nodes?: Point[]; // orientation points
} }

View File

@@ -12,6 +12,7 @@ export const environment = {
directionStart: 0, directionStart: 0,
directionEnd: 180, directionEnd: 180,
nodes: 3, nodes: 3,
stroke: 1,
scale: 0.3 scale: 0.3
} }
}; };

View File

@@ -16,6 +16,7 @@ export const environment = {
directionStart: 0, directionStart: 0,
directionEnd: 180, directionEnd: 180,
nodes: 3, nodes: 3,
stroke: 1,
scale: 0.3 scale: 0.3
} }
}; };