Compare commits
No commits in common. "7408520819cd9e6e8e66371d2b5493608e75d151" and "d6a83b0f4bbb45455349ae7bdfb08740b0b95e7c" have entirely different histories.
7408520819
...
d6a83b0f4b
4 changed files with 18 additions and 44 deletions
|
@ -26,8 +26,7 @@ var ADDITIONAL_VARCHARS = [
|
|||
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
|
||||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||
"₄","₅","₆","₇","₈","₉","₀",
|
||||
"∞"
|
||||
"₄","₅","₆","₇","₈","₉","₀"
|
||||
]
|
||||
|
||||
function Instruction(type, value) {
|
||||
|
@ -692,7 +691,7 @@ TokenStream.prototype.isConst = function () {
|
|||
var i = startPos;
|
||||
for (; i < this.expression.length; i++) {
|
||||
var c = this.expression.charAt(i);
|
||||
if (c.toUpperCase() === c.toLowerCase() && !ADDITIONAL_VARCHARS.includes(c)) {
|
||||
if (c.toUpperCase() === c.toLowerCase()) {
|
||||
if (i === this.pos || (c !== '_' && c !== '.' && (c < '0' || c > '9'))) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -437,8 +437,8 @@ class UnionDomain extends Domain {
|
|||
static import(frm) {
|
||||
var domains = frm.trim().split("∪")
|
||||
if(domains.length == 1) domains = frm.trim().split("U") // Fallback
|
||||
var dom2 = parseDomain(domains.pop())
|
||||
var dom1 = parseDomain(domains.join('∪'))
|
||||
var dom1 = parseDomain(domains.pop())
|
||||
var dom2 = parseDomain(domains.join('∪'))
|
||||
return dom1.union(dom2)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ function variable(vari, wrapIn$ = false) {
|
|||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||
"₄","₅","₆","₇","₈","₉","₀",
|
||||
"pi", "∞"]
|
||||
"pi"]
|
||||
let equivalchars = ["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta",
|
||||
"\\pi","\\theta","\\kappa","\\lambda","\\mu","\\xi","\\rho",
|
||||
"\\sigma","\\sigma","\\tau","\\phi","\\chi","\\psi","\\omega",
|
||||
|
@ -124,7 +124,7 @@ function variable(vari, wrapIn$ = false) {
|
|||
"{}_{t}","{}^{1}","{}^{2}","{}^{3}","{}^{4}","{}^{5}","{}^{6}",
|
||||
"{}^{7}","{}^{8}","{}^{9}","{}^{0}","{}_{1}","{}_{2}","{}_{3}",
|
||||
"{}_{4}","{}_{5}","{}_{6}","{}_{7}","{}_{8}","{}_{9}","{}_{0}",
|
||||
"\\pi", "\\infty"]
|
||||
"\\pi"]
|
||||
if(wrapIn$)
|
||||
for(let i = 0; i < unicodechars.length; i++) {
|
||||
if(vari.includes(unicodechars[i]))
|
||||
|
|
|
@ -115,9 +115,9 @@ class Function extends Common.ExecutableObject {
|
|||
static drawFunction(canvas, ctx, expr, definitionDomain, destinationDomain, drawPoints = true, drawDash = true) {
|
||||
// Reusable in other objects.
|
||||
// Drawing small traits every 0.2px
|
||||
var pxprecision = 10
|
||||
var pxprecision = 1
|
||||
var previousX = canvas.px2x(0)
|
||||
var previousY = null;
|
||||
var previousY;
|
||||
if(definitionDomain instanceof MathLib.SpecialDomain && definitionDomain.moveSupported) {
|
||||
// Point based functions.
|
||||
previousX = definitionDomain.next(previousX)
|
||||
|
@ -147,42 +147,17 @@ class Function extends Common.ExecutableObject {
|
|||
ctx.fillRect(canvas.x2px(previousX)-1, canvas.y2px(previousY)-5, 2, 10)
|
||||
}
|
||||
} else {
|
||||
if(definitionDomain.includes(previousX))
|
||||
// PreviousY at the start of the canvas
|
||||
previousY = expr.execute(previousX)
|
||||
for(let px = pxprecision; px < canvas.canvasSize.width; px += pxprecision) {
|
||||
let currentX = canvas.px2x(px)
|
||||
if(!definitionDomain.includes(previousX) && definitionDomain.includes(currentX)) {
|
||||
// Should draw up to currentX, but NOT at previousX.
|
||||
// Need to find the starting point.
|
||||
let tmpPx = px-pxprecision
|
||||
do {
|
||||
tmpPx++;
|
||||
previousX = canvas.px2x(tmpPx)
|
||||
} while(!definitionDomain.includes(previousX))
|
||||
// Recaclulate previousY
|
||||
previousY = expr.execute(previousX)
|
||||
} else if(!definitionDomain.includes(currentX)) {
|
||||
// Next x is NOT in the definition domain.
|
||||
// Augmenting the pixel precision until this condition is fulfilled.
|
||||
let tmpPx = px
|
||||
do {
|
||||
tmpPx--;
|
||||
currentX = canvas.px2x(tmpPx)
|
||||
} while(!definitionDomain.includes(currentX) && currentX != previousX)
|
||||
}
|
||||
if(definitionDomain.includes(previousX) && definitionDomain.includes(currentX)) {
|
||||
let currentY = expr.execute(currentX)
|
||||
if(destinationDomain.includes(currentY)) {
|
||||
if(previousY != null && destinationDomain.includes(previousY)) {
|
||||
canvas.drawLine(ctx, canvas.x2px(previousX), canvas.y2px(previousY), canvas.x2px(currentX), canvas.y2px(currentY))
|
||||
}
|
||||
previousY = expr.execute(previousX)
|
||||
for(var px = pxprecision; px < canvas.canvasSize.width; px += pxprecision) {
|
||||
var currentX = canvas.px2x(px)
|
||||
var currentY = expr.execute(currentX)
|
||||
if((definitionDomain.includes(currentX) || definitionDomain.includes(previousX)) &&
|
||||
(destinationDomain.includes(currentY) || destinationDomain.includes(previousY)) &&
|
||||
Math.abs(previousY-currentY)<100) {
|
||||
canvas.drawLine(ctx, canvas.x2px(previousX), canvas.y2px(previousY), canvas.x2px(currentX), canvas.y2px(currentY))
|
||||
}
|
||||
previousY = currentY
|
||||
} else {
|
||||
previousY = null // Last y was invalid, so let's not draw anything from it.
|
||||
}
|
||||
previousX = canvas.px2x(px)
|
||||
previousX = currentX
|
||||
previousY = currentY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue