Settings for line width and text size
This commit is contained in:
parent
80d5051858
commit
8227d3974e
8 changed files with 287 additions and 46 deletions
|
@ -66,8 +66,8 @@ ApplicationWindow {
|
|||
anchors.left: parent.left
|
||||
anchors.topMargin: 5
|
||||
anchors.leftMargin: 5
|
||||
anchors.bottom: parent.bottom
|
||||
width: parent.width - 10
|
||||
height: parent.height - sidebarContents.x;
|
||||
currentIndex: sidebarSelector.currentIndex
|
||||
z: -1
|
||||
clip: true
|
||||
|
@ -101,12 +101,10 @@ ApplicationWindow {
|
|||
yaxisstep: settings.yaxisstep
|
||||
xaxisstep: settings.xaxisstep
|
||||
logscalex: settings.logscalex
|
||||
linewidth: settings.linewidth
|
||||
textsize: settings.textsize
|
||||
showxgrad: settings.showxgrad
|
||||
showygrad: settings.showygrad
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
}
|
||||
}
|
||||
|
||||
function saveDiagram(filename) {
|
||||
|
@ -130,6 +128,8 @@ ApplicationWindow {
|
|||
"xaxislabel": settings.xaxislabel,
|
||||
"yaxislabel": settings.yaxislabel,
|
||||
"logscalex": settings.logscalex,
|
||||
"linewidth": settings.linewidth,
|
||||
"textsize": settings.textsize,
|
||||
"width": root.width,
|
||||
"height": root.height,
|
||||
"objects": objs,
|
||||
|
@ -151,6 +151,10 @@ ApplicationWindow {
|
|||
settings.xaxislabel = data["xaxislabel"]
|
||||
settings.yaxislabel = data["yaxislabel"]
|
||||
settings.logscalex = data["logscalex"]
|
||||
if("linewidth" in data)
|
||||
settings.linewidth = data["linewidth"]
|
||||
if("textsize" in data)
|
||||
settings.textsize = data["textsize"]
|
||||
root.height = data["height"]
|
||||
root.width = data["width"]
|
||||
|
||||
|
@ -176,6 +180,8 @@ ApplicationWindow {
|
|||
} else {
|
||||
objectLists.update()
|
||||
}
|
||||
} else {
|
||||
error = "Invalid file provided."
|
||||
}
|
||||
if(error != "") {
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ Canvas {
|
|||
property string xlabel: ""
|
||||
property string ylabel: ""
|
||||
property int maxgradx: 8
|
||||
property double linewidth: 1
|
||||
property double textsize: 14
|
||||
property bool logscalex: false
|
||||
property bool showxgrad: false
|
||||
property bool showygrad: false
|
||||
|
@ -56,6 +58,7 @@ Canvas {
|
|||
reset(ctx)
|
||||
drawGrille(ctx)
|
||||
drawAxises(ctx)
|
||||
ctx.lineWidth = linewidth
|
||||
for(var objType in Objects.currentObjects) {
|
||||
for(var obj of Objects.currentObjects[objType]){
|
||||
ctx.strokeStyle = obj.color
|
||||
|
@ -63,6 +66,7 @@ Canvas {
|
|||
if(obj.visible) obj.draw(canvas, ctx)
|
||||
}
|
||||
}
|
||||
ctx.lineWidth = 1
|
||||
drawLabels(ctx)
|
||||
|
||||
}
|
||||
|
@ -71,7 +75,7 @@ Canvas {
|
|||
// Reset
|
||||
ctx.fillStyle = "#FFFFFF"
|
||||
ctx.strokeStyle = "#000000"
|
||||
ctx.font = "12px sans-serif"
|
||||
ctx.font = `${canvas.textsize-2}px sans-serif`
|
||||
ctx.fillRect(0,0,width,height)
|
||||
}
|
||||
|
||||
|
@ -115,12 +119,12 @@ Canvas {
|
|||
var axisxpx = y2px(0) // Y coordinate of X axis
|
||||
// Labels
|
||||
ctx.fillStyle = "#000000"
|
||||
ctx.font = "16px sans-serif"
|
||||
ctx.fillText(ylabel, axisypx+5, 24)
|
||||
ctx.font = `${canvas.textsize+2}px sans-serif`
|
||||
ctx.fillText(ylabel, axisypx+10, 24)
|
||||
var textSize = ctx.measureText(xlabel).width
|
||||
ctx.fillText(xlabel, canvasSize.width-14-textSize, axisxpx-5)
|
||||
// Axis graduation labels
|
||||
ctx.font = "12px sans-serif"
|
||||
ctx.font = `${canvas.textsize-2}px sans-serif`
|
||||
|
||||
var txtMinus = ctx.measureText('-').width
|
||||
if(showxgrad) {
|
||||
|
@ -135,8 +139,8 @@ Canvas {
|
|||
var drawX = x*xaxisstep1
|
||||
var txtX = xaxisstepExpr.simplify(x)
|
||||
var textSize = measureText(ctx, txtX, 6).height
|
||||
drawVisibleText(ctx, txtX, x2px(drawX)-4, axisxpx+6+textSize)
|
||||
drawVisibleText(ctx, '-'+txtX, x2px(-drawX)-4, axisxpx+6+textSize)
|
||||
drawVisibleText(ctx, txtX, x2px(drawX)-4, axisxpx+textsize/2+textSize)
|
||||
drawVisibleText(ctx, '-'+txtX, x2px(-drawX)-4, axisxpx+textsize/2+textSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,20 +169,20 @@ Canvas {
|
|||
}
|
||||
}
|
||||
|
||||
function drawVisibleText(ctx, text, x, y, lineHeight = 14) {
|
||||
function drawVisibleText(ctx, text, x, y) {
|
||||
if(x > 0 && x < canvasSize.width && y > 0 && y < canvasSize.height) {
|
||||
text.toString().split("\n").forEach(function(txt, i){
|
||||
ctx.fillText(txt, x, y+(lineHeight*i))
|
||||
ctx.fillText(txt, x, y+(canvas.textsize*i))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Method to calculate multi-line string dimensions
|
||||
function measureText(ctx, text, lineHeight=14) {
|
||||
function measureText(ctx, text) {
|
||||
var theight = 0
|
||||
var twidth = 0
|
||||
text.split("\n").forEach(function(txt, i){
|
||||
theight += lineHeight
|
||||
theight += canvas.textsize
|
||||
if(ctx.measureText(txt).width > twidth) twidth = ctx.measureText(txt).width
|
||||
})
|
||||
return {'width': twidth, 'height': theight}
|
||||
|
@ -217,6 +221,12 @@ Canvas {
|
|||
ctx.stroke();
|
||||
}
|
||||
|
||||
function drawDashedLine2(ctx, x1, y1, x2, y2, dashPxSize = 5) {
|
||||
ctx.setLineDash([dashPxSize, dashPxSize]);
|
||||
drawLine(ctx, x1, y1, x2, y2)
|
||||
ctx.setLineDash([]);
|
||||
}
|
||||
|
||||
function drawDashedLine(ctx, x1, y1, x2, y2, dashPxSize = 10) {
|
||||
var distance = Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
|
||||
var progPerc = dashPxSize/distance
|
||||
|
|
|
@ -35,15 +35,18 @@ ScrollView {
|
|||
property string yaxisstep: "4"
|
||||
property string xaxislabel: ""
|
||||
property string yaxislabel: ""
|
||||
property double linewidth: 1
|
||||
property double textsize: 14
|
||||
property bool logscalex: true
|
||||
property string saveFilename: ""
|
||||
property bool showxgrad: true
|
||||
property bool showygrad: true
|
||||
|
||||
Column {
|
||||
height: 30*9 //30*Math.max(1, Math.ceil(7 / columns))
|
||||
//height: 30*12 //30*Math.max(1, Math.ceil(7 / columns))
|
||||
//columns: Math.floor(width / settingWidth)
|
||||
spacing: 10
|
||||
|
||||
FileDialog {
|
||||
id: fdiag
|
||||
onAccepted: {
|
||||
|
@ -61,7 +64,6 @@ ScrollView {
|
|||
}
|
||||
}
|
||||
|
||||
// Line 1
|
||||
// Zoom
|
||||
TextSetting {
|
||||
id: zoomX
|
||||
|
@ -120,6 +122,20 @@ ScrollView {
|
|||
}
|
||||
}
|
||||
|
||||
TextSetting {
|
||||
id: xAxisStep
|
||||
height: 30
|
||||
label: "X Axis Step"
|
||||
icon: "icons/settings/xaxisstep.svg"
|
||||
width: settings.settingWidth
|
||||
defValue: settings.xaxisstep
|
||||
visible: !settings.logscalex
|
||||
onChanged: function(newValue) {
|
||||
settings.xaxisstep = newValue
|
||||
settings.changed()
|
||||
}
|
||||
}
|
||||
|
||||
TextSetting {
|
||||
id: yAxisStep
|
||||
height: 30
|
||||
|
@ -134,15 +150,31 @@ ScrollView {
|
|||
}
|
||||
|
||||
TextSetting {
|
||||
id: xAxisStep
|
||||
id: lineWidth
|
||||
height: 30
|
||||
label: "X Axis Step"
|
||||
icon: "icons/settings/xaxisstep.svg"
|
||||
isDouble: true
|
||||
label: "Line width"
|
||||
min: 1
|
||||
icon: "icons/settings/linewidth.svg"
|
||||
width: settings.settingWidth
|
||||
defValue: settings.xaxisstep
|
||||
visible: !settings.logscalex
|
||||
defValue: settings.linewidth
|
||||
onChanged: function(newValue) {
|
||||
settings.xaxisstep = newValue
|
||||
settings.linewidth = newValue
|
||||
settings.changed()
|
||||
}
|
||||
}
|
||||
|
||||
TextSetting {
|
||||
id: textSize
|
||||
height: 30
|
||||
isDouble: true
|
||||
label: "Text size (px)"
|
||||
min: 1
|
||||
icon: "icons/settings/textsize.svg"
|
||||
width: settings.settingWidth
|
||||
defValue: settings.textsize
|
||||
onChanged: function(newValue) {
|
||||
settings.textsize = newValue
|
||||
settings.changed()
|
||||
}
|
||||
}
|
||||
|
|
80
qml/icons/settings/linewidth.svg
Normal file
80
qml/icons/settings/linewidth.svg
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24.0px"
|
||||
height="24.0px"
|
||||
viewBox="0 0 24.0 24.0"
|
||||
version="1.1"
|
||||
id="SVGRoot"
|
||||
sodipodi:docname="linewidth.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<defs
|
||||
id="defs836" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="31.678384"
|
||||
inkscape:cx="6.3741139"
|
||||
inkscape:cy="13.782634"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid1406" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata839">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="fill:#000000;fill-rule:evenodd;stroke-width:3.65149"
|
||||
id="rect1420"
|
||||
width="20"
|
||||
height="2"
|
||||
x="2"
|
||||
y="3" />
|
||||
<rect
|
||||
style="fill:#000000;fill-rule:evenodd;stroke-width:5.16398"
|
||||
id="rect1420-3"
|
||||
width="20"
|
||||
height="4"
|
||||
x="2"
|
||||
y="8" />
|
||||
<rect
|
||||
style="fill:#000000;fill-rule:evenodd;stroke-width:7.30297"
|
||||
id="rect1420-3-6"
|
||||
width="20"
|
||||
height="6"
|
||||
x="2"
|
||||
y="15" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
104
qml/icons/settings/textsize.svg
Normal file
104
qml/icons/settings/textsize.svg
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24.0px"
|
||||
height="24.0px"
|
||||
viewBox="0 0 24.0 24.0"
|
||||
version="1.1"
|
||||
id="SVGRoot"
|
||||
sodipodi:docname="textsize.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<defs
|
||||
id="defs833" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="8"
|
||||
inkscape:cx="-23.020311"
|
||||
inkscape:cy="14.000331"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid1403" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:date>2021</dc:date>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Ad5001</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:rights>
|
||||
<cc:Agent>
|
||||
<dc:title>(C) Ad5001 2021 - Licensed under CC4.0-BY-NC-SA</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:rights>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-nc-nd/4.0/" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-nc-nd/4.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||
<cc:prohibits
|
||||
rdf:resource="http://creativecommons.org/ns#CommercialUse" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
id="rect1021-2"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke-width:2"
|
||||
d="M 15 7.5214844 C 13.703216 8.0990522 12.071184 9.3220377 11 12 C 8.999999 17 10.740903 17.97437 13 18 C 13.628595 18.007132 14.271011 17.836312 15 17.435547 L 15 15.429688 C 13.606222 16.332721 12 17.136051 12 16 C 12 16 12 15 13 12 C 13.53565 10.393051 14.351576 9.6589924 15 9.3125 L 15 7.5214844 z " />
|
||||
<path
|
||||
id="rect1021-2-2"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke-width:2"
|
||||
d="m 6,18.000225 c -2,0 -2,-3 -2,-3 l 1,-1 c 0,0 1,2 2,2 0,0 2,0 3,-3 1,-3 1,-4 1,-4 0,-2 -5,2 -5,2 l -1,-1 c 2.247519,-2.247519 3.646932,-3.015351 5,-3 2.259097,0.02563 4,1 1.999999,6 -1.999999,5 -5.999999,5 -5.999999,5 z"
|
||||
sodipodi:nodetypes="ccccccccscc" />
|
||||
<path
|
||||
id="rect834"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke-width:2.44949"
|
||||
d="m 17,14 h 2 v 6 h 3 l -4,4 -4,-4 h 3 z"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
<path
|
||||
id="rect834-3"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke-width:2.44949"
|
||||
d="m 17,12 h 2 V 6 h 3 L 18,2 14,6 h 3 z"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.8 KiB |
|
@ -42,6 +42,13 @@ parser.functions.integral = function(a, b, f, variable) {
|
|||
return (b-a)/6*(f(a)+4*f((a+b)/2)+f(b))
|
||||
}
|
||||
|
||||
const DERIVATION_PRECISION = 0.1
|
||||
|
||||
parser.functions.derivative = function(f, variable, x) {
|
||||
f = parser.parse(f).toJSFunction(variable, currentVars)
|
||||
return (f(x+DERIVATION_PRECISION/2)-f(x-DERIVATION_PRECISION/2))/DERIVATION_PRECISION
|
||||
}
|
||||
|
||||
class Expression {
|
||||
constructor(expr) {
|
||||
this.expr = expr
|
||||
|
|
|
@ -163,7 +163,7 @@ class Point extends DrawableObject {
|
|||
break;
|
||||
}
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = ctx.measureText(text).width
|
||||
switch(this.labelPosition) {
|
||||
case 'top':
|
||||
|
@ -266,8 +266,8 @@ class Function extends ExecutableObject {
|
|||
Function.drawFunction(canvas, ctx, this.expression, this.definitionDomain, this.destinationDomain, this.drawPoints, this.drawDashedLines)
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var posX = canvas.x2px(this.labelX)
|
||||
var posY = canvas.y2px(this.execute(this.labelX))
|
||||
switch(this.labelPosition) {
|
||||
|
@ -439,8 +439,8 @@ class GainBode extends ExecutableObject {
|
|||
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var posX = canvas.x2px(this.labelX)
|
||||
var posY = canvas.y2px(this.execute(this.labelX))
|
||||
switch(this.labelPosition) {
|
||||
|
@ -588,8 +588,8 @@ class SommeGainsBode extends DrawableObject {
|
|||
if(inDrawDom.includes(this.labelX)) {
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var posX = canvas.x2px(this.labelX)
|
||||
var posY = canvas.y2px(dbfn.execute(this.labelX))
|
||||
switch(this.labelPosition) {
|
||||
|
@ -712,8 +712,8 @@ class PhaseBode extends ExecutableObject {
|
|||
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var posX = canvas.x2px(this.labelX)
|
||||
var posY = canvas.y2px(this.execute(this.labelX))
|
||||
switch(this.labelPosition) {
|
||||
|
@ -848,8 +848,8 @@ class SommePhasesBode extends ExecutableObject {
|
|||
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var posX = canvas.x2px(this.labelX)
|
||||
var posY = canvas.y2px(this.execute(this.labelX))
|
||||
switch(this.labelPosition) {
|
||||
|
@ -993,8 +993,8 @@ class CursorX extends DrawableObject {
|
|||
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
|
||||
switch(this.labelPosition) {
|
||||
case 'left':
|
||||
|
@ -1007,7 +1007,7 @@ class CursorX extends DrawableObject {
|
|||
|
||||
if(this.targetValuePosition == 'Next to target' && this.getTargetElement() != null) {
|
||||
var text = this.getTargetValueLabel()
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var ypox = canvas.y2px(this.getTargetElement().execute(this.x.execute()))
|
||||
switch(this.labelPosition) {
|
||||
case 'left':
|
||||
|
@ -1103,8 +1103,8 @@ class Sequence extends ExecutableObject {
|
|||
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var posX = canvas.x2px(this.labelX)
|
||||
var posY = canvas.y2px(this.execute(this.labelX))
|
||||
switch(this.labelPosition) {
|
||||
|
@ -1253,8 +1253,8 @@ class RepartitionFunction extends ExecutableObject {
|
|||
|
||||
// Label
|
||||
var text = this.getLabel()
|
||||
ctx.font = "14px sans-serif"
|
||||
var textSize = canvas.measureText(ctx, text, 7)
|
||||
ctx.font = `${canvas.textsize}px sans-serif`
|
||||
var textSize = canvas.measureText(ctx, text)
|
||||
var posX = canvas.x2px(this.labelX)
|
||||
var posY = canvas.y2px(this.execute(this.labelX))
|
||||
switch(this.labelPosition) {
|
||||
|
|
|
@ -252,20 +252,22 @@ function makeExpressionReadable(str) {
|
|||
[/ \* /g, '×'],
|
||||
[/ \^ /g, '^'],
|
||||
[/\^\(([^\^]+)\)/g, function(match, p1) { return textsup(p1) }],
|
||||
[/\^([^ ]+)/g, function(match, p1) { return textsup(p1) }],
|
||||
[/\^([^ "]+)/g, function(match, p1) { return textsup(p1) }],
|
||||
[/_\(([^_]+)\)/g, function(match, p1) { return textsub(p1) }],
|
||||
[/_([^ ]+)/g, function(match, p1) { return textsub(p1) }],
|
||||
[/_([^ "]+)/g, function(match, p1) { return textsub(p1) }],
|
||||
[/\[([^\[\]]+)\]/g, function(match, p1) { return textsub(p1) }],
|
||||
[/(\d|\))×/g, '$1'],
|
||||
//[/×(\d|\()/g, '$1'],
|
||||
[/\(([^)(+.\/-]+)\)/g, "$1"],
|
||||
[/integral\((.+), ?(.+), ("|')(.+)("|'), ?("|')(.+)("|')\)/g, function(match, a, b, p1, body, p2, p3, by, p4) {
|
||||
console.log('Intégrale', a, b, body, by)
|
||||
[/integral\((.+), ?(.+), ?("|')(.+)("|'), ?("|')(.+)("|')\)/g, function(match, a, b, p1, body, p2, p3, by, p4) {
|
||||
if(a.length < b.length) {
|
||||
return `∫${textsub(a)}${textsup(b)} ${body} d${by}`
|
||||
} else {
|
||||
return `∫${textsup(b)}${textsub(a)} ${body} d${by}`
|
||||
}
|
||||
}],
|
||||
[/derivative\(?("|')(.+)("|'), ?("|')(.+)("|'), ?(.+)\)?/g, function(match, p1, body, p2, p3, by, p4, x) {
|
||||
return `d(${body.replace(new RegExp(by, 'g'), 'x')})/dx`
|
||||
}]
|
||||
]
|
||||
|
||||
|
@ -315,7 +317,7 @@ function parseName(str, removeUnallowed = true) {
|
|||
[/([^a-z]|^)gom(ega)?([^a-z]|$)/g, '$1Ω$3'],
|
||||
// Underscores
|
||||
[/_\(([^_]+)\)/g, function(match, p1) { return textsub(p1) }],
|
||||
[/_([^ ]+)/g, function(match, p1) { return textsub(p1) }],
|
||||
[/_([^" ]+)/g, function(match, p1) { return textsub(p1) }],
|
||||
// Array elements
|
||||
[/\[([^\]\[]+)\]/g, function(match, p1) { return textsub(p1) }],
|
||||
// Removing
|
||||
|
|
Loading…
Reference in a new issue