Skip to content
Snippets Groups Projects
Commit da0147cf authored by Gonzalo Fabian Cameto Hernandez's avatar Gonzalo Fabian Cameto Hernandez
Browse files

Mejoras en la renderización de funciones

parent 648682c3
No related branches found
No related tags found
No related merge requests found
...@@ -176,7 +176,7 @@ export class CanvasComponent { ...@@ -176,7 +176,7 @@ export class CanvasComponent {
this.unitY = this.canvasRef.nativeElement.height / this.rangeY; this.unitY = this.canvasRef.nativeElement.height / this.rangeY;
this.centerY = (-this.minY / this.rangeY) * this.canvasRef.nativeElement.height; this.centerY = (-this.minY / this.rangeY) * this.canvasRef.nativeElement.height;
this.centerX = (-this.minX / this.rangeX) * this.canvasRef.nativeElement.width; 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.scaleX = this.canvasRef.nativeElement.width / this.rangeX;
this.scaleY = this.canvasRef.nativeElement.height / this.rangeY; this.scaleY = this.canvasRef.nativeElement.height / this.rangeY;
...@@ -337,7 +337,8 @@ export class CanvasComponent { ...@@ -337,7 +337,8 @@ export class CanvasComponent {
this.unitY = this.canvasRef.nativeElement.height / this.rangeY; this.unitY = this.canvasRef.nativeElement.height / this.rangeY;
this.centerY = Math.round(Math.abs(this.minY / this.rangeY) * this.canvasRef.nativeElement.height); 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.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.scaleX = this.canvasRef.nativeElement.width / this.rangeX;
this.scaleY = this.canvasRef.nativeElement.height / this.rangeY; this.scaleY = this.canvasRef.nativeElement.height / this.rangeY;
}; };
...@@ -753,7 +754,7 @@ export class CanvasComponent { ...@@ -753,7 +754,7 @@ export class CanvasComponent {
this.unitY = this.canvasRef.nativeElement.height / this.rangeY; this.unitY = this.canvasRef.nativeElement.height / this.rangeY;
this.centerY = (this.maxY / this.rangeY) * this.canvasRef.nativeElement.height; this.centerY = (this.maxY / this.rangeY) * this.canvasRef.nativeElement.height;
this.centerX = (-this.minX / this.rangeX) * this.canvasRef.nativeElement.width; 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.scaleX = this.canvasRef.nativeElement.width / this.rangeX;
this.scaleY = this.canvasRef.nativeElement.height / this.rangeY; this.scaleY = this.canvasRef.nativeElement.height / this.rangeY;
...@@ -889,15 +890,20 @@ export class CanvasComponent { ...@@ -889,15 +890,20 @@ export class CanvasComponent {
context.beginPath(); context.beginPath();
context.lineWidth = thickness; context.lineWidth = thickness;
try { 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 move = true;
var _x = undefined; var _x = undefined;
var _y = undefined; var _y = undefined;
var pendiente = undefined; var pendiente = undefined;
var delta = 0.50; var delta = 0.50;
var nuevoY = undefined; var h = 1/this.precision;
var h = 1/1000; var delta = this.rangeX/this.precision;
var delta = this.rangeX/1000;
var anchoPunto = this.rangeX/200; var anchoPunto = this.rangeX/200;
for (var x = this.minX + this.iteration; x <= this.maxX; x += this.iteration) { for (var x = this.minX + this.iteration; x <= this.maxX; x += this.iteration) {
try{ try{
...@@ -915,17 +921,15 @@ export class CanvasComponent { ...@@ -915,17 +921,15 @@ export class CanvasComponent {
}else{ }else{
if(pendiente != undefined){ if(pendiente != undefined){
var diff = Math.abs(Math.abs(nuevoY)-Math.abs(y));
var pendienteMas1 = Math.tan(Math.atan(pendiente)+Math.PI/8); var pendienteMas1 = Math.tan(Math.atan(pendiente)+Math.PI/8);
var pendienteMenos1 = Math.tan(Math.atan(pendiente)-Math.PI/8); var pendienteMenos1 = Math.tan(Math.atan(pendiente)-Math.PI/8);
if(pendiente > 0 && pendienteMas1 < 0){ if(pendiente > 0 && pendienteMas1 < 0){
pendienteMas1 = 1000000; pendienteMas1 = 1e20;//Number.MAX_VALUE;//1000000;
} }
if(pendiente < 0 && pendienteMenos1 > 0){ if(pendiente < 0 && pendienteMenos1 > 0){
pendienteMenos1 = -1000000; pendienteMenos1 = -1e20;//Number.MIN_VALUE;//-1000000;
} }
var max = (x - _x)*pendienteMas1 - (y-_y); var max = (x - _x)*pendienteMas1 - (y-_y);
...@@ -939,17 +943,17 @@ export class CanvasComponent { ...@@ -939,17 +943,17 @@ export class CanvasComponent {
pendiente = (y -_y)/(x-_x); pendiente = (y -_y)/(x-_x);
} }
var copiaY = y;
if(y>10e6){ if(y>10e6){
y = 10e6; copiaY = 10e6;
}else if (y<-10e6){ }else if (y<-10e6){
y = -10e6; copiaY = -10e6;
} }
if(move){ if(move){
context.moveTo(x,y); context.moveTo(x,copiaY);
move = false; move = false;
}else{ }else{
context.lineTo(x, y); context.lineTo(x, copiaY);
} }
} }
_x = x; _x = x;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment