added margin as parameter
This commit is contained in:
@@ -7,7 +7,16 @@
|
|||||||
<li><pre>{{canvasParam | json}}</pre></li>
|
<li><pre>{{canvasParam | json}}</pre></li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<div><input type="number" [(ngModel)]="canvasParam.points"></div>
|
<label>
|
||||||
|
<div>Amount of points</div>
|
||||||
|
<input type="number" [(ngModel)]="canvasParam.points">
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>
|
||||||
|
<div>Margin</div>
|
||||||
|
<input type="number" [(ngModel)]="canvasParam.margin">
|
||||||
|
</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ export class AppComponent {
|
|||||||
start: '#cc0045',
|
start: '#cc0045',
|
||||||
end: '#0067cc'
|
end: '#0067cc'
|
||||||
},
|
},
|
||||||
points: 3
|
points: 3,
|
||||||
|
margin: 0.1
|
||||||
};
|
};
|
||||||
this.test = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateCanvasConfig(config): void {
|
public updateCanvasConfig(config): void {
|
||||||
|
|||||||
@@ -163,16 +163,18 @@ export class CanvasDirective implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateConfig(): void {
|
private updateConfig(): void {
|
||||||
|
const margin = this.canvas.clientWidth * this.param.margin;
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
width: this.canvas.clientWidth,
|
width: this.canvas.clientWidth,
|
||||||
height: this.canvas.clientHeight,
|
height: this.canvas.clientHeight,
|
||||||
start: {
|
start: {
|
||||||
x: this.canvas.clientWidth,
|
x: this.canvas.clientWidth - margin,
|
||||||
y: 0,
|
y: 0,
|
||||||
color: this.param.colors.start
|
color: this.param.colors.start
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
x: 0,
|
x: 0 + margin,
|
||||||
y: this.canvas.clientHeight,
|
y: this.canvas.clientHeight,
|
||||||
color: this.param.colors.end
|
color: this.param.colors.end
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ export interface Param {
|
|||||||
end: string
|
end: string
|
||||||
};
|
};
|
||||||
points: number;
|
points: number;
|
||||||
|
margin: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user