diff --git a/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts b/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts index f1e9f77968d7a535db60c7a6304b075c7a157b50..5b01a4ac39bbc13b521ef43532f755c66ac5e7ad 100644 --- a/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts +++ b/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts @@ -176,7 +176,7 @@ export class CanvasComponent { this.unitY = this.canvasRef.nativeElement.height / this.rangeY; this.centerY = (-this.minY / this.rangeY) * this.canvasRef.nativeElement.height; this.centerX = (-this.minX / this.rangeX) * this.canvasRef.nativeElement.width; - this.iteration = (this.maxX - this.minX) / 1000; + this.iteration = (this.maxX - this.minX) / this.precision; this.scaleX = this.canvasRef.nativeElement.width / this.rangeX; this.scaleY = this.canvasRef.nativeElement.height / this.rangeY; @@ -337,7 +337,8 @@ export class CanvasComponent { this.unitY = this.canvasRef.nativeElement.height / this.rangeY; this.centerY = Math.round(Math.abs(this.minY / this.rangeY) * this.canvasRef.nativeElement.height); this.centerX = Math.round(Math.abs(this.minX / this.rangeX) * this.canvasRef.nativeElement.width); - this.iteration = (this.maxX - this.minX) / 1000; + this.precision = 1000; + this.iteration = (this.maxX - this.minX) / this.precision; this.scaleX = this.canvasRef.nativeElement.width / this.rangeX; this.scaleY = this.canvasRef.nativeElement.height / this.rangeY; }; @@ -753,7 +754,7 @@ export class CanvasComponent { this.unitY = this.canvasRef.nativeElement.height / this.rangeY; this.centerY = (this.maxY / this.rangeY) * this.canvasRef.nativeElement.height; this.centerX = (-this.minX / this.rangeX) * this.canvasRef.nativeElement.width; - this.iteration = (this.maxX - this.minX) / 1000; + this.iteration = (this.maxX - this.minX) / this.precision; this.scaleX = this.canvasRef.nativeElement.width / this.rangeX; this.scaleY = this.canvasRef.nativeElement.height / this.rangeY; @@ -889,15 +890,20 @@ export class CanvasComponent { context.beginPath(); context.lineWidth = thickness; try { - context.moveTo(this.minX, equation(this.minX)); + var firstPoint = equation(this.minX); + if(firstPoint>10e6){ + firstPoint = 10e6; + }else if (firstPoint<-10e6){ + firstPoint = -10e6; + } + context.moveTo(this.minX, firstPoint); var move = true; var _x = undefined; var _y = undefined; var pendiente = undefined; var delta = 0.50; - var nuevoY = undefined; - var h = 1/1000; - var delta = this.rangeX/1000; + var h = 1/this.precision; + var delta = this.rangeX/this.precision; var anchoPunto = this.rangeX/200; for (var x = this.minX + this.iteration; x <= this.maxX; x += this.iteration) { try{ @@ -915,17 +921,15 @@ export class CanvasComponent { }else{ if(pendiente != undefined){ - var diff = Math.abs(Math.abs(nuevoY)-Math.abs(y)); - var pendienteMas1 = Math.tan(Math.atan(pendiente)+Math.PI/8); var pendienteMenos1 = Math.tan(Math.atan(pendiente)-Math.PI/8); if(pendiente > 0 && pendienteMas1 < 0){ - pendienteMas1 = 1000000; + pendienteMas1 = 1e20;//Number.MAX_VALUE;//1000000; } if(pendiente < 0 && pendienteMenos1 > 0){ - pendienteMenos1 = -1000000; + pendienteMenos1 = -1e20;//Number.MIN_VALUE;//-1000000; } var max = (x - _x)*pendienteMas1 - (y-_y); @@ -939,17 +943,17 @@ export class CanvasComponent { pendiente = (y -_y)/(x-_x); } - + var copiaY = y; if(y>10e6){ - y = 10e6; + copiaY = 10e6; }else if (y<-10e6){ - y = -10e6; + copiaY = -10e6; } if(move){ - context.moveTo(x,y); + context.moveTo(x,copiaY); move = false; }else{ - context.lineTo(x, y); + context.lineTo(x, copiaY); } } _x = x;