mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
fixed some errors
This commit is contained in:
parent
76ec8c9cab
commit
7fdc530b6c
5 changed files with 283 additions and 12 deletions
|
@ -78,7 +78,7 @@ function getColor(i, transparency) {
|
|||
return color;
|
||||
}
|
||||
|
||||
function drawQuadraticFunction(canvas) {
|
||||
function drawFunction(canvas) {
|
||||
var add = parseInt(document.getElementById("density").value);
|
||||
|
||||
context.beginPath();
|
||||
|
@ -88,7 +88,6 @@ function drawQuadraticFunction(canvas) {
|
|||
for (var xS=0; xS < canvas.width; xS+=add) {
|
||||
var x = r(xS);
|
||||
var y = getValue(x);
|
||||
//context.fillRect(c(x), c(y, false), add/2, add/2);
|
||||
context.lineTo(c(x, true), c(y, false));
|
||||
}
|
||||
|
||||
|
@ -215,7 +214,7 @@ function drawBoard(canvas, mouseCoords, radius) {
|
|||
context.canvas.height = window.innerHeight - 120;
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
drawQuadraticFunction(canvas);
|
||||
drawFunction(canvas);
|
||||
if (document.getElementById("pDistance").checked) {
|
||||
var add = parseInt(document.getElementById("density").value)+10;
|
||||
for (var x=0; x < canvas.width; x+=add) {
|
||||
|
@ -262,13 +261,13 @@ canvas.addEventListener('mousemove',
|
|||
var x = r(mouseCoords.x, true).toFixed(3);
|
||||
var y = r(mouseCoords.y, false).toFixed(3);
|
||||
context.fillText("(" + x + ", " + y + ")", mouseCoords.x + 5, mouseCoords.y - 5);
|
||||
var minX = findMin({"x": mouseCoords.x, "y": mouseCoords.y});
|
||||
var minX = findMin({"x": r(mouseCoords.x,true), "y": r(mouseCoords.y,false)});
|
||||
var minY = getValue(minX);
|
||||
context.beginPath();
|
||||
context.moveTo(c(minX, true), c(minY, false), false);
|
||||
context.moveTo(c(minX,true), c(minY, false));
|
||||
context.lineTo(mouseCoords.x, mouseCoords.y, false);
|
||||
context.stroke();
|
||||
var minRadius = getDist({"x":x, "y":y}, minX);
|
||||
var minRadius = euklideanDist({"x": r(mouseCoords.x,true), "y": r(mouseCoords.y,false)}, {"x":minX,"y":minY});
|
||||
|
||||
/* Draw circle */
|
||||
drawEllipse(mouseCoords.x, mouseCoords.y, minRadius*STRETCH_X, minRadius*STRETCH_Y);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue