Commit ea3a6844 authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master'

parents 0b3cff4e 9ad1f83e
...@@ -691,20 +691,6 @@ class PlowRect { ...@@ -691,20 +691,6 @@ class PlowRect {
} }
} }
class GDraw {
ctx: PlowCtx;
canvas: HTMLCanvasElement;
gctx: CanvasRenderingContext2D;
offset_top: number;
constructor(ctx) {
this.ctx = ctx;
this.canvas = document.querySelector("canvas");
this.gctx = this.canvas.getContext("2d");
this.offset_top = this.canvas.offsetTop;
}
}
class PlowCtx { class PlowCtx {
gdh: Gdh = null; gdh: Gdh = null;
nodraw = 0; nodraw = 0;
...@@ -716,7 +702,7 @@ class PlowCtx { ...@@ -716,7 +702,7 @@ class PlowCtx {
a: PlowArray; a: PlowArray;
a_nc: PlowArray; a_nc: PlowArray;
name = "Claes context"; name = "Claes context";
gdraw: GDraw; gdraw: Draw;
select_object: PlowNode = null; select_object: PlowNode = null;
event_cb: (event: object, object: PlowNode, x: number, y: number) => void = null; event_cb: (event: object, object: PlowNode, x: number, y: number) => void = null;
event_object: PlowNode = null; event_object: PlowNode = null;
...@@ -724,7 +710,7 @@ class PlowCtx { ...@@ -724,7 +710,7 @@ class PlowCtx {
constructor() { constructor() {
this.a = new PlowArray(this); this.a = new PlowArray(this);
this.a_nc = new PlowArray(this); this.a_nc = new PlowArray(this);
this.gdraw = new GDraw(this); this.gdraw = new Draw(this);
this.rect = new Rect(); this.rect = new Rect();
} }
......
...@@ -46,10 +46,11 @@ ...@@ -46,10 +46,11 @@
</div> </div>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel" src="pwr.js"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="cli.js"></script> <script type="text/babel" src="cli.ts"></script>
<script type="text/babel" src="gdh.js"></script> <script type="text/babel" src="gdh.ts"></script>
<script type="text/babel" src="plow.js"></script> <script type="text/babel" src="draw.ts"></script>
<script type="text/babel" src="plow.ts"></script>
<script type="text/babel" src="ev.ts"></script> <script type="text/babel" src="ev.ts"></script>
<hr> <hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address> <address><a href="mailto:claes@debian86.ssab.com"></a></address>
......
...@@ -579,13 +579,13 @@ class Ev { ...@@ -579,13 +579,13 @@ class Ev {
case Event.Key_CtrlL: case Event.Key_CtrlL:
let o = this.ctx.get_select(); let o = this.ctx.get_select();
if (o.userdata instanceof EvItemAlarm) { if (o.userdata instanceof EvItemAlarm) {
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC).then(this.open_plc_cb); this.ctx.gdh.getObjectFromAref(o.userdata.e.supObject, GdhOp.GET_OP_METHOD_PLC).then(this.open_plc_cb);
} }
break; break;
case Event.Key_CtrlG: case Event.Key_CtrlG:
let o = this.ctx.get_select(); let o = this.ctx.get_select();
if (o.userdata instanceof EvItemAlarm) { if (o.userdata instanceof EvItemAlarm) {
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC).then(this.open_objectgraph_cb); this.ctx.gdh.getObjectFromAref(o.userdata.e.supObject, GdhOp.GET_OP_METHOD_PLC).then(this.open_objectgraph_cb);
} }
break; break;
default: default:
......
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
</div> </div>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel" src="pwr.js"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="gdh.js"></script> <script type="text/babel" src="gdh.ts"></script>
<script type="text/babel" src="draw.ts"></script>
<script type="text/babel" src="flow.ts"></script> <script type="text/babel" src="flow.ts"></script>
<hr> <hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address> <address><a href="mailto:claes@debian86.ssab.com"></a></address>
......
...@@ -214,34 +214,6 @@ enum Save { ...@@ -214,34 +214,6 @@ enum Save {
Triangle_rect_part = 2000 Triangle_rect_part = 2000
} }
class GDraw {
ctx: FlowCtx;
canvas: HTMLCanvasElement;
gctx: CanvasRenderingContext2D;
offset_top: number;
offset_left: number;
constructor(ctx: FlowCtx) {
this.ctx = ctx;
this.canvas = document.querySelector("canvas");
this.gctx = this.canvas.getContext("2d");
this.offset_top = this.canvas.offsetTop;
this.offset_left = this.canvas.offsetTop;
console.log("offset_top", this.offset_top, "offset_left", this.offset_left);
}
rect(x, y, width, height) {
this.gctx.strokeRect(x, y, width, height);
}
line(x1, y1, x2, y2) {
this.gctx.beginPath();
this.gctx.moveTo(x1, y1);
this.gctx.lineTo(x2, y2);
this.gctx.stroke();
}
}
class FlowArray { class FlowArray {
ctx: FlowCtx; ctx: FlowCtx;
a = []; a = [];
...@@ -1548,7 +1520,7 @@ class FlowCtx extends Rect { ...@@ -1548,7 +1520,7 @@ class FlowCtx extends Rect {
a: FlowArray; a: FlowArray;
a_nc: FlowArray; a_nc: FlowArray;
a_cc: FlowArray; a_cc: FlowArray;
gdraw: GDraw; gdraw: Draw;
display_level = DisplayLevel.One; display_level = DisplayLevel.One;
gdh: Gdh = null; gdh: Gdh = null;
zoom_factor = 20.0; zoom_factor = 20.0;
...@@ -1563,7 +1535,7 @@ class FlowCtx extends Rect { ...@@ -1563,7 +1535,7 @@ class FlowCtx extends Rect {
this.a = new FlowArray(this); this.a = new FlowArray(this);
this.a_nc = new FlowArray(this); this.a_nc = new FlowArray(this);
this.a_cc = new FlowArray(this); this.a_cc = new FlowArray(this);
this.gdraw = new GDraw(this); this.gdraw = new Draw(this);
} }
draw() { draw() {
......
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
<body> <body>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel" src="pwr.js"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="cli.js"></script> <script type="text/babel" src="cli.ts"></script>
<script type="text/babel" src="gdh.js"></script> <script type="text/babel" src="gdh.ts"></script>
<script type="text/babel" src="draw.ts"></script>
<script type="text/babel" src="glow.ts"></script> <script type="text/babel" src="glow.ts"></script>
<script type="text/babel" src="glow_color.ts"></script> <script type="text/babel" src="glow_color.ts"></script>
...@@ -25,7 +26,6 @@ ...@@ -25,7 +26,6 @@
<script type="text/babel" src="glow_con.ts"></script> <script type="text/babel" src="glow_con.ts"></script>
<script type="text/babel" src="glow_conclass.ts"></script> <script type="text/babel" src="glow_conclass.ts"></script>
<script type="text/babel" src="glow_conpoint.ts"></script> <script type="text/babel" src="glow_conpoint.ts"></script>
<script type="text/babel" src="glow_draw.ts"></script>
<script type="text/babel" src="glow_line.ts"></script> <script type="text/babel" src="glow_line.ts"></script>
<script type="text/babel" src="glow_node.ts"></script> <script type="text/babel" src="glow_node.ts"></script>
<script type="text/babel" src="glow_nodeclass.ts"></script> <script type="text/babel" src="glow_nodeclass.ts"></script>
......
...@@ -108,7 +108,7 @@ class Appl { ...@@ -108,7 +108,7 @@ class Appl {
let arrTmp = ["pwrb", "pwrs", "nmps", "profibus", "otherio", "opc", let arrTmp = ["pwrb", "pwrs", "nmps", "profibus", "otherio", "opc",
"basecomponent", "abb", "siemens", "ssabox"]; "basecomponent", "abb", "siemens", "ssabox"];
if (arrTmp.some(e => urlValue.startsWith(e + "_"))) { // Object reference manual if (arrTmp.some(e => urlValue.startsWith(e + "_"))) { // Object reference manual
urlValue = "$pwr_doc/" + getLang() + "/orm/" + urlValue; urlValue = "$pwr_doc/en_us/orm/" + urlValue;
} }
console.log("open url " + urlValue); console.log("open url " + urlValue);
...@@ -160,15 +160,15 @@ class Appl { ...@@ -160,15 +160,15 @@ class Appl {
} }
} }
} else if (command === ("HELP")) { } else if (command === ("HELP")) {
let fileName = "xtt_help_"; let fileName = "/pwrp_web/xtt_help_";
let bookmarkValue = null; let bookmarkValue = null;
if (cli.qualifierFound("/VERSION")) { if (cli.qualifierFound("/VERSION")) {
fileName = this.pwrHost + "xtt_version_help_version.html"; fileName = window.location.hostname + "/pwr_doc/xtt_version_help_version.html";
this.openURL(fileName, null); this.openURL(fileName, null);
} else { } else {
if (cli.qualifierFound("/BASE")) { // Not language dependent !! TODO if (cli.qualifierFound("/BASE")) { // Not language dependent !! TODO
fileName = this.pwrHost + "help/xtt_help_"; fileName = "/pwr_doc/help/xtt_help_";
} }
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
...@@ -179,14 +179,14 @@ class Appl { ...@@ -179,14 +179,14 @@ class Appl {
let arrTmp = ["pwrb", "pwrs", "nmps", "profibus", "otherio", "opc", let arrTmp = ["pwrb", "pwrs", "nmps", "profibus", "otherio", "opc",
"basecomponent", "abb", "siemens", "ssabox"]; "basecomponent", "abb", "siemens", "ssabox"];
if (arrTmp.some(e => fileName.startsWith(e + "_"))) { // Object reference manual if (arrTmp.some(e => fileName.startsWith(e + "_"))) { // Object reference manual
fileName = "$pwr_doc/orm/" + fileName; fileName = "/pwr_doc/orm/" + fileName;
} }
bookmarkValue = getQualIfExists("/BOOKMARK"); bookmarkValue = getQualIfExists("/BOOKMARK");
fileName += ".html"; fileName += ".html";
console.log("Loading helpfile \"" + fileName + "\""); console.log("Loading helpfile \"" + fileName + "\"");
this.openURL(fileName, bookmarkValue); this.openURL(window.location.hostname + fileName, bookmarkValue);
} }
} else if (command === ("CHECK")) { } else if (command === ("CHECK")) {
let cli_arg1 = getQualIfExists("cli_arg1"); let cli_arg1 = getQualIfExists("cli_arg1");
......
...@@ -5992,6 +5992,180 @@ class DynFillLevel extends DynElem { ...@@ -5992,6 +5992,180 @@ class DynFillLevel extends DynElem {
} }
} }
class DynDigCommand extends DynElem {
command = "";
a = null;
first_scan = true;
level = 0;
constructor(dyn) {
super(dyn, DynPrio.DigCommand);
this.dyn_type1 = DynType1.DigCommand;
}
connect(object) {
this.a = new DynReference(this.dyn, this.attribute);
this.a.connect(this.dyn);
if (!this.a.sts) {
console.log("DigCommand: " + this.attribute);
return 1;
}
return 1;
}
disconnect() {
if (this.a) {
this.a.disconnect();
}
}
scan(object) {
if (this.a === null || !this.a.sts) {
return;
}
let value = this.dyn.getDig(this.a.p, this.a.typeid, this.a.bitmask, this.a.database);
value = (this.a.inverted) ? !value : value;
if (this.first_scan) {
this.a.oldValue = value;
this.first_scan = false;
return;
}
if ((!this.level && value && !this.a.oldValue) || (this.level && value)) {
let cmd = this.dyn.graph.getCommand(this.command);
this.dyn.graph.command(cmd);
return;
}
this.a.oldValue = value;
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case DynSave.DigCommand:
break;
case DynSave.DigCommand_attribute:
if (tokens.length > 1) {
this.attribute = tokens[1];
}
break;
case DynSave.DigCommand_command:
if (tokens.length > 1) {
this.command = tokens[1];
}
break;
case DynSave.DigCommand_level:
this.level = parseInt(tokens[1], 10);
break;
case DynSave.DigCommand_instance:
this.instance = parseInt(tokens[1], 10);
break;
case DynSave.DigCommand_instance_mask:
this.instance_mask = parseInt(tokens[1], 10);
break;
case DynSave.End:
return i;
default:
console.log("Syntax error in DynDigCommand");
break;
}
}
return i;
}
}
class DynDigScript extends DynElem {
script = "";
a = null;
first_scan = true;
level = 0;
constructor(dyn) {
super(dyn, DynPrio.DigScript);
this.dyn_type2 = DynType2.DigScript;
}
connect(object) {
this.a = new DynReference(this.dyn, this.attribute);
this.a.connect(this.dyn);
if (!this.a.sts) {
console.log("DigScript: " + this.attribute);
return 1;
}
return 1;
}
disconnect() {
if (this.a) {
this.a.disconnect();
}
}
scan(object) {
if (this.a === null || !this.a.sts) {
return;
}
let value = this.dyn.getDig(this.a.p, this.a.typeid, this.a.bitmask, this.a.database);
value = (this.a.inverted) ? !value : value;
if (this.first_scan) {
this.a.oldValue = value;
this.first_scan = false;
return;
}
if ((!this.level && value && !this.a.oldValue) || (this.level && value)) {
this.dyn.graph.script(this.script);
}
this.a.oldValue = value;
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case DynSave.DigScript:
break;
case DynSave.DigScript_attribute:
if (tokens.length > 1) {
this.attribute = tokens[1];
}
break;
case DynSave.DigScript_level:
this.level = parseInt(tokens[1], 10);
break;
case DynSave.DigScript_script_len:
break;
case DynSave.DigScript_script:
this.script = lines.join("\n").split(/[^\\]"/)[0];
break;
case DynSave.End:
return i;
default:
console.log("Syntax error in DynDigScript");
break;
}
}
return i;
}
}
class DynSetDig extends DynElem { class DynSetDig extends DynElem {
constructor(dyn) { constructor(dyn) {
super(dyn, DynPrio.SetDig); super(dyn, DynPrio.SetDig);
...@@ -8919,6 +9093,118 @@ class DynMethodPulldownMenu extends DynElem { ...@@ -8919,6 +9093,118 @@ class DynMethodPulldownMenu extends DynElem {
} }
} }
class DynCatchSignal extends DynElem {
signal_name = "";
constructor(dyn) {
super(dyn, DynPrio.CatchSignal);
this.action_type1 = ActionType1.CatchSignal;
}
action(object, e) {
if (!this.dyn.graph.isAuthorized(this.dyn.access)) {
return 1;
}
if (e.event === Event.Signal && e.signal.signal_name === this.signal_name) {
let e = new GlowEvent();
e.event = Event.MB1Click;
e.object = object;
let sts = this.dyn.action(object, e);
if (sts === GLOW__NO_PROPAGATE || sts === GLOW__TERMINATED || sts === GLOW__SUBTERMINATED) {
return sts;
}
}
return 1;
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case DynSave.CatchSignal:
break;
case DynSave.CatchSignal_signal_name:
this.signal_name = tokens[1];
break;
case DynSave.End:
return i;
default:
console.log("Syntax error in DynCatchSignal");
break;
}
}
return i;
}
}
class DynEmitSignal extends DynElem {
signal_name = "";
global = 0;
constructor(dyn) {
super(dyn, DynPrio.EmitSignal);
this.action_type1 = ActionType1.EmitSignal;
}
action(object, e) {
if (!this.dyn.graph.isAuthorized(this.dyn.access)) {
return 1;
}
switch (e.event) {
case Event.MB1Down:
object.setColorInverse(1);
break;
case Event.MB1Up:
object.setColorInverse(0);
break;
case Event.Key_Return:
case Event.MB1Click:
if (this.global) {
let command = "emit signal/signalname=" + this.signal_name;
let cmd = this.dyn.graph.getCommand(command);
this.dyn.graph.command(cmd);
} else {
//TODO:
//this.dyn.graph.signalSend(this.signal_name);
}
}
return 1;
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case DynSave.EmitSignal:
break;
case DynSave.EmitSignal_signal_name:
this.signal_name = tokens[1];
break;
case DynSave.EmitSignal_global:
this.global = Number(tokens[1]);
case DynSave.End:
return i;
default:
console.log("Syntax error in DynEmitSignal");
break;
}
}
return i;
}
}
class DynPopupMenu extends DynElem { class DynPopupMenu extends DynElem {
ref_object; ref_object;
......
...@@ -81,7 +81,7 @@ class GlowArc { ...@@ -81,7 +81,7 @@ class GlowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1,
this.angle2, this.draw_type, idx, highlight); this.angle2, this.draw_type, false, idx, highlight);
} }
draw_shadow(border, shadow, highlight, hot) { draw_shadow(border, shadow, highlight, hot) {
...@@ -110,78 +110,78 @@ class GlowArc { ...@@ -110,78 +110,78 @@ class GlowArc {
this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx + this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx +
offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs *
2, this.angle1 + 45, this.angle2 - 45, 2, this.angle1 + 45, this.angle2 - 45,
GlowColor.shift_drawtype(this.draw_type, -2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, -2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx + this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx +
offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2, offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2,
this.angle1, this.angle2 - 45, this.angle1, this.angle2 - 45,
GlowColor.shift_drawtype(this.draw_type, 2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, 2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs, this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs,
Math.max(0, ur_x - ll_x - idx + offs * 2), Math.max(0, ur_x - ll_x - idx + offs * 2),
Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1 + Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1 +
45, this.angle2 - 45, 45, this.angle2 - 45,
GlowColor.shift_drawtype(this.draw_type, 2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, 2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs, this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs,
Math.max(0, ur_x - ll_x - idx + offs * 2), Math.max(0, ur_x - ll_x - idx + offs * 2),
Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2 - Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2 -
45, GlowColor.shift_drawtype(this.draw_type, -2, null), ish - 1, 45, GlowColor.shift_drawtype(this.draw_type, -2, null), false, ish - 1,
highlight); highlight);
} else if (this.angle1 === 90) { } else if (this.angle1 === 90) {
this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx + this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx +
offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2, offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2,
this.angle1, this.angle2, this.angle1, this.angle2,
GlowColor.shift_drawtype(this.draw_type, -2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, -2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs, this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs,
Math.max(0, ur_x - ll_x - idx + offs * 2), Math.max(0, ur_x - ll_x - idx + offs * 2),
Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2, Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2,
GlowColor.shift_drawtype(this.draw_type, 2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, 2, null), false, ish - 1,
highlight); highlight);
} else if (this.angle1 === 180) { } else if (this.angle1 === 180) {
this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx + this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx +
offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs *
2, this.angle1 + 45, this.angle2 - 45, 2, this.angle1 + 45, this.angle2 - 45,
GlowColor.shift_drawtype(this.draw_type, 2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, 2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx + this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx +
offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2, offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2,
this.angle1, this.angle2 - 45, this.angle1, this.angle2 - 45,
GlowColor.shift_drawtype(this.draw_type, -2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, -2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs, this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs,
Math.max(0, ur_x - ll_x - idx + offs * 2), Math.max(0, ur_x - ll_x - idx + offs * 2),
Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1 + Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1 +
45, this.angle2 - 45, 45, this.angle2 - 45,
GlowColor.shift_drawtype(this.draw_type, -2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, -2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs, this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs,
Math.max(0, ur_x - ll_x - idx + offs * 2), Math.max(0, ur_x - ll_x - idx + offs * 2),
Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2 - Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2 -
45, GlowColor.shift_drawtype(this.draw_type, 2, null), ish - 1, 45, GlowColor.shift_drawtype(this.draw_type, 2, null), false, ish - 1,
highlight); highlight);
} else if (this.angle1 === 270) { } else if (this.angle1 === 270) {
this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx + this.ctx.gdraw.arc(ll_x + idx / 2 - idx + offs, ll_y + idx / 2 - idx +
offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2, offs, ur_x - ll_x + idx - offs * 2, ur_y - ll_y + idx - offs * 2,
this.angle1, this.angle2, this.angle1, this.angle2,
GlowColor.shift_drawtype(this.draw_type, 2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, 2, null), false, ish - 1,
highlight); highlight);
this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs, this.ctx.gdraw.arc(ll_x + idx / 2 - offs, ll_y + idx / 2 - offs,
Math.max(0, ur_x - ll_x - idx + offs * 2), Math.max(0, ur_x - ll_x - idx + offs * 2),
Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2, Math.max(0, ur_y - ll_y - idx + offs * 2), this.angle1, this.angle2,
GlowColor.shift_drawtype(this.draw_type, -2, null), ish - 1, GlowColor.shift_drawtype(this.draw_type, -2, null), false, ish - 1,
highlight); highlight);
} }
} }
if (border !== 0) { if (border !== 0) {
this.ctx.gdraw.arc(ll_x + idx / 2 - idx, ll_y + idx / 2 - idx, ur_x - this.ctx.gdraw.arc(ll_x + idx / 2 - idx, ll_y + idx / 2 - idx, ur_x -
ll_x + idx, ur_y - ll_y + idx, this.angle1, this.angle2, ll_x + idx, ur_y - ll_y + idx, this.angle1, this.angle2,
DrawType.Line, 0, highlight); DrawType.Line, false, 0, highlight);
if (idx > 0) { if (idx > 0) {
this.ctx.gdraw.arc(ll_x + idx / 2, ll_y + idx / 2, this.ctx.gdraw.arc(ll_x + idx / 2, ll_y + idx / 2,
Math.max(0, ur_x - ll_x - idx), Math.max(0, ur_y - ll_y - idx), Math.max(0, ur_x - ll_x - idx), Math.max(0, ur_y - ll_y - idx),
this.angle1, this.angle2, DrawType.Line, 0, highlight); this.angle1, this.angle2, DrawType.Line, false, 0, highlight);
} }
} }
} }
......
...@@ -203,21 +203,16 @@ class GlowNodeClass { ...@@ -203,21 +203,16 @@ class GlowNodeClass {
Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) { Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) {
// Borders are given i x0, y0, x1, y1 // Borders are given i x0, y0, x1, y1
// Will not work in rotated nodes // Will not work in rotated nodes
let kx1, kx2, ky1, ky2; let k1 = new Point(base.x0, base.y0);
let k2 = new Point(base.x1, base.y1);
if (t === null) { if (t !== null) {
kx1 = base.x0; k1 = t.apply(k1);
kx2 = base.x1; k2 = t.apply(k2);
ky1 = base.y0;
ky2 = base.y1;
} else {
kx1 = t.x(base.x0, base.y0);
kx2 = t.x(base.x1, base.y1);
ky1 = t.y(base.x0, base.y0);
ky2 = t.y(base.x1, base.y1);
} }
g.set(Rect.union(g, new Rect(Math.min(kx1, kx2), Math.min(ky1, ky2), Math.max(kx1, kx2), Math.max(ky1, ky2)))); g.set(Rect.union(g, new Rect(Math.min(k1.x, k2.x), Math.min(k1.y, k2.y),
Math.max(k1.x, k2.x), Math.max(k1.y, k2.y))));
} else { } else {
this.a.forEach(e => e.get_borders(t, g)); this.a.forEach(e => e.get_borders(t, g));
} }
......
...@@ -5,7 +5,7 @@ class GlowRect { ...@@ -5,7 +5,7 @@ class GlowRect {
draw_type; draw_type;
line_width; line_width;
display_level; display_level;
fill; fill: boolean;
constructor(ctx) { constructor(ctx) {
this.ctx = ctx; this.ctx = ctx;
...@@ -32,7 +32,7 @@ class GlowRect { ...@@ -32,7 +32,7 @@ class GlowRect {
this.display_level = parseInt(tokens[1], 10); this.display_level = parseInt(tokens[1], 10);
break; break;
case GlowSave.Rect_fill: case GlowSave.Rect_fill:
this.fill = parseInt(tokens[1], 10); this.fill = Boolean(parseInt(tokens[1], 10));
break; break;
case GlowSave.Rect_ll: case GlowSave.Rect_ll:
i = this.ll.open(lines, i + 1); i = this.ll.open(lines, i + 1);
...@@ -51,9 +51,11 @@ class GlowRect { ...@@ -51,9 +51,11 @@ class GlowRect {
return i; return i;
} }
draw(highlight, hot) { draw(pos, highlight = 0, hot = 0, node = null) {
} let idx = this.line_width + hot;
idx = clamp(idx, 0, DRAW_TYPE_SIZE - 1);
draw_shadow(border, shadow, highlight, hot) { this.ctx.gdraw.rect(this.ll.x + pos.x, this.ll.y + pos.y,
this.ur.x - this.ll.x, this.ur.y - this.ll.y,
this.draw_type, this.fill, idx * this.fill, highlight);
} }
} }
\ No newline at end of file
...@@ -47,9 +47,10 @@ class GlowText { ...@@ -47,9 +47,10 @@ class GlowText {
return i; return i;
} }
draw(hightlight, hot) { draw(pos, hightlight = 0, hot = 0, node = null) {
} let idx = clamp(this.text_size, 0, DRAW_TYPE_SIZE - 1);
this.ctx.gdraw.text(this.p.x + pos.x, this.p.y + pos.y, this.text,
draw_shadow(border, shadow, hightlight, hot) { this.draw_type, this.color_drawtype, idx, hightlight, Font.Helvetica,
(8 + 2 * this.text_size));
} }
} }
\ No newline at end of file
class GlowTransform { class Matrix {
a11 = 1; a11 = 1;
a12 = 0; a12 = 0;
a13 = 0; a13 = 0;
...@@ -6,24 +6,60 @@ class GlowTransform { ...@@ -6,24 +6,60 @@ class GlowTransform {
a22 = 1; a22 = 1;
a23 = 0; a23 = 0;
rotation = 0; rotation = 0;
s: GlowTransform;
stored = false;
set(o: GlowTransform) { set(m: Matrix) {
this.a11 = o.a11; this.a11 = m.a11;
this.a12 = o.a12; this.a12 = m.a12;
this.a13 = o.a13; this.a13 = m.a13;
this.a21 = o.a21; this.a21 = m.a21;
this.a22 = o.a22; this.a22 = m.a22;
this.a23 = o.a23; this.a23 = m.a23;
this.rotation = o.rotation; this.rotation = m.rotation;
}
apply(p: Point) {
return new Point(
p.x * this.a11 + p.y * this.a12 + this.a13,
p.x * this.a21 + p.y * this.a22 + this.a23
);
}
static multiply(a, b) {
if (b === null) {
return a;
}
if (a === null) {
return b;
}
let tmp = new Matrix();
tmp.a11 = a.a11 * b.a11 + a.a12 * b.a21;
tmp.a12 = a.a11 * b.a12 + a.a12 * b.a22;
tmp.a13 = a.a11 * b.a13 + a.a12 * b.a23 + a.a13;
tmp.a21 = a.a21 * b.a11 + a.a22 * b.a21;
tmp.a22 = a.a21 * b.a12 + a.a22 * b.a22;
tmp.a23 = a.a21 * b.a13 + a.a22 * b.a23 + a.a23;
tmp.rotation = a.rotation + b.rotation;
return tmp;
}
vertical_scale() {
return Math.sqrt(this.a12 * this.a12 + this.a22 * this.a22);
} }
}
class GlowTransform extends Matrix {
s: Matrix;
stored = false;
store() { store() {
this.s.set(this); this.s.set(this);
this.stored = true; this.stored = true;
} }
revert() {
this.set(this.s);
}
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
...@@ -65,68 +101,6 @@ class GlowTransform { ...@@ -65,68 +101,6 @@ class GlowTransform {
return i; return i;
} }
rot() {
if (arguments.length === 1 && arguments[0] !== null) {
let t = arguments[0];
return t.rotation + this.rotation;
} else {
return this.rotation;
}
}
x() {
if (arguments.length === 3 && arguments[0] !== null) {
let t = arguments[0];
let x1 = arguments[1];
let y1 = arguments[2];
let tmp = GlowTransform.multiply(t, this);
return x1 * tmp.a11 + y1 * tmp.a12 + tmp.a13;
} else {
let x1 = arguments[0];
let y1 = arguments[1];
return x1 * this.a11 + y1 * this.a12 + this.a13;
}
}
y() {
if (arguments.length === 3 && arguments[0] !== null) {
let t = arguments[0];
let x1 = arguments[1];
let y1 = arguments[2];
let tmp = GlowTransform.multiply(t, this);
return x1 * tmp.a21 + y1 * tmp.a22 + tmp.a23;
} else {
let x1 = arguments[0];
let y1 = arguments[1];
return x1 * this.a21 + y1 * this.a22 + this.a23;
}
}
static multiply(a, b) {
let tmp = new GlowTransform();
tmp.a11 = a.a11 * b.a11 + a.a12 * b.a21;
tmp.a12 = a.a11 * b.a12 + a.a12 * b.a22;
tmp.a13 = a.a11 * b.a13 + a.a12 * b.a23 + a.a13;
tmp.a21 = a.a21 * b.a11 + a.a22 * b.a21;
tmp.a22 = a.a21 * b.a12 + a.a22 * b.a22;
tmp.a23 = a.a21 * b.a13 + a.a22 * b.a23 + a.a23;
tmp.rotation = a.rotation + b.rotation;
return tmp;
}
set_from_stored(t) {
this.set(GlowTransform.multiply(t, this.s));
this.a11 = t.a11 * this.s.a11 + t.a12 * this.s.a21;
this.a12 = t.a11 * this.s.a12 + t.a12 * this.s.a22;
this.a13 = t.a11 * this.s.a13 + t.a12 * this.s.a23 + t.a13;
this.a21 = t.a21 * this.s.a11 + t.a22 * this.s.a21;
this.a22 = t.a21 * this.s.a12 + t.a22 * this.s.a22;
this.a23 = t.a21 * this.s.a13 + t.a22 * this.s.a23 + t.a23;
this.rotation = this.s.rotation + t.rotation;
}
scale(sx, sy, x0, y0) { scale(sx, sy, x0, y0) {
this.a13 = this.a13 * sx + x0 * (1 - sx); this.a13 = this.a13 * sx + x0 * (1 - sx);
this.a23 = this.a23 * sy + y0 * (1 - sy); this.a23 = this.a23 * sy + y0 * (1 - sy);
...@@ -136,15 +110,6 @@ class GlowTransform { ...@@ -136,15 +110,6 @@ class GlowTransform {
this.a22 *= sy; this.a22 *= sy;
} }
scale_from_stored(sx, sy, x0, y0) {
this.a13 = this.s.a13 * sx + x0 * (1 - sx);
this.a23 = this.s.a23 * sy + y0 * (1 - sy);
this.a11 = this.s.a11 * sx;
this.a12 = this.s.a12 * sx;
this.a21 = this.s.a21 * sy;
this.a22 = this.s.a22 * sy;
}
rotate(angle, x0, y0) { rotate(angle, x0, y0) {
let sin_a; let sin_a;
let cos_a; let cos_a;
...@@ -176,28 +141,6 @@ class GlowTransform { ...@@ -176,28 +141,6 @@ class GlowTransform {
this.rotation += angle; this.rotation += angle;
} }
rotate_from_stored(angle, x0, y0) {
let sin_a;
let cos_a;
if (-90.01 < this.s.rotation + angle && this.s.rotation + angle < -89.99) {
sin_a = -1.0;
cos_a = 0.0;
} else {
sin_a = Math.sin((this.s.rotation + angle) / 180 * 3.14159);
cos_a = Math.cos((this.s.rotation + angle) / 180 * 3.14159);
}
this.a11 = this.s.a11 * cos_a - this.s.a21 * sin_a;
this.a12 = this.s.a12 * cos_a - this.s.a22 * sin_a;
this.a13 =
this.s.a13 * cos_a - this.s.a23 * sin_a + x0 * (1 - cos_a) + y0 * sin_a;
this.a21 = this.s.a11 * sin_a + this.s.a21 * cos_a;
this.a22 = this.s.a21 * sin_a + this.s.a22 * cos_a;
this.a23 =
this.s.a13 * sin_a + this.s.a23 * cos_a + y0 * (1 - cos_a) - x0 * sin_a;
this.rotation = this.s.rotation + angle;
}
move(x0, y0) { move(x0, y0) {
this.a13 += x0; this.a13 += x0;
this.a23 += y0; this.a23 += y0;
...@@ -214,7 +157,7 @@ class GlowTransform { ...@@ -214,7 +157,7 @@ class GlowTransform {
} }
reverse(x, y) { reverse(x, y) {
let p = new GlowPoint(); let p = new Point();
if (this.a11 === 0 || (this.a12 * this.a21 - this.a11 * this.a22) === 0) { if (this.a11 === 0 || (this.a12 * this.a21 - this.a11 * this.a22) === 0) {
if (this.a11 === 0 && this.a22 === 0 && this.a12 !== 0 && if (this.a11 === 0 && this.a22 === 0 && this.a12 !== 0 &&
this.a21 !== 0) { this.a21 !== 0) {
...@@ -233,16 +176,6 @@ class GlowTransform { ...@@ -233,16 +176,6 @@ class GlowTransform {
return p; return p;
} }
vertical_scale(t) {
if (t === null) {
return Math.sqrt(this.a12 * this.a12 + this.a22 * this.a22);
}
let tmp = GlowTransform.multiply(t, this);
return Math.sqrt(tmp.a12 * tmp.a12 + tmp.a22 * tmp.a22);
}
is_stored() { is_stored() {
return this.stored; return this.stored;
} }
......
...@@ -49,7 +49,7 @@ class GrowAnnot extends GlowAnnot { ...@@ -49,7 +49,7 @@ class GrowAnnot extends GlowAnnot {
return; return;
} }
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y / let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
...@@ -75,11 +75,15 @@ class GrowAnnot extends GlowAnnot { ...@@ -75,11 +75,15 @@ class GrowAnnot extends GlowAnnot {
ldraw_type = this.draw_type; ldraw_type = this.draw_type;
} }
let x1 = Math.floor((this.trf.x(t, this.p.x, this.p.y) + offset_x) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p = tmp.apply(this.p);
let y1 = Math.floor((this.trf.y(t, this.p.x, this.p.y) + offset_y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let x1 = Math.floor((p.x + offset_x) * this.ctx.mw.zoom_factor_x) -
let rot = Math.floor(this.trf.rot(t)); this.ctx.mw.offset_x;
let y1 = Math.floor((p.y + offset_y) * this.ctx.mw.zoom_factor_y) -
this.ctx.mw.offset_y;
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
rot = rot < 0 ? rot % 360 + 360 : rot % 360; rot = rot < 0 ? rot % 360 + 360 : rot % 360;
switch (this.annot_type) { switch (this.annot_type) {
...@@ -111,8 +115,8 @@ class GrowAnnot extends GlowAnnot { ...@@ -111,8 +115,8 @@ class GrowAnnot extends GlowAnnot {
if (rot < 45 || rot >= 315) { if (rot < 45 || rot >= 315) {
if (node.annotv_inputmode[this.number] !== 0 && if (node.annotv_inputmode[this.number] !== 0 &&
node.input_selected !== 0) { node.input_selected !== 0) {
this.ctx.gdraw.fill_rect(x1, y1 - height + descent, width, height, this.ctx.gdraw.rect(x1, y1 - height + descent, width, height,
DrawType.MediumGray); DrawType.MediumGray, true, 0);
} }
} else { } else {
// Text is rotated, adjust the coordinates // Text is rotated, adjust the coordinates
...@@ -143,7 +147,7 @@ class GrowAnnot extends GlowAnnot { ...@@ -143,7 +147,7 @@ class GrowAnnot extends GlowAnnot {
} }
this.ctx.gdraw.text(x1, y1, node.annotv[this.number], ldraw_type, color, this.ctx.gdraw.text(x1, y1, node.annotv[this.number], ldraw_type, color,
idx, highlight, 0, lfont, tsize, rot); idx, highlight, lfont, tsize, rot);
break; break;
case AnnotType.MultiLine: case AnnotType.MultiLine:
break; break;
...@@ -157,7 +161,7 @@ class GrowAnnot extends GlowAnnot { ...@@ -157,7 +161,7 @@ class GrowAnnot extends GlowAnnot {
return new Point(); return new Point();
} }
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y / let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
...@@ -167,8 +171,8 @@ class GrowAnnot extends GlowAnnot { ...@@ -167,8 +171,8 @@ class GrowAnnot extends GlowAnnot {
} }
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
return this.ctx.gdraw.getTextExtent(node.annotv[this.number], idx, return this.ctx.gdraw.getTextExtent(node.annotv[this.number], this.draw_type, idx,
this.font, this.draw_type); this.font);
} }
event_handler(event, fx, fy) { event_handler(event, fx, fy) {
......
...@@ -169,29 +169,24 @@ class GrowArc extends GlowArc { ...@@ -169,29 +169,24 @@ class GrowArc extends GlowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t)); let rot = Math.floor(tmp.rotation);
if (rot % 90 !== 0 && if (rot % 90 !== 0 &&
Math.abs((this.ur.x - this.ll.x) - (this.ur.y - this.ll.y)) < Math.abs((this.ur.x - this.ll.x) - (this.ur.y - this.ll.y)) <
Number.MIN_VALUE) { Number.MIN_VALUE) {
let tmp = t ? GlowTransform.multiply(t, this.trf) : this.trf; let scale = Matrix.multiply(tmp, this.trf).vertical_scale();
let scale = this.trf.vertical_scale(tmp); let x_c = ((p.x * this.ctx.mw.zoom_factor_x - this.ctx.mw.offset_x) +
let x_c = ((this.trf.x(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_x - (p2.x * this.ctx.mw.zoom_factor_x - this.ctx.mw.offset_x)) / 2;
this.ctx.mw.offset_x) + let y_c = ((p.y * this.ctx.mw.zoom_factor_y - this.ctx.mw.offset_y) +
(this.trf.x(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_x - (p2.y * this.ctx.mw.zoom_factor_y - this.ctx.mw.offset_y)) / 2;
this.ctx.mw.offset_x)) / 2;
let y_c = ((this.trf.y(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_y -
this.ctx.mw.offset_y) +
(this.trf.y(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_y -
this.ctx.mw.offset_y)) / 2;
x1 = Math.floor(-scale * x1 = Math.floor(-scale *
((this.ur.x - this.ll.x) / 2 * this.ctx.mw.zoom_factor_x) + x_c + 0.5); ((this.ur.x - this.ll.x) / 2 * this.ctx.mw.zoom_factor_x) + x_c + 0.5);
...@@ -230,8 +225,8 @@ class GrowArc extends GlowArc { ...@@ -230,8 +225,8 @@ class GrowArc extends GlowArc {
if (!display_shadow || this.shadow_width === 0 || this.angle2 !== 360) { if (!display_shadow || this.shadow_width === 0 || this.angle2 !== 360) {
if (grad === Gradient.No || fillcolor === DrawType.ColorRed) { if (grad === Gradient.No || fillcolor === DrawType.ColorRed) {
let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null); let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null);
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y -
ll_y, this.angle1 - rot, this.angle2, drawtype); ll_y, this.angle1 - rot, this.angle2, drawtype, true, 0);
} else { } else {
let fa1, fa2; let fa1, fa2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -265,15 +260,15 @@ class GrowArc extends GlowArc { ...@@ -265,15 +260,15 @@ class GrowArc extends GlowArc {
let drawtype = GlowColor.shift_drawtype(fillcolor, -drawtype_incr + chot, let drawtype = GlowColor.shift_drawtype(fillcolor, -drawtype_incr + chot,
colornode); colornode);
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 35, 140, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 35, 140,
drawtype); drawtype, true, 0);
// Draw dark shadow // Draw dark shadow
drawtype = GlowColor.shift_drawtype(fillcolor, drawtype_incr + chot, drawtype = GlowColor.shift_drawtype(fillcolor, drawtype_incr + chot,
colornode); colornode);
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 215, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 215,
140, drawtype); 140, drawtype, true, 0);
// Draw medium shadow and body // Draw medium shadow and body
if (chot === 0) { if (chot === 0) {
...@@ -282,14 +277,14 @@ class GrowArc extends GlowArc { ...@@ -282,14 +277,14 @@ class GrowArc extends GlowArc {
drawtype = GlowColor.shift_drawtype(fillcolor, chot, null); drawtype = GlowColor.shift_drawtype(fillcolor, chot, null);
} }
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, -5, 40, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, -5, 40,
drawtype); drawtype, true, 0);
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 175, 40, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 175, 40,
drawtype); drawtype, true, 0);
this.ctx.gdraw.fill_arc(ll_x + ish, ll_y + ish, ur_x - ll_x - 2 * this.ctx.gdraw.arc(ll_x + ish, ll_y + ish, ur_x - ll_x - 2 *
ish, ur_y - ll_y - 2 * ish, this.angle1 - rot, this.angle2, ish, ur_y - ll_y - 2 * ish, this.angle1 - rot, this.angle2,
drawtype); drawtype, true, 0);
} else { } else {
// Draw shadow // Draw shadow
let fb1 = GlowColor.shift_drawtype(fillcolor, -drawtype_incr + chot, let fb1 = GlowColor.shift_drawtype(fillcolor, -drawtype_incr + chot,
...@@ -328,17 +323,17 @@ class GrowArc extends GlowArc { ...@@ -328,17 +323,17 @@ class GrowArc extends GlowArc {
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1 - this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1 -
rot, this.angle2, drawtype, idx); rot, this.angle2, drawtype, false, idx);
} }
} }
get_borders(t, g) { get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let x2 = this.trf.x(t, this.ur.x, this.ur.y); let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y); let p2 = tmp.apply(this.ur);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
get_background_object_limits(t, type, x, y, bo) { get_background_object_limits(t, type, x, y, bo) {
......
...@@ -202,16 +202,17 @@ class GrowAxis extends GrowRect { ...@@ -202,16 +202,17 @@ class GrowAxis extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -232,8 +233,8 @@ class GrowAxis extends GrowRect { ...@@ -232,8 +233,8 @@ class GrowAxis extends GrowRect {
if (i % this.valuequotient === 0) { if (i % this.valuequotient === 0) {
let text = this.format_text(this.format, this.max_value - i * let text = this.format_text(this.format, this.max_value - i *
this.increment); this.increment);
let p = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx), let p = this.ctx.gdraw.getTextExtent(text, this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p.x; z_width = p.x;
z_height = p.y; z_height = p.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -275,8 +276,7 @@ class GrowAxis extends GrowRect { ...@@ -275,8 +276,7 @@ class GrowAxis extends GrowRect {
y_text = y + (z_height - z_descent) / 2; y_text = y + (z_height - z_descent) / 2;
} }
this.ctx.gdraw.text(ll_x, y_text, text, this.text_drawtype, this.ctx.gdraw.text(ll_x, y_text, text, this.text_drawtype,
this.text_color_drawtype, text_idx, highlight, 0, this.text_color_drawtype, text_idx, highlight, Font.Helvetica, tsize, 0);
Font.Helvetica, tsize, 0);
} }
} }
} }
...@@ -287,8 +287,8 @@ class GrowAxis extends GrowRect { ...@@ -287,8 +287,8 @@ class GrowAxis extends GrowRect {
// Calculate max value text height // Calculate max value text height
if (draw_text) { if (draw_text) {
let p2 = this.ctx.gdraw.getTextExtent("0", Math.max(0, text_idx), let p2 = this.ctx.gdraw.getTextExtent("0", this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p2.x; z_width = p2.x;
z_height = p2.y; z_height = p2.y;
...@@ -314,8 +314,8 @@ class GrowAxis extends GrowRect { ...@@ -314,8 +314,8 @@ class GrowAxis extends GrowRect {
if (draw_text && i % this.valuequotient === 0) { if (draw_text && i % this.valuequotient === 0) {
let text = let text =
this.format_text(this.format, this.max_value - i * this.increment); this.format_text(this.format, this.max_value - i * this.increment);
let p3 = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx), let p3 = this.ctx.gdraw.getTextExtent(text, this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p3.x; z_width = p3.x;
z_height = p3.y; z_height = p3.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -330,7 +330,7 @@ class GrowAxis extends GrowRect { ...@@ -330,7 +330,7 @@ class GrowAxis extends GrowRect {
} }
this.ctx.gdraw.text(x_text, ll_y + z_height - z_descent, text, this.ctx.gdraw.text(x_text, ll_y + z_height - z_descent, text,
this.text_drawtype, this.text_color_drawtype, text_idx, highlight, this.text_drawtype, this.text_color_drawtype, text_idx, highlight,
0, Font.Helvetica, tsize, 0); Font.Helvetica, tsize, 0);
} }
} }
} }
...@@ -345,8 +345,8 @@ class GrowAxis extends GrowRect { ...@@ -345,8 +345,8 @@ class GrowAxis extends GrowRect {
if (i % this.valuequotient === 0) { if (i % this.valuequotient === 0) {
let text = this.format_text(this.format, this.max_value - i * let text = this.format_text(this.format, this.max_value - i *
this.increment); this.increment);
let p4 = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx), let p4 = this.ctx.gdraw.getTextExtent(text, this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p4.x; z_width = p4.x;
z_height = p4.y; z_height = p4.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -388,8 +388,7 @@ class GrowAxis extends GrowRect { ...@@ -388,8 +388,7 @@ class GrowAxis extends GrowRect {
y_text = y + (z_height - z_descent) / 2; y_text = y + (z_height - z_descent) / 2;
} }
this.ctx.gdraw.text(x_text, y_text, text, this.text_drawtype, this.ctx.gdraw.text(x_text, y_text, text, this.text_drawtype,
this.text_color_drawtype, text_idx, highlight, 0, this.text_color_drawtype, text_idx, highlight, Font.Helvetica, tsize, 0);
Font.Helvetica, tsize, 0);
} }
} }
} else { // if ( 225 < rotation && rotation <= 315) } else { // if ( 225 < rotation && rotation <= 315)
...@@ -399,8 +398,8 @@ class GrowAxis extends GrowRect { ...@@ -399,8 +398,8 @@ class GrowAxis extends GrowRect {
// Calculate max value text height // Calculate max value text height
if (draw_text) { if (draw_text) {
let p5 = this.ctx.gdraw.getTextExtent("0", Math.max(0, text_idx), let p5 = this.ctx.gdraw.getTextExtent("0", this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p5.x; z_width = p5.x;
z_height = p5.y; z_height = p5.y;
...@@ -424,8 +423,8 @@ class GrowAxis extends GrowRect { ...@@ -424,8 +423,8 @@ class GrowAxis extends GrowRect {
if (draw_text && i % this.valuequotient === 0) { if (draw_text && i % this.valuequotient === 0) {
let text = let text =
this.format_text(this.format, this.max_value - i * this.increment); this.format_text(this.format, this.max_value - i * this.increment);
let p6 = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx), let p6 = this.ctx.gdraw.getTextExtent(text, this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p6.x; z_width = p6.x;
z_height = p6.y; z_height = p6.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -439,8 +438,7 @@ class GrowAxis extends GrowRect { ...@@ -439,8 +438,7 @@ class GrowAxis extends GrowRect {
x_text = x - (z_width) / 2; x_text = x - (z_width) / 2;
} }
this.ctx.gdraw.text(x_text, ur_y, text, this.text_drawtype, this.ctx.gdraw.text(x_text, ur_y, text, this.text_drawtype,
this.text_color_drawtype, text_idx, highlight, 0, this.text_color_drawtype, text_idx, highlight, Font.Helvetica, tsize, 0);
Font.Helvetica, tsize, 0);
} }
} }
} }
...@@ -462,15 +460,15 @@ class GrowAxis extends GrowRect { ...@@ -462,15 +460,15 @@ class GrowAxis extends GrowRect {
this.max_value = maxval; this.max_value = maxval;
this.min_value = minval; this.min_value = minval;
let x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) * let p1 = this.trf.apply(this.ll);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p2 = this.trf.apply(this.ur);
let y1 = Math.floor(this.trf.y(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) * let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(this.ur.x, this.ur.y) * let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation = (this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) *
360; 360;
if (keep_settings === 0) { if (keep_settings === 0) {
......
...@@ -133,16 +133,17 @@ class GrowAxisArc extends GrowArc { ...@@ -133,16 +133,17 @@ class GrowAxisArc extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -168,8 +169,8 @@ class GrowAxisArc extends GrowArc { ...@@ -168,8 +169,8 @@ class GrowAxisArc extends GrowArc {
} else { } else {
text = this.format_text(this.format, this.min_value + this.increment); text = this.format_text(this.format, this.min_value + this.increment);
} }
let p = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx), let p = this.ctx.gdraw.getTextExtent(text, this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p.x; z_width = p.x;
z_height = p.y; z_height = p.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -209,8 +210,8 @@ class GrowAxisArc extends GrowArc { ...@@ -209,8 +210,8 @@ class GrowAxisArc extends GrowArc {
(this.increment < 0 && i === 0)))) { (this.increment < 0 && i === 0)))) {
text = this.format_text(this.format, this.min_value + i * text = this.format_text(this.format, this.min_value + i *
this.increment); this.increment);
p = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx), p = this.ctx.gdraw.getTextExtent(text, this.text_drawtype, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype); Font.Helvetica);
z_width = p.x; z_width = p.x;
z_height = p.y; z_height = p.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -228,8 +229,7 @@ class GrowAxisArc extends GrowArc { ...@@ -228,8 +229,7 @@ class GrowAxisArc extends GrowArc {
xt -= z_width / 2; xt -= z_width / 2;
} }
this.ctx.gdraw.text(xt, yt, text, this.text_drawtype, this.ctx.gdraw.text(xt, yt, text, this.text_drawtype,
this.text_color_drawtype, text_idx, highlight, 0, this.text_color_drawtype, text_idx, highlight, Font.Helvetica, tsize, 0);
Font.Helvetica, tsize, 0);
} }
} }
} }
...@@ -251,15 +251,15 @@ class GrowAxisArc extends GrowArc { ...@@ -251,15 +251,15 @@ class GrowAxisArc extends GrowArc {
this.max_value = maxval; this.max_value = maxval;
this.min_value = minval; this.min_value = minval;
let x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) * let p1 = this.trf.apply(this.ll);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p2 = this.trf.apply(this.ur);
let y1 = Math.floor(this.trf.y(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) * let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(this.ur.x, this.ur.y) * let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation = (this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) *
360; 360;
if (keep_settings === 0) { if (keep_settings === 0) {
......
...@@ -108,29 +108,29 @@ class GrowBar extends GrowRect { ...@@ -108,29 +108,29 @@ class GrowBar extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
if (this.fill !== 0) { if (this.fill) {
let drawtype = let drawtype =
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight, GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0); highlight, colornode, 1, 0);
if (grad === Gradient.No) { if (grad === Gradient.No) {
this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype); drawtype, true, 0);
} else { } else {
let rotation = (t) ? this.trf.rot(t) : this.trf.rot(); let rotation = (t) ? this.trf.rotation + t.rotation : this.trf.rotation;
let fa1, fa2; let fa1, fa2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -155,7 +155,7 @@ class GrowBar extends GrowRect { ...@@ -155,7 +155,7 @@ class GrowBar extends GrowRect {
if (this.max_value !== this.min_value) { if (this.max_value !== this.min_value) {
let x0, y0, width, height, l_x0, l_y0, l_x1, l_y1; let x0, y0, width, height, l_x0, l_y0, l_x1, l_y1;
let rotation = (t) ? this.trf.rot(t) : this.trf.rot(); let rotation = (t) ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360; rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
x0 = ll_x; x0 = ll_x;
y0 = ll_y; y0 = ll_y;
...@@ -199,9 +199,9 @@ class GrowBar extends GrowRect { ...@@ -199,9 +199,9 @@ class GrowBar extends GrowRect {
} }
if (grad === Gradient.No) { if (grad === Gradient.No) {
this.ctx.gdraw.fill_rect(x0, y0, width, height, dt); this.ctx.gdraw.rect(x0, y0, width, height, dt, true, 0);
} else { } else {
rotation = (t) ? this.trf.rot(t) : this.trf.rot(); rotation = (t) ? this.trf.rotation + t.rotation : this.trf.rotation;
let fb1, fb2; let fb1, fb2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -225,8 +225,7 @@ class GrowBar extends GrowRect { ...@@ -225,8 +225,7 @@ class GrowBar extends GrowRect {
} }
if (this.border !== 0) { if (this.border !== 0) {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, false, idx);
0);
} }
} }
......
...@@ -92,16 +92,17 @@ class GrowBarArc extends GrowArc { ...@@ -92,16 +92,17 @@ class GrowBarArc extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -118,12 +119,12 @@ class GrowBarArc extends GrowArc { ...@@ -118,12 +119,12 @@ class GrowBarArc extends GrowArc {
let bg_drawtype = (this.background_drawtype === DrawType.No) ? this.ctx.background_color : this.background_drawtype; let bg_drawtype = (this.background_drawtype === DrawType.No) ? this.ctx.background_color : this.background_drawtype;
// Draw circle background // Draw circle background
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 0, 360, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 0, 360,
bg_drawtype); bg_drawtype, true, 0);
// Draw bar background // Draw bar background
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1 - this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1 -
Math.floor(rotation), this.angle2, drawtype); Math.floor(rotation), this.angle2, drawtype, true, 0);
// Draw bar // Draw bar
let ang = this.angle1 - rotation; let ang = this.angle1 - rotation;
...@@ -132,9 +133,8 @@ class GrowBarArc extends GrowArc { ...@@ -132,9 +133,8 @@ class GrowBarArc extends GrowArc {
} }
if (this.gradient === Gradient.No) { if (this.gradient === Gradient.No) {
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, ang,
ang, this.angle2 * (value - this.min_value) / this.angle2 * (value - this.min_value) / (this.max_value - this.min_value), this.bar_drawtype, true, 0);
(this.max_value - this.min_value), this.bar_drawtype);
} else { } else {
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -157,8 +157,8 @@ class GrowBarArc extends GrowArc { ...@@ -157,8 +157,8 @@ class GrowBarArc extends GrowArc {
} }
// Draw inner circle background // Draw inner circle background
this.ctx.gdraw.fill_arc(ll_x + width, ll_y + yscale * width, ur_x - ll_x - this.ctx.gdraw.arc(ll_x + width, ll_y + yscale * width, ur_x - ll_x -
2 * width, ur_y - ll_y - yscale * 2 * width, 0, 360, bg_drawtype); 2 * width, ur_y - ll_y - yscale * 2 * width, 0, 360, bg_drawtype, true, 0);
if (this.bar_direction === 0) { if (this.bar_direction === 0) {
ang = Math.PI * ang = Math.PI *
...@@ -181,11 +181,11 @@ class GrowBarArc extends GrowArc { ...@@ -181,11 +181,11 @@ class GrowBarArc extends GrowArc {
DrawType.LineHighlight, highlight, colornode, 0, 0); DrawType.LineHighlight, highlight, colornode, 0, 0);
this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1 - this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.angle1 -
Math.floor(rotation), this.angle2, bordercolor, idx); Math.floor(rotation), this.angle2, bordercolor, false, idx);
this.ctx.gdraw.arc(ll_x + width, ll_y + yscale * width, ur_x - ll_x - 2 * this.ctx.gdraw.arc(ll_x + width, ll_y + yscale * width, ur_x - ll_x - 2 *
width, ur_y - ll_y - yscale * 2 * width, this.angle1 - width, ur_y - ll_y - yscale * 2 * width, this.angle1 -
Math.floor(rotation), this.angle2, bordercolor, idx); Math.floor(rotation), this.angle2, bordercolor, false, idx);
ang = Math.PI * (this.angle1 - rotation) / 180; ang = Math.PI * (this.angle1 - rotation) / 180;
this.ctx.gdraw.line((ur_x + ll_x) / 2 + (ur_x - ll_x) / 2 * this.ctx.gdraw.line((ur_x + ll_x) / 2 + (ur_x - ll_x) / 2 *
......
...@@ -136,15 +136,17 @@ class GrowBarChart extends GrowRect { ...@@ -136,15 +136,17 @@ class GrowBarChart extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t));
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -230,8 +232,8 @@ class GrowBarChart extends GrowRect { ...@@ -230,8 +232,8 @@ class GrowBarChart extends GrowRect {
} else { } else {
drawtype = GlowColor.shift_drawtype(fillcolor, chot, null); drawtype = GlowColor.shift_drawtype(fillcolor, chot, null);
} }
this.ctx.gdraw.fill_rect(bar_ll_x, bar_up_ll_y, bar_ur_x - this.ctx.gdraw.rect(bar_ll_x, bar_up_ll_y, bar_ur_x -
bar_ll_x, bar_up_ur_y - bar_up_ll_y, drawtype); bar_ll_x, bar_up_ur_y - bar_up_ll_y, drawtype, true, 0);
} else { } else {
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -291,8 +293,8 @@ class GrowBarChart extends GrowRect { ...@@ -291,8 +293,8 @@ class GrowBarChart extends GrowRect {
if (grad === Gradient.No || if (grad === Gradient.No ||
fillcolor === DrawType.ColorRed || i === this.barsegments) { fillcolor === DrawType.ColorRed || i === this.barsegments) {
let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null); let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null);
this.ctx.gdraw.fill_rect(bar_ll_x, bar_down_ll_y, bar_ur_x - this.ctx.gdraw.rect(bar_ll_x, bar_down_ll_y, bar_ur_x -
bar_ll_x, bar_down_ur_y - bar_down_ll_y, drawtype); bar_ll_x, bar_down_ur_y - bar_down_ll_y, drawtype, true, 0);
} else { } else {
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -324,7 +326,7 @@ class GrowBarChart extends GrowRect { ...@@ -324,7 +326,7 @@ class GrowBarChart extends GrowRect {
DrawType.LineHighlight, highlight, colornode, 0, 0); DrawType.LineHighlight, highlight, colornode, 0, 0);
this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width, this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width,
brect_height, drawtype, idx, 0); brect_height, drawtype, false, idx);
} }
if (this.min_value >= 0) { if (this.min_value >= 0) {
brect_ll_x = bar_ll_x; brect_ll_x = bar_ll_x;
...@@ -344,7 +346,7 @@ class GrowBarChart extends GrowRect { ...@@ -344,7 +346,7 @@ class GrowBarChart extends GrowRect {
DrawType.LineHighlight, highlight, colornode, 0, 0); DrawType.LineHighlight, highlight, colornode, 0, 0);
this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width, this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width,
brect_height, drawtype, idx, 0); brect_height, drawtype, false, idx);
} }
// Draw negative bar border // Draw negative bar border
...@@ -354,7 +356,7 @@ class GrowBarChart extends GrowRect { ...@@ -354,7 +356,7 @@ class GrowBarChart extends GrowRect {
DrawType.LineHighlight, highlight, colornode, 0, 0); DrawType.LineHighlight, highlight, colornode, 0, 0);
this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width, this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width,
brect_height, drawtype, idx, 0); brect_height, drawtype, false, idx);
} }
brect_ll_x = bar_ll_x; brect_ll_x = bar_ll_x;
brect_ll_y = ur_y + this.min_value * (ur_y - ll_y) / brect_ll_y = ur_y + this.min_value * (ur_y - ll_y) /
...@@ -367,7 +369,7 @@ class GrowBarChart extends GrowRect { ...@@ -367,7 +369,7 @@ class GrowBarChart extends GrowRect {
DrawType.LineHighlight, highlight, colornode, 0, 0); DrawType.LineHighlight, highlight, colornode, 0, 0);
this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width, this.ctx.gdraw.rect(brect_ll_x, brect_ll_y, brect_width,
brect_height, drawtype, idx, 0); brect_height, drawtype, false, idx);
} }
} }
} }
...@@ -394,8 +396,7 @@ class GrowBarChart extends GrowRect { ...@@ -394,8 +396,7 @@ class GrowBarChart extends GrowRect {
drawtype = drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, false, idx);
0);
} }
} }
......
This diff is collapsed.
...@@ -77,7 +77,7 @@ class GrowCtx extends Rect { ...@@ -77,7 +77,7 @@ class GrowCtx extends Rect {
a: GlowArray; a: GlowArray;
a_nc: GlowArray; a_nc: GlowArray;
a_cc: GlowArray; a_cc: GlowArray;
gdraw: GlowDraw; gdraw: Draw;
constructor(ctx) { constructor(ctx) {
super(); super();
...@@ -90,7 +90,7 @@ class GrowCtx extends Rect { ...@@ -90,7 +90,7 @@ class GrowCtx extends Rect {
if (ctx) { if (ctx) {
this.gdraw = ctx.gdraw; this.gdraw = ctx.gdraw;
} else { } else {
this.gdraw = new GlowDraw(this); this.gdraw = new Draw(this);
} }
} }
...@@ -635,8 +635,8 @@ class GrowCtx extends Rect { ...@@ -635,8 +635,8 @@ class GrowCtx extends Rect {
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) { draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
// Draw background color // Draw background color
this.gdraw.fill_rect(0, 0, this.gdraw.canvas.width, this.gdraw.rect(0, 0, this.gdraw.canvas.width,
this.gdraw.canvas.height, this.background_color); this.gdraw.canvas.height, this.background_color, true, 0);
// Draw connections // Draw connections
this.a.forEach(function (e) { this.a.forEach(function (e) {
......
...@@ -386,20 +386,19 @@ class GrowFolder extends GrowWindow { ...@@ -386,20 +386,19 @@ class GrowFolder extends GrowWindow {
(8 + 2 * this.text_size); (8 + 2 * this.text_size);
text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1); text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1);
let dx1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let dy1 = this.trf.y(t, this.ll.x, this.ll.y); let d1 = tmp.apply(this.ll);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y); let d2 = tmp.apply(this.ur);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y); d1.x = Math.min(d1.x, d2.x);
dx1 = Math.min(dx1, dx2); d2.x = Math.max(d1.x, d2.x);
dx2 = Math.max(dx1, dx2); d1.y = Math.min(d1.y, d2.y);
dy1 = Math.min(dy1, dy2); d2.y = Math.max(d1.y, d2.y);
dy2 = Math.max(dy1, dy2);
let ll_x = Math.floor(dx1 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ll_x = Math.floor(d1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_x = Math.floor(dx2 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ur_x = Math.floor(d2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = Math.floor((dy1 + this.y_low_offs) * this.ctx.mw.zoom_factor_y) - let ur_y = Math.floor((d1.y + this.y_low_offs) * this.ctx.mw.zoom_factor_y) -
this.ctx.mw.offset_y; this.ctx.mw.offset_y;
let ll_y = Math.floor(dy1 * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let ll_y = Math.floor(d1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
...@@ -443,9 +442,9 @@ class GrowFolder extends GrowWindow { ...@@ -443,9 +442,9 @@ class GrowFolder extends GrowWindow {
p[3].y = ll_y + h; p[3].y = ll_y + h;
if (i === this.current_folder) { if (i === this.current_folder) {
this.ctx.gdraw.fill_polyline(p, 4, this.color_selected, 0); this.ctx.gdraw.polyline(p, 4, this.color_selected, true, 0);
} else { } else {
this.ctx.gdraw.fill_polyline(p, 4, this.color_unselected, 0); this.ctx.gdraw.polyline(p, 4, this.color_unselected, true, 0);
if (this.shadow !== 0) { if (this.shadow !== 0) {
this.ctx.gdraw.line(p[0].x + 1, p[0].y, p[1].x + 1, p[1].y, this.ctx.gdraw.line(p[0].x + 1, p[0].y, p[1].x + 1, p[1].y,
drawtype_light, 0, 0); drawtype_light, 0, 0);
...@@ -456,7 +455,7 @@ class GrowFolder extends GrowWindow { ...@@ -456,7 +455,7 @@ class GrowFolder extends GrowWindow {
new Point(x + h / 8, ll_y + h / 4), new Point(x + h / 8, ll_y + h / 4),
new Point(x + h / 2, ll_y + h)]; new Point(x + h / 2, ll_y + h)];
this.ctx.gdraw.fill_polyline(ps, 4, drawtype_dark, 0); this.ctx.gdraw.polyline(ps, 4, drawtype_dark, true, 0);
} }
} }
} }
...@@ -471,12 +470,11 @@ class GrowFolder extends GrowWindow { ...@@ -471,12 +470,11 @@ class GrowFolder extends GrowWindow {
this.ctx.gdraw.line(p[1].x, p[1].y + 1, p[2].x, p[2].y + 1, this.ctx.gdraw.line(p[1].x, p[1].y + 1, p[2].x, p[2].y + 1,
drawtype_light, 0, 0); drawtype_light, 0, 0);
} }
this.ctx.gdraw.polyline(p, 4, drawtype, idx, 0); this.ctx.gdraw.polyline(p, 4, drawtype, false, idx);
if (text_idx >= 0 && this.folder_text[i] !== null) { if (text_idx >= 0 && this.folder_text[i] !== null) {
this.ctx.gdraw.text(x + h / 2, ll_y + h - 2, this.folder_text[i], this.ctx.gdraw.text(x + h / 2, ll_y + h - 2, this.folder_text[i],
this.text_drawtype, this.text_color_drawtype, text_idx, highlight, 0, this.text_drawtype, this.text_color_drawtype, text_idx, highlight, Font.Helvetica, tsize, 0);
Font.Helvetica, tsize, 0);
} }
if (i === this.current_folder) { if (i === this.current_folder) {
break; break;
......
...@@ -137,31 +137,30 @@ class GrowImage extends Rect { ...@@ -137,31 +137,30 @@ class GrowImage extends Rect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
// this.ctx.gdraw.rect( ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, DrawType.Line, idx, 0);
this.ctx.gdraw.image(this.image, ll_x, ll_y, ur_x - ll_x, ur_y - ll_y); this.ctx.gdraw.image(this.image, ll_x, ll_y, ur_x - ll_x, ur_y - ll_y);
} }
get_borders(t, g) { get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let x2 = this.trf.x(t, this.ur.x, this.ur.y); let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y); let p2 = tmp.apply(this.ur);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
get_node_borders() { get_node_borders() {
...@@ -207,7 +206,8 @@ class GrowImage extends Rect { ...@@ -207,7 +206,8 @@ class GrowImage extends Rect {
let old_x_right = this.ur_x; let old_x_right = this.ur_x;
let old_y_low = this.ll_y; let old_y_low = this.ll_y;
let old_y_high = this.ur_y; let old_y_high = this.ur_y;
this.trf.scale_from_stored(scale_x, scale_y, x0, y0); this.trf.revert();
this.trf.scale(scale_x, scale_y, x0, y0);
this.get_node_borders(); this.get_node_borders();
switch (type) { switch (type) {
......
...@@ -96,14 +96,14 @@ class GrowLine extends GlowLine { ...@@ -96,14 +96,14 @@ class GrowLine extends GlowLine {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.p1.x, this.p1.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.p1);
let y1 = Math.floor(this.trf.y(t, this.p1.x, this.p1.y) * let p2 = tmp.apply(this.p2);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.p2.x, this.p2.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.p2.x, this.p2.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
if (x1 === x2 && y1 === y2) { if (x1 === x2 && y1 === y2) {
return; return;
...@@ -113,12 +113,7 @@ class GrowLine extends GlowLine { ...@@ -113,12 +113,7 @@ class GrowLine extends GlowLine {
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
if (this.line_type === LineType.Solid) { this.ctx.gdraw.line(x1, y1, x2, y2, drawtype, idx, 0, this.line_type);
this.ctx.gdraw.line(x1, y1, x2, y2, drawtype, idx, 0);
} else {
this.ctx.gdraw.line_dashed(x1, y1, x2, y2, drawtype, idx, 0,
this.line_type);
}
} }
get_borders(t, g) { get_borders(t, g) {
......
...@@ -46,18 +46,14 @@ class GrowMenu extends GrowRect { ...@@ -46,18 +46,14 @@ class GrowMenu extends GrowRect {
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; return;
} }
let text_idx = Math.floor(this.trf.vertical_scale(t) * let tsize = Matrix.multiply(t, this.trf).vertical_scale() *
this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * (this.text_size + 4);
(this.text_size + 4) - 4); let text_idx = clamp(Math.floor(tsize - 4), 0, DRAW_TYPE_SIZE - 1);
let tsize = this.trf.vertical_scale(t) * this.ctx.mw.zoom_factor_y / tsize *= 2;
this.ctx.mw.base_zoom_factor * (8 + 2 * this.text_size);
text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1);
text_idx = Math.max(0, text_idx);
let idx = Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * let idx = Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
this.line_width - 1); this.line_width - 1);
idx += hot; idx = clamp(idx + hot, 0, DRAW_TYPE_SIZE-1);
idx = clamp(idx, 0, DRAW_TYPE_SIZE-1);
let z_width, z_descent; let z_width, z_descent;
let z_height = 0; let z_height = 0;
...@@ -67,8 +63,8 @@ class GrowMenu extends GrowRect { ...@@ -67,8 +63,8 @@ class GrowMenu extends GrowRect {
this.item_cnt = 0; this.item_cnt = 0;
this.info.item.forEach(function (e) { this.info.item.forEach(function (e) {
if (e.occupied) { if (e.occupied) {
let p = this.ctx.gdraw.getTextExtent(e.text, let p = this.ctx.gdraw.getTextExtent(e.text, this.text_drawtype,
Math.max(0, text_idx), this.font, this.text_drawtype); Math.max(0, text_idx), this.font);
z_width = p.x; z_width = p.x;
z_height = p.y; z_height = p.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -118,9 +114,9 @@ class GrowMenu extends GrowRect { ...@@ -118,9 +114,9 @@ class GrowMenu extends GrowRect {
Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.get_node_borders(); this.get_node_borders();
if (this.fill !== 0) { if (this.fill) {
this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
this.fill_drawtype); this.fill_drawtype, true, 0);
} }
this.item_height = tot_z_height / this.item_cnt; this.item_height = tot_z_height / this.item_cnt;
...@@ -135,17 +131,16 @@ class GrowMenu extends GrowRect { ...@@ -135,17 +131,16 @@ class GrowMenu extends GrowRect {
} else { } else {
drawtype = GlowColor.shift_drawtype(this.fill_drawtype, -2, null); drawtype = GlowColor.shift_drawtype(this.fill_drawtype, -2, null);
} }
this.ctx.gdraw.fill_rect(ll_x, this.ctx.gdraw.rect(ll_x, Math.floor(ll_y + item_idx * this.item_height), ur_x - ll_x,
Math.floor(ll_y + item_idx * this.item_height), ur_x - ll_x, Math.floor(this.item_height), drawtype, true, 0);
Math.floor(this.item_height), drawtype);
} }
let x_text = ll_x + 3; let x_text = ll_x + 3;
if (e.type === MenuItem.ButtonDisabled) { if (e.type === MenuItem.ButtonDisabled) {
this.ctx.gdraw.text(x_text, y_text, e.text, this.text_drawtype, this.ctx.gdraw.text(x_text, y_text, e.text, this.text_drawtype,
this.text_color_disabled, text_idx, highlight, 0, this.font, tsize, 0); this.text_color_disabled, text_idx, highlight, this.font, tsize, 0);
} else { } else {
this.ctx.gdraw.text(x_text, y_text, e.text, this.text_drawtype, this.ctx.gdraw.text(x_text, y_text, e.text, this.text_drawtype,
this.text_color, text_idx, highlight, 0, this.font, tsize, 0); this.text_color, text_idx, highlight, this.font, tsize, 0);
} }
if (e.type === MenuItem.PulldownMenu) { if (e.type === MenuItem.PulldownMenu) {
// Draw arrow // Draw arrow
...@@ -159,14 +154,14 @@ class GrowMenu extends GrowRect { ...@@ -159,14 +154,14 @@ class GrowMenu extends GrowRect {
new Point(ur_x - arrow_size - 2, Math.floor(ll_y + item_idx * new Point(ur_x - arrow_size - 2, Math.floor(ll_y + item_idx *
this.item_height + this.item_height / 2 - arrow_size / 2)), this.item_height + this.item_height / 2 - arrow_size / 2)),
]; ];
this.ctx.gdraw.fill_polyline(p, 4, DrawType.MediumGray, 0); this.ctx.gdraw.polyline(p, 4, DrawType.MediumGray, true, 0);
} }
item_idx++; item_idx++;
} }
}); });
if (this.border !== 0) { if (this.border !== 0) {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.draw_type, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.draw_type,
idx, 0); false, idx);
} }
} }
...@@ -177,7 +172,7 @@ class GrowMenu extends GrowRect { ...@@ -177,7 +172,7 @@ class GrowMenu extends GrowRect {
let ur_y = Math.max(this.ll.y, this.ur.y); let ur_y = Math.max(this.ll.y, this.ur.y);
if (ll_x <= x && x <= ur_x && ll_y <= y && y <= ur_y) { if (ll_x <= x && x <= ur_x && ll_y <= y && y <= ur_y) {
let vscale = this.trf.vertical_scale(null); let vscale = this.trf.vertical_scale();
let item = Math.floor((y - this.ll.y) / let item = Math.floor((y - this.ll.y) /
(this.item_height / vscale / this.ctx.mw.zoom_factor_y)); (this.item_height / vscale / this.ctx.mw.zoom_factor_y));
......
...@@ -213,7 +213,7 @@ class GrowNode extends GlowNode { ...@@ -213,7 +213,7 @@ class GrowNode extends GlowNode {
if (t === null) { if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node); this.nc.draw(this.trf, highlight, hot, node, node);
} else { } else {
let trf_tot = GlowTransform.multiply(t, this.trf); let trf_tot = Matrix.multiply(t, this.trf);
this.nc.draw(trf_tot, highlight, hot, this, this); this.nc.draw(trf_tot, highlight, hot, this, this);
} }
} else { } else {
...@@ -291,7 +291,7 @@ class GrowNode extends GlowNode { ...@@ -291,7 +291,7 @@ class GrowNode extends GlowNode {
if (t === null) { if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node); this.nc.draw(this.trf, highlight, hot, node, node);
} else { } else {
let trf_tot = GlowTransform.multiply(t, this.trf); let trf_tot = Matrix.multiply(t, this.trf);
// If this node has a trace pointer, use colors for this node // If this node has a trace pointer, use colors for this node
this.nc.draw(trf_tot, highlight, hot, this, this); this.nc.draw(trf_tot, highlight, hot, this, this);
} }
...@@ -351,7 +351,7 @@ class GrowNode extends GlowNode { ...@@ -351,7 +351,7 @@ class GrowNode extends GlowNode {
if (t === null) { if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node); this.nc.draw(this.trf, highlight, hot, node, node);
} else { } else {
let trf_tot = GlowTransform.multiply(t, this.trf); let trf_tot = Matrix.multiply(t, this.trf);
// If this node has a trace pointer, use colors for this node // If this node has a trace pointer, use colors for this node
this.nc.draw(trf_tot, highlight, hot, this, this); this.nc.draw(trf_tot, highlight, hot, this, this);
} }
...@@ -466,7 +466,8 @@ class GrowNode extends GlowNode { ...@@ -466,7 +466,8 @@ class GrowNode extends GlowNode {
old_x_right = this.ur_x; old_x_right = this.ur_x;
old_y_low = this.ll_y; old_y_low = this.ll_y;
old_y_high = this.ur_y; old_y_high = this.ur_y;
this.trf.scale_from_stored(scale_x, scale_y, x0, y0); this.trf.revert();
this.trf.scale(scale_x, scale_y, x0, y0);
this.get_node_borders(); this.get_node_borders();
this.ctx.draw(); this.ctx.draw();
...@@ -510,7 +511,7 @@ class GrowNode extends GlowNode { ...@@ -510,7 +511,7 @@ class GrowNode extends GlowNode {
let t = new GlowTransform(); let t = new GlowTransform();
t.rotate(angel, x0, y0); t.rotate(angel, x0, y0);
this.trf.set_from_stored(t); this.trf.set(Matrix.multiply(t, this.trf.s));
this.get_node_borders(); this.get_node_borders();
} }
...@@ -600,29 +601,27 @@ class GrowNode extends GlowNode { ...@@ -600,29 +601,27 @@ class GrowNode extends GlowNode {
} }
// Calculate max and min coordinates // Calculate max and min coordinates
let x1 = this.trf.x(0, this.nc.y0); let p1 = this.trf.apply(new Point(0, this.nc.y0));
let y1 = this.trf.y(0, this.nc.y0); let p2 = this.trf.apply(new Point(0, this.nc.y1));
let x2 = this.trf.x(0, this.nc.y1);
let y2 = this.trf.y(0, this.nc.y1);
let rotation = (this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * 360; let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) * 360;
if (rotation <= 45 || rotation > 315) { if (rotation <= 45 || rotation > 315) {
limits.direction = Direction.Down; limits.direction = Direction.Down;
limits.min = y1; limits.min = p1.y;
limits.max = y2; limits.max = p2.y;
} else if (rotation > 45 && rotation <= 135) { } else if (rotation > 45 && rotation <= 135) {
limits.direction = Direction.Right; limits.direction = Direction.Right;
limits.min = x2; limits.min = p2.x;
limits.max = x1; limits.max = p1.x;
} else if (rotation > 135 && rotation <= 225) { } else if (rotation > 135 && rotation <= 225) {
limits.direction = Direction.Up; limits.direction = Direction.Up;
limits.min = y2; limits.min = p2.y;
limits.max = y1; limits.max = p1.y;
} else if (rotation > 225 && rotation <= 315) { } else if (rotation > 225 && rotation <= 315) {
limits.direction = Direction.Left; limits.direction = Direction.Left;
limits.min = x1; limits.min = p1.x;
limits.max = x2; limits.max = p2.x;
} }
limits.status = 1; limits.status = 1;
return limits; return limits;
...@@ -635,7 +634,7 @@ class GrowNode extends GlowNode { ...@@ -635,7 +634,7 @@ class GrowNode extends GlowNode {
} }
get_borders(t, g) { get_borders(t, g) {
let t2 = (t) ? GlowTransform.multiply(t, this.trf) : this.trf; let t2 = (t) ? Matrix.multiply(t, this.trf) : this.trf;
this.nc.get_borders(t2, g); this.nc.get_borders(t2, g);
} }
...@@ -655,30 +654,28 @@ class GrowNode extends GlowNode { ...@@ -655,30 +654,28 @@ class GrowNode extends GlowNode {
this.get_borders(t, g); this.get_borders(t, g);
if (g.hit(new Point(x, y))) { if (g.hit(new Point(x, y))) {
// Hit, calculate max and min koordinates // Hit, calculate max and min koordinates
let x1 = this.trf.x(t, 0, this.nc.y0); let tmp = Matrix.multiply(t, this.trf);
let y1 = this.trf.y(t, 0, this.nc.y0); let p1 = tmp.apply(new Point(0, this.nc.y0));
let x2 = this.trf.x(t, 0, this.nc.y1); let p2 = tmp.apply(new Point(0, this.nc.y1));
let y2 = this.trf.y(t, 0, this.nc.y1);
let rotation = let rotation = (tmp.rotation / 360 - Math.floor(tmp.rotation / 360)) * 360;
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
if (rotation <= 45 || rotation > 315) { if (rotation <= 45 || rotation > 315) {
b.direction = Direction.Down; b.direction = Direction.Down;
b.min = y1; b.min = p1.y;
b.max = y2; b.max = p2.y;
} else if (rotation > 45 && rotation <= 135) { } else if (rotation > 45 && rotation <= 135) {
b.direction = Direction.Left; b.direction = Direction.Left;
b.min = x2; b.min = p2.x;
b.max = x1; b.max = p1.x;
} else if (rotation > 135 && rotation <= 225) { } else if (rotation > 135 && rotation <= 225) {
b.direction = Direction.Up; b.direction = Direction.Up;
b.min = y2; b.min = p2.y;
b.max = y1; b.max = p1.y;
} else if (rotation > 225 && rotation <= 315) { } else if (rotation > 225 && rotation <= 315) {
b.direction = Direction.Right; b.direction = Direction.Right;
b.min = x1; b.min = p1.x;
b.max = x2; b.max = p2.x;
} }
b.background = this; b.background = this;
...@@ -875,7 +872,7 @@ class GrowNode extends GlowNode { ...@@ -875,7 +872,7 @@ class GrowNode extends GlowNode {
} }
getAnnotationTextExtent(num) { getAnnotationTextExtent(num) {
return this.nc.getAnnotationTextExtent(this.trf, this, num); return this.nc.getAnnotationTextExtent(t, this.trfhis, num);
} }
setColorThemeLightness() { setColorThemeLightness() {
......
...@@ -158,15 +158,17 @@ class GrowPie extends GrowArc { ...@@ -158,15 +158,17 @@ class GrowPie extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t));
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -216,8 +218,8 @@ class GrowPie extends GrowArc { ...@@ -216,8 +218,8 @@ class GrowPie extends GrowArc {
if (grad === Gradient.No || fillcolor === DrawType.ColorRed) { if (grad === Gradient.No || fillcolor === DrawType.ColorRed) {
let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null); let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null);
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, ia1 - rot, this.ctx.gdraw.arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, ia1 - rot,
ia2, drawtype); ia2, drawtype, true, 0);
} else if (!display_shadow || this.shadow_width === 0) { } else if (!display_shadow || this.shadow_width === 0) {
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
......
...@@ -287,10 +287,10 @@ class GrowPolyline extends GlowPolyline { ...@@ -287,10 +287,10 @@ class GrowPolyline extends GlowPolyline {
} }
if (grad === Gradient.No || drawtype === DrawType.ColorRed) { if (grad === Gradient.No || drawtype === DrawType.ColorRed) {
this.ctx.gdraw.fill_polyline(this.points, this.a_points.size(), this.ctx.gdraw.polyline(this.points, this.a_points.size(),
drawtype, 0); drawtype, true, 0);
} else { } else {
let rotation = t ? this.trf.rot(t) : this.trf.rot(); let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -314,7 +314,7 @@ class GrowPolyline extends GlowPolyline { ...@@ -314,7 +314,7 @@ class GrowPolyline extends GlowPolyline {
0 && this.fill_eq_shadow === 0; 0 && this.fill_eq_shadow === 0;
if (display_shadow && this.shadow_width !== 0) { if (display_shadow && this.shadow_width !== 0) {
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let ish = Math.floor(this.shadow_width / 100 * trf_scale * let ish = Math.floor(this.shadow_width / 100 * trf_scale *
Math.min((this.ur_x - this.ll_x) * this.ctx.mw.zoom_factor_x, Math.min((this.ur_x - this.ll_x) * this.ctx.mw.zoom_factor_x,
(this.ur_y - this.ll_y) * this.ctx.mw.zoom_factor_y) + 0.5); (this.ur_y - this.ll_y) * this.ctx.mw.zoom_factor_y) + 0.5);
...@@ -328,7 +328,7 @@ class GrowPolyline extends GlowPolyline { ...@@ -328,7 +328,7 @@ class GrowPolyline extends GlowPolyline {
sp[i + 1], sp[i + 1],
this.points[i + 1] this.points[i + 1]
]; ];
this.ctx.gdraw.fill_polyline(p, 4, sp[i].drawtype, 0); this.ctx.gdraw.polyline(p, 4, sp[i].drawtype, true, 0);
} }
} }
} }
...@@ -587,19 +587,18 @@ class GrowPolyline extends GlowPolyline { ...@@ -587,19 +587,18 @@ class GrowPolyline extends GlowPolyline {
} }
get_borders(t, g) { get_borders(t, g) {
let x2 = 0, y2 = 0; let tmp = Matrix.multiply(t, this.trf);
let p2 = new Point();
for (let i = 0; i < this.a_points.size() - 1; i++) { for (let i = 0; i < this.a_points.size() - 1; i++) {
let e = this.a_points.get(i); let e = this.a_points.get(i);
let x1 = x2; let p1 = new Point(p2.x, p2.y);
let y1 = y2;
if (i === 0) { if (i === 0) {
x1 = this.trf.x(t, e.x, e.y); p1 = tmp.apply(e);
y1 = this.trf.y(t, e.x, e.y);
} }
x2 = this.trf.x(t, e.x, e.y); p2 = tmp.apply(e);
y2 = this.trf.y(t, e.x, e.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
} }
......
...@@ -172,14 +172,14 @@ class GrowRect extends GlowRect { ...@@ -172,14 +172,14 @@ class GrowRect extends GlowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = this.trf.x(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_x + let tmp = Matrix.multiply(t, this.trf);
0.5 - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_y + let p2 = tmp.apply(this.ur);
0.5 - this.ctx.mw.offset_y;
let x2 = this.trf.x(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_x + let x1 = p1.x * this.ctx.mw.zoom_factor_x + 0.5 - this.ctx.mw.offset_x;
0.5 - this.ctx.mw.offset_x; let y1 = p1.y * this.ctx.mw.zoom_factor_y + 0.5 - this.ctx.mw.offset_y;
let y2 = this.trf.y(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_y + let x2 = p2.x * this.ctx.mw.zoom_factor_x + 0.5 - this.ctx.mw.offset_x;
0.5 - this.ctx.mw.offset_y; let y2 = p2.y * this.ctx.mw.zoom_factor_y + 0.5 - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -222,7 +222,7 @@ class GrowRect extends GlowRect { ...@@ -222,7 +222,7 @@ class GrowRect extends GlowRect {
new Point(ll_x, ur_y), new Point(ll_x, ur_y),
new Point(ll_x, ll_y) new Point(ll_x, ll_y)
]; ];
this.ctx.gdraw.fill_polyline(points, 7, drawtype, 0); this.ctx.gdraw.polyline(points, 7, drawtype, true, 0);
// Draw dark shadow // Draw dark shadow
drawtype = drawtype =
...@@ -237,16 +237,16 @@ class GrowRect extends GlowRect { ...@@ -237,16 +237,16 @@ class GrowRect extends GlowRect {
new Point(ur_x, ll_y), new Point(ur_x, ll_y),
new Point(ur_x, ur_y) new Point(ur_x, ur_y)
]; ];
this.ctx.gdraw.fill_polyline(points, 7, drawtype, 0); this.ctx.gdraw.polyline(points, 7, drawtype, true, 0);
} }
if (this.fill !== 0) { if (this.fill) {
if (display_shadow && ish !== 0) { if (display_shadow && ish !== 0) {
if (grad === Gradient.No || fillcolor === DrawType.ColorRed) { if (grad === Gradient.No || fillcolor === DrawType.ColorRed) {
let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null); let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null);
this.ctx.gdraw.fill_rect(ll_x + ish, ll_y + ish, ur_x - ll_x - 2 * this.ctx.gdraw.rect(ll_x + ish, ll_y + ish, ur_x - ll_x - 2 *
ish, ur_y - ll_y - 2 * ish, drawtype); ish, ur_y - ll_y - 2 * ish, drawtype, true, 0);
} else { } else {
let rotationa = t ? this.trf.rot(t) : this.trf.rot(); let rotationa = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let fa0, fa1, fa2; let fa0, fa1, fa2;
if (this.bgcolor_gradient !== 0 && if (this.bgcolor_gradient !== 0 &&
...@@ -273,16 +273,15 @@ class GrowRect extends GlowRect { ...@@ -273,16 +273,15 @@ class GrowRect extends GlowRect {
fa0 = fillcolor; fa0 = fillcolor;
} }
this.ctx.gdraw.gradient_fill_rect(ll_x + ish, ll_y + ish, ur_x - this.ctx.gdraw.gradient_fill_rect(ll_x + ish, ll_y + ish, ur_x -
ll_x - 2 * ish, ur_y - ll_y - 2 * ish, fa0, fa1, fa2, ll_x - 2 * ish, ur_y - ll_y - 2 * ish, fa0, fa1, fa2, this.ctx.gdraw.gradient_rotate(rotationa, grad));
this.ctx.gdraw.gradient_rotate(rotationa, grad));
} }
} else { } else {
if (grad === Gradient.No || fillcolor === DrawType.ColorRed) { if (grad === Gradient.No || fillcolor === DrawType.ColorRed) {
let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null); let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null);
this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype); drawtype, true, 0);
} else { } else {
let rotationb = t ? this.trf.rot(t) : this.trf.rot(); let rotationb = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let fb0, fb1, fb2; let fb0, fb1, fb2;
if (this.bgcolor_gradient !== 0 && if (this.bgcolor_gradient !== 0 &&
...@@ -309,28 +308,26 @@ class GrowRect extends GlowRect { ...@@ -309,28 +308,26 @@ class GrowRect extends GlowRect {
fb0 = fillcolor; fb0 = fillcolor;
} }
this.ctx.gdraw.gradient_fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - this.ctx.gdraw.gradient_fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y -
ll_y, fb0, fb1, fb2, ll_y, fb0, fb1, fb2, this.ctx.gdraw.gradient_rotate(rotationb, grad));
this.ctx.gdraw.gradient_rotate(rotationb, grad));
} }
} }
} }
if (this.border !== 0 || if (this.border !== 0 ||
!(this.fill !== 0 || (display_shadow && this.shadow_width !== 0))) { !(this.fill || (display_shadow && this.shadow_width !== 0))) {
let drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, false, idx);
0);
} }
} }
get_borders(t, g) { get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let x2 = this.trf.x(t, this.ur.x, this.ur.y); let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y); let p2 = tmp.apply(this.ur);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
get_node_borders() { get_node_borders() {
...@@ -379,7 +376,8 @@ class GrowRect extends GlowRect { ...@@ -379,7 +376,8 @@ class GrowRect extends GlowRect {
let old_x_right = this.ur_x; let old_x_right = this.ur_x;
let old_y_low = this.ll_y; let old_y_low = this.ll_y;
let old_y_high = this.ur_y; let old_y_high = this.ur_y;
this.trf.scale_from_stored(scale_x, scale_y, x0, y0); this.trf.revert();
this.trf.scale(scale_x, scale_y, x0, y0);
this.get_node_borders(); this.get_node_borders();
switch (type) { switch (type) {
......
This diff is collapsed.
...@@ -22,7 +22,7 @@ class GrowScrollBar extends GrowRect { ...@@ -22,7 +22,7 @@ class GrowScrollBar extends GrowRect {
this.ur.y = y + h; this.ur.y = y + h;
this.draw_type = border_d_type; this.draw_type = border_d_type;
this.line_width = line_width; this.line_width = line_width;
this.fill = 1; this.fill = true;
this.border = 1; this.border = 1;
this.shadow = 0; this.shadow = 0;
this.fill_drawtype = fill_d_type; this.fill_drawtype = fill_d_type;
...@@ -48,14 +48,14 @@ class GrowScrollBar extends GrowRect { ...@@ -48,14 +48,14 @@ class GrowScrollBar extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -68,7 +68,7 @@ class GrowScrollBar extends GrowRect { ...@@ -68,7 +68,7 @@ class GrowScrollBar extends GrowRect {
DrawType.LineHighlight, highlight, colornode, 0, 0); DrawType.LineHighlight, highlight, colornode, 0, 0);
let shift_drawtype; let shift_drawtype;
this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, fdrawtype); this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, fdrawtype, true, 0);
if (this.shadow !== 0) { if (this.shadow !== 0) {
shift_drawtype = GlowColor.shift_drawtype(this.fill_drawtype, 2, null); // Dark shift_drawtype = GlowColor.shift_drawtype(this.fill_drawtype, 2, null); // Dark
this.ctx.gdraw.line(ll_x + 1, ll_y + 1, ll_x + 1, ur_y - 1, this.ctx.gdraw.line(ll_x + 1, ll_y + 1, ll_x + 1, ur_y - 1,
...@@ -106,7 +106,7 @@ class GrowScrollBar extends GrowRect { ...@@ -106,7 +106,7 @@ class GrowScrollBar extends GrowRect {
y0 = ll_y; y0 = ll_y;
break; break;
} }
this.ctx.gdraw.fill_rect(x0, y0, width, height, this.bar_color); this.ctx.gdraw.rect(x0, y0, width, height, this.bar_color, true, 0);
if (this.shadow !== 0) { if (this.shadow !== 0) {
shift_drawtype = GlowColor.shift_drawtype(this.bar_color, -2, null); // Light shift_drawtype = GlowColor.shift_drawtype(this.bar_color, -2, null); // Light
this.ctx.gdraw.line(x0 + 1, y0 + 1, x0 + 1, y0 + height - 1, this.ctx.gdraw.line(x0 + 1, y0 + 1, x0 + 1, y0 + height - 1,
...@@ -119,11 +119,10 @@ class GrowScrollBar extends GrowRect { ...@@ -119,11 +119,10 @@ class GrowScrollBar extends GrowRect {
this.ctx.gdraw.line(x0 + width - 1, y0 + 1, x0 + width - 1, y0 + this.ctx.gdraw.line(x0 + width - 1, y0 + 1, x0 + width - 1, y0 +
height - 1, shift_drawtype, 0, 0); height - 1, shift_drawtype, 0, 0);
} }
this.ctx.gdraw.rect(x0, y0, width, height, bdrawtype, idx, 0); this.ctx.gdraw.rect(x0, y0, width, height, bdrawtype, false, idx);
} }
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, bdrawtype, idx, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, bdrawtype, false, idx);
0);
} }
set_value(value, length) { set_value(value, length) {
......
class GrowSubAnnot extends GlowAnnot {
trf: GlowTransform;
rect: GlowRect;
n_name = null;
ll_x: Number;
ll_y: Number;
ur_x: Number;
ur_y: Number;
adjustment: Adjustment;
text: GlowText;
constructor(ctx) {
super(ctx);
this.trf = new GlowTransform();
this.rect = new GlowRect(ctx);
this.text = new GlowText(ctx);
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case GlowSave.GrowSubAnnot:
break;
case GlowSave.GrowSubAnnot_n_name:
if (tokens.length > 1) {
this.n_name = tokens[1];
}
break;
case GlowSave.GrowSubAnnot_x_right:
this.ur_x = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_x_left:
this.ll_x = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_y_high:
this.ur_y = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_y_low:
this.ll_y = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_text:
this.text = tokens[1];
break;
case GlowSave.GrowSubAnnot_rect:
i = this.rect.open(lines, i + 1);
break;
case GlowSave.GrowSubAnnot_annot_part:
i = super.open(lines, i + 1);
break;
case GlowSave.GrowSubAnnot_trf:
i = this.trf.open(lines, i + 1);
break;
case GlowSave.GrowSubAnnot_adjustment:
this.adjustment = parseInt(tokens[1], 10);
case GlowSave.End:
return i;
default:
console.log("Syntax error in GrowSubAnnot");
break;
}
}
return i;
}
event_handler(event, fx, fy) {
return 0;
}
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
let p = new Point();
if (t) {
p = Matrix.multiply(t, this.trf).apply(this.p);
let p2 = this.trf.apply(this.p);
p.x -= p2.x;
p.y -= p2.y;
}
this.rect.draw(p, highlight, hot);
this.text.draw(p, highlight, hot);
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -85,7 +85,7 @@ class GrowText extends GlowText { ...@@ -85,7 +85,7 @@ class GrowText extends GlowText {
} }
let z_descent; let z_descent;
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y / let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
...@@ -110,9 +110,12 @@ class GrowText extends GlowText { ...@@ -110,9 +110,12 @@ class GrowText extends GlowText {
let ry1 = 0; let ry1 = 0;
let z_width = 0; let z_width = 0;
let z_height = 0; let z_height = 0;
let x1 = Math.floor(this.trf.x(t, this.p.x, this.p.y) * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let tmp = Matrix.multiply(t, this.trf);
let y1 = Math.floor(this.trf.y(t, this.p.x, this.p.y) * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let p = tmp.apply(this.p);
let rot = Math.floor(this.trf.rot(t)); let x1 = Math.floor(p.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(p.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
if (this.adjustment === Adjustment.Center) { if (this.adjustment === Adjustment.Center) {
rot = rot < 0 ? rot % 360 + 360 : rot % 360; rot = rot < 0 ? rot % 360 + 360 : rot % 360;
} else { } else {
...@@ -122,8 +125,8 @@ class GrowText extends GlowText { ...@@ -122,8 +125,8 @@ class GrowText extends GlowText {
if (this.text !== "") { if (this.text !== "") {
if (highl !== 0 || (hot !== 0 && node === null) || if (highl !== 0 || (hot !== 0 && node === null) ||
this.adjustment !== Adjustment.Left) { this.adjustment !== Adjustment.Left) {
let p = this.ctx.gdraw.getTextExtent(this.text, Math.max(0, idx), let p = this.ctx.gdraw.getTextExtent(this.text, ldraw_type, Math.max(0, idx),
lfont, ldraw_type); lfont);
z_width = p.x; z_width = p.x;
z_height = p.y; z_height = p.y;
z_descent = z_height / 4; z_descent = z_height / 4;
...@@ -165,26 +168,25 @@ class GrowText extends GlowText { ...@@ -165,26 +168,25 @@ class GrowText extends GlowText {
} }
if (highl !== 0) { if (highl !== 0) {
this.ctx.gdraw.rect(rx1, ry1, z_width, z_height, this.ctx.gdraw.rect(rx1, ry1, z_width, z_height, DrawType.FillHighlight,
DrawType.FillHighlight, Math.max(1, Math.min(idx + hot, 2)), 0); false, Math.max(1, Math.min(idx + hot, 2)));
} else if (hot !== 0 && node === null) { } else if (hot !== 0 && node === null) {
this.ctx.gdraw.rect(rx1, ry1, z_width, z_height, this.ctx.gdraw.rect(rx1, ry1, z_width, z_height, DrawType.LineGray,
DrawType.LineGray, Math.max(Math.min(idx, 2), 1), 0); false, Math.max(Math.min(idx, 2), 1));
} }
if (idx >= 0) { if (idx >= 0) {
let color = GlowColor.get_drawtype(this.color_drawtype, let color = GlowColor.get_drawtype(this.color_drawtype,
DrawType.LineHighlight, highlight, colornode, 2, 0); DrawType.LineHighlight, highlight, colornode, 2, 0);
this.ctx.gdraw.text(x1, y1, this.text, ldraw_type, color, idx, this.ctx.gdraw.text(x1, y1, this.text, ldraw_type, color, idx,
highlight, 0, lfont, tsize, rot); highlight, lfont, tsize, rot);
} }
} else if (idx >= 0) { } else if (idx >= 0) {
let p2 = this.ctx.gdraw.getTextExtent("A", Math.max(0, idx), lfont, let p2 = this.ctx.gdraw.getTextExtent("A", ldraw_type, Math.max(0, idx), lfont);
ldraw_type);
z_width = p2.x; z_width = p2.x;
z_height = p2.y; z_height = p2.y;
z_descent = z_height / 4; z_descent = z_height / 4;
this.ctx.gdraw.rect(x1, y1 - (z_height - z_descent), z_width, z_height, this.ctx.gdraw.rect(x1, y1 - (z_height - z_descent), z_width, z_height,
DrawType.LineGray, idx, 0); DrawType.LineGray, false, idx);
} }
} }
......
...@@ -157,21 +157,21 @@ class GrowTrend extends GrowRect { ...@@ -157,21 +157,21 @@ class GrowTrend extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
if (this.fill !== 0) { if (this.fill) {
let grad = this.gradient; let grad = this.gradient;
if (this.gradient === Gradient.No && if (this.gradient === Gradient.No &&
(node !== null && node.gradient !== Gradient.No) && (node !== null && node.gradient !== Gradient.No) &&
...@@ -183,10 +183,10 @@ class GrowTrend extends GrowRect { ...@@ -183,10 +183,10 @@ class GrowTrend extends GrowRect {
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight, GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0); highlight, colornode, 1, 0);
if (grad === Gradient.No) { if (grad === Gradient.No) {
this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype); drawtype, true, 0);
} else { } else {
let rotation = t ? this.trf.rot(t) : this.trf.rot(); let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -211,10 +211,8 @@ class GrowTrend extends GrowRect { ...@@ -211,10 +211,8 @@ class GrowTrend extends GrowRect {
let curvetmp = this.curve.slice(0, this.curve_cnt).filter(e => e !== null); let curvetmp = this.curve.slice(0, this.curve_cnt).filter(e => e !== null);
if (this.fill_curve !== 0) { if (this.fill_curve !== 0) {
let tmp1 = t ? GlowTransform.multiply(t, this.trf) : this.trf;
curvetmp.forEach(e => e.border = 0); curvetmp.forEach(e => e.border = 0);
curvetmp.forEach(e => e.draw(tmp1, highlight, hot, node, colornode)); curvetmp.forEach(e => e.draw(Matrix.multiply(t, this.trf), highlight, hot, node, colornode));
curvetmp.forEach(e => e.border = 1); curvetmp.forEach(e => e.border = 1);
} }
...@@ -233,15 +231,16 @@ class GrowTrend extends GrowRect { ...@@ -233,15 +231,16 @@ class GrowTrend extends GrowRect {
if (this.fill_curve !== 0) { if (this.fill_curve !== 0) {
curvetmp.forEach(e => e.fill = 0); curvetmp.forEach(e => e.fill = 0);
} }
let tmp2 = t ? GlowTransform.multiply(t, this.trf) : this.trf; curvetmp.forEach(e => e.draw(Matrix.multiply(t, this.trf), highlight, hot, node, colornode));
curvetmp.forEach(e => e.draw(tmp2, highlight, hot, node, colornode));
if (this.fill_curve !== 0) { if (this.fill_curve !== 0) {
curvetmp.forEach(e => e.fill = 1); curvetmp.forEach(e => e.fill = 1);
} }
let tmp = Matrix.multiply(t, this.trf);
if (this.display_x_mark1 !== 0) { if (this.display_x_mark1 !== 0) {
let xm1 = Math.floor(this.trf.x(t, this.x_mark1, this.ll.y) * let p = tmp.apply(new Point(this.x_mark1, this.ll.y));
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let xm1 = Math.floor(p.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
if (xm1 >= ll_x && xm1 <= ur_x) { if (xm1 >= ll_x && xm1 <= ur_x) {
drawtype = this.mark1_color; drawtype = this.mark1_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
...@@ -251,8 +250,8 @@ class GrowTrend extends GrowRect { ...@@ -251,8 +250,8 @@ class GrowTrend extends GrowRect {
} }
} }
if (this.display_x_mark2 !== 0) { if (this.display_x_mark2 !== 0) {
let xm2 = Math.floor(this.trf.x(t, this.x_mark2, this.ll.y) * let p = tmp.apply(new Point(this.x_mark2, this.ll.y));
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let xm2 = Math.floor(p.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
if (xm2 >= ll_x && xm2 <= ur_x) { if (xm2 >= ll_x && xm2 <= ur_x) {
drawtype = this.mark2_color; drawtype = this.mark2_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
...@@ -262,14 +261,8 @@ class GrowTrend extends GrowRect { ...@@ -262,14 +261,8 @@ class GrowTrend extends GrowRect {
} }
} }
if (this.display_y_mark1 !== 0) { if (this.display_y_mark1 !== 0) {
let ym1; let p = tmp.apply(new Point(this.ll.x, this.y_mark1));
if (t === null) { let ym1 = Math.floor(p.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
ym1 = Math.floor(this.trf.y(this.ll.x, this.y_mark1) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
} else {
ym1 = Math.floor(this.trf.y(t, this.ll.x, this.y_mark1) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
}
if (ym1 >= ll_y && ym1 <= ur_y) { if (ym1 >= ll_y && ym1 <= ur_y) {
drawtype = this.mark1_color; drawtype = this.mark1_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
...@@ -279,14 +272,8 @@ class GrowTrend extends GrowRect { ...@@ -279,14 +272,8 @@ class GrowTrend extends GrowRect {
} }
} }
if (this.display_y_mark2 !== 0) { if (this.display_y_mark2 !== 0) {
let ym2; let p = tmp.apply(new Point(this.ll.x, this.y_mark2));
if (t === null) { let ym2 = Math.floor(p.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
ym2 = Math.floor(this.trf.y(this.ll.x, this.y_mark2) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
} else {
ym2 = Math.floor(this.trf.y(t, this.ll.x, this.y_mark2) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
}
if (ym2 >= ll_y && ym2 <= ur_y) { if (ym2 >= ll_y && ym2 <= ur_y) {
drawtype = this.mark2_color; drawtype = this.mark2_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
...@@ -297,8 +284,7 @@ class GrowTrend extends GrowRect { ...@@ -297,8 +284,7 @@ class GrowTrend extends GrowRect {
} }
if (this.border !== 0) { if (this.border !== 0) {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, false, idx);
0);
} }
} }
......
...@@ -117,46 +117,45 @@ class GrowWindow extends GrowRect { ...@@ -117,46 +117,45 @@ class GrowWindow extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let dx1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let dy1 = this.trf.y(t, this.ll.x, this.ll.y); let d1 = tmp.apply(this.ll);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y); let d2 = tmp.apply(this.ur);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y); d1.x = Math.min(d1.x, d2.x);
dx1 = Math.min(dx1, dx2); d2.x = Math.max(d1.x, d2.x);
dx2 = Math.max(dx1, dx2); d1.y = Math.min(d1.y, d2.y);
dy1 = Math.min(dy1, dy2); d2.y = Math.max(d1.y, d2.y);
dy2 = Math.max(dy1, dy2);
if (this.v_scrollbar !== null) { if (this.v_scrollbar !== null) {
if (this.h_scrollbar === null) { if (this.h_scrollbar === null) {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 + this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs)); this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs));
} else { } else {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 + this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs) - this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs) -
this.scrollbar_width); this.scrollbar_width);
} }
this.v_scrollbar.draw(null, 0, 0, null, null); this.v_scrollbar.draw(null, 0, 0, null, null);
} }
if (this.h_scrollbar !== null) { if (this.h_scrollbar !== null) {
if (this.v_scrollbar === null) { if (this.v_scrollbar === null) {
this.h_scrollbar.set_position(dx1, dy2 - this.scrollbar_width, dx2 - this.h_scrollbar.set_position(d1.x, d2.y - this.scrollbar_width, d2.x -
dx1, this.scrollbar_width); d1.x, this.scrollbar_width);
} else { } else {
this.h_scrollbar.set_position(dx1, dy2 - this.scrollbar_width, dx2 - this.h_scrollbar.set_position(d1.x, d2.y - this.scrollbar_width, d2.x -
dx1 - this.scrollbar_width, this.scrollbar_width); d1.x - this.scrollbar_width, this.scrollbar_width);
} }
this.h_scrollbar.draw(null, 0, 0, null, null); this.h_scrollbar.draw(null, 0, 0, null, null);
} }
let ll_x = Math.floor(dx1 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ll_x = Math.floor(d1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ll_y = Math.floor((dy1 + this.y_low_offs) * this.ctx.mw.zoom_factor_y) - let ll_y = Math.floor((d1.y + this.y_low_offs) * this.ctx.mw.zoom_factor_y) -
this.ctx.mw.offset_y; this.ctx.mw.offset_y;
if (this.windowCtx !== null) { if (this.windowCtx !== null) {
let ur_x = Math.floor((dx2 - this.vertical_scrollbar * this.scrollbar_width) * let ur_x = Math.floor((d2.x - this.vertical_scrollbar * this.scrollbar_width) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = let ur_y =
Math.floor((dy2 - this.horizontal_scrollbar * this.scrollbar_width) * Math.floor((d2.y - this.horizontal_scrollbar * this.scrollbar_width) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.windowCtx.mw.window_width = this.windowCtx.mw.window_width =
...@@ -179,9 +178,9 @@ class GrowWindow extends GrowRect { ...@@ -179,9 +178,9 @@ class GrowWindow extends GrowRect {
this.windowCtx.mw.subwindow_scale * this.ctx.mw.zoom_factor_y; this.windowCtx.mw.subwindow_scale * this.ctx.mw.zoom_factor_y;
// window_ctx->draw_buffer_only = ctx->draw_buffer_only; // window_ctx->draw_buffer_only = ctx->draw_buffer_only;
if (this.fill !== 0) { if (this.fill) {
this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
this.fill_drawtype); this.fill_drawtype, true, 0);
} }
this.ctx.gdraw.set_clip_rectangle(ll_x, ll_y, ur_x - 1, ur_y - 1); this.ctx.gdraw.set_clip_rectangle(ll_x, ll_y, ur_x - 1, ur_y - 1);
...@@ -197,13 +196,13 @@ class GrowWindow extends GrowRect { ...@@ -197,13 +196,13 @@ class GrowWindow extends GrowRect {
this.ctx.gdraw.reset_clip_rectangle(); this.ctx.gdraw.reset_clip_rectangle();
} }
let ur_x = Math.floor(dx2 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ur_x = Math.floor(d2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = Math.floor(dy2 * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let ur_y = Math.floor(d2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, 0); this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, false, idx);
} }
new_ctx() { new_ctx() {
...@@ -253,7 +252,7 @@ class GrowWindow extends GrowRect { ...@@ -253,7 +252,7 @@ class GrowWindow extends GrowRect {
if (this.windowCtx.background_color !== DrawType.Inherit) { if (this.windowCtx.background_color !== DrawType.Inherit) {
this.fill_drawtype = this.windowCtx.background_color; this.fill_drawtype = this.windowCtx.background_color;
this.original_fill_drawtype = this.fill_drawtype; this.original_fill_drawtype = this.fill_drawtype;
this.fill = 1; this.fill = true;
} }
if (this.windowCtx.x0 !== this.windowCtx.x1 && if (this.windowCtx.x0 !== this.windowCtx.x1 &&
this.windowCtx.y0 !== this.windowCtx.y1) { this.windowCtx.y0 !== this.windowCtx.y1) {
...@@ -547,7 +546,7 @@ class GrowWindow extends GrowRect { ...@@ -547,7 +546,7 @@ class GrowWindow extends GrowRect {
} }
this.fill_drawtype = DrawType.Inherit; this.fill_drawtype = DrawType.Inherit;
this.original_fill_drawtype = this.fill_drawtype; this.original_fill_drawtype = this.fill_drawtype;
this.fill = 0; this.fill = false;
} }
this.file_name = this.input_file_name; this.file_name = this.input_file_name;
this.new_ctx(); this.new_ctx();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
Based upon C source code written by Eric Young, eay@psych.uq.oz.au Based upon C source code written by Eric Young, eay@psych.uq.oz.au
and the java version JCrypt by John Dumas. and the java version JCrypt by John Dumas.
*/ */
class JopCrypt { class Crypt {
static ITERATIONS = 16; static ITERATIONS = 16;
static con_salt = static con_salt =
...@@ -225,78 +225,53 @@ class JopCrypt { ...@@ -225,78 +225,53 @@ class JopCrypt {
return (value >= 0 ? value : value + 256); return (value >= 0 ? value : value + 256);
} }
fourBytesToInt(b, offset) { static fourBytesToInt(b, offset) {
let value = JopCrypt.byteToUnsigned(b[offset++]); let value = Crypt.byteToUnsigned(b[offset++]);
value |= (JopCrypt.byteToUnsigned(b[offset++]) << 8); value |= (Crypt.byteToUnsigned(b[offset++]) << 8);
value |= (JopCrypt.byteToUnsigned(b[offset++]) << 16); value |= (Crypt.byteToUnsigned(b[offset++]) << 16);
value |= (JopCrypt.byteToUnsigned(b[offset++]) << 24); value |= (Crypt.byteToUnsigned(b[offset]) << 24);
return value; return value;
} }
static intToFourBytes(iValue, b, offset) { static intToFourBytes(iValue, b) {
b[offset++] = ((iValue) & 0xff); b.push((iValue) & 0xff);
b[offset++] = ((iValue >>> 8) & 0xff); b.push((iValue >>> 8) & 0xff);
b[offset++] = ((iValue >>> 16) & 0xff); b.push((iValue >>> 16) & 0xff);
b[offset++] = ((iValue >>> 24) & 0xff); b.push((iValue >>> 24) & 0xff);
} }
static PERM_OP(a, b, n, m, results) { static PERM_OP(a, b, n, m) {
let t; let t = ((a >>> n) ^ b) & m;
t = ((a >>> n) ^ b) & m;
a ^= t << n; a ^= t << n;
b ^= t; b ^= t;
return [a, b];
results[0] = a;
results[1] = b;
} }
static HPERM_OP(a, n, m) { static HPERM_OP(a, n, m) {
let t; let t = ((a << (16 - n)) ^ a) & m;
return a ^ t ^ (t >>> (16 - n));
t = ((a << (16 - n)) ^ a) & m;
a = a ^ t ^ (t >>> (16 - n));
return (a);
} }
des_set_key(key) { static des_set_key(key) {
let schedule = new Array(JopCrypt.ITERATIONS * 2); let schedule = new Array(Crypt.ITERATIONS * 2);
let c = this.fourBytesToInt(key, 0);
let d = this.fourBytesToInt(key, 4);
let results = new Array(2);
JopCrypt.PERM_OP(d, c, 4, 0x0f0f0f0f, results);
d = results[0];
c = results[1];
c = JopCrypt.HPERM_OP(c, -2, 0xcccc0000);
d = JopCrypt.HPERM_OP(d, -2, 0xcccc0000);
JopCrypt.PERM_OP(d, c, 1, 0x55555555, results);
d = results[0];
c = results[1];
JopCrypt.PERM_OP(c, d, 8, 0x00ff00ff, results); let c = Crypt.fourBytesToInt(key, 0);
c = results[0]; let d = Crypt.fourBytesToInt(key, 4);
d = results[1];
JopCrypt.PERM_OP(d, c, 1, 0x55555555, results); [d, c] = Crypt.PERM_OP(d, c, 4, 0x0f0f0f0f);
d = results[0]; c = Crypt.HPERM_OP(c, -2, 0xcccc0000);
c = results[1]; d = Crypt.HPERM_OP(d, -2, 0xcccc0000);
[d, c] = Crypt.PERM_OP(d, c, 1, 0x55555555);
[c, d] = Crypt.PERM_OP(c, d, 8, 0x00ff00ff);
[d, c] = Crypt.PERM_OP(d, c, 1, 0x55555555);
d = d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) |
(((d & 0x000000ff) << 16) | (d & 0x0000ff00) | ((d & 0x00ff0000) >>> 16) | ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4));
((c & 0xf0000000) >>> 4));
c &= 0x0fffffff; c &= 0x0fffffff;
let s, t;
let j = 0; let j = 0;
for (let i = 0; i < Crypt.ITERATIONS; i++) {
for (let i = 0; i < JopCrypt.ITERATIONS; i++) { if (Crypt.shifts2[i]) {
if (JopCrypt.shifts2[i]) {
c = (c >>> 2) | (c << 26); c = (c >>> 2) | (c << 26);
d = (d >>> 2) | (d << 26); d = (d >>> 2) | (d << 26);
} else { } else {
...@@ -307,16 +282,16 @@ class JopCrypt { ...@@ -307,16 +282,16 @@ class JopCrypt {
c &= 0x0fffffff; c &= 0x0fffffff;
d &= 0x0fffffff; d &= 0x0fffffff;
s = JopCrypt.skb[0][(c) & 0x3f] | let s = Crypt.skb[0][(c) & 0x3f] |
JopCrypt.skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)] | Crypt.skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)] |
JopCrypt.skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)] | Crypt.skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)] |
JopCrypt.skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | Crypt.skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) |
((c >>> 22) & 0x38)]; ((c >>> 22) & 0x38)];
t = JopCrypt.skb[4][(d) & 0x3f] | let t = Crypt.skb[4][(d) & 0x3f] |
JopCrypt.skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)] | Crypt.skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)] |
JopCrypt.skb[6][(d >>> 15) & 0x3f] | Crypt.skb[6][(d >>> 15) & 0x3f] |
JopCrypt.skb[7][((d >>> 21) & 0x0f) | ((d >>> 22) & 0x30)]; Crypt.skb[7][((d >>> 21) & 0x0f) | ((d >>> 22) & 0x30)];
schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff;
s = ((s >>> 16) | (t & 0xffff0000)); s = ((s >>> 16) | (t & 0xffff0000));
...@@ -337,23 +312,23 @@ class JopCrypt { ...@@ -337,23 +312,23 @@ class JopCrypt {
t = (v ^ (v << 16)) ^ R ^ s[S + 1]; t = (v ^ (v << 16)) ^ R ^ s[S + 1];
t = (t >>> 4) | (t << 28); t = (t >>> 4) | (t << 28);
L ^= JopCrypt.SPtrans[1][(t) & 0x3f] | JopCrypt.SPtrans[3][(t >>> 8) & 0x3f] | L ^= Crypt.SPtrans[1][(t) & 0x3f] | Crypt.SPtrans[3][(t >>> 8) & 0x3f] |
JopCrypt.SPtrans[5][(t >>> 16) & 0x3f] | JopCrypt.SPtrans[7][(t >>> 24) & 0x3f] | Crypt.SPtrans[5][(t >>> 16) & 0x3f] | Crypt.SPtrans[7][(t >>> 24) & 0x3f] |
JopCrypt.SPtrans[0][(u) & 0x3f] | JopCrypt.SPtrans[2][(u >>> 8) & 0x3f] | Crypt.SPtrans[0][(u) & 0x3f] | Crypt.SPtrans[2][(u >>> 8) & 0x3f] |
JopCrypt.SPtrans[4][(u >>> 16) & 0x3f] | JopCrypt.SPtrans[6][(u >>> 24) & 0x3f]; Crypt.SPtrans[4][(u >>> 16) & 0x3f] | Crypt.SPtrans[6][(u >>> 24) & 0x3f];
return L; return L;
} }
body(schedule, Eswap0, Eswap1) { static body(schedule, Eswap0, Eswap1) {
let left = 0; let left = 0;
let right = 0; let right = 0;
let t = 0; let t = 0;
for (let j = 0; j < 25; j++) { for (let j = 0; j < 25; j++) {
for (let i = 0; i < JopCrypt.ITERATIONS * 2; i += 4) { for (let i = 0; i < Crypt.ITERATIONS * 2; i += 4) {
left = JopCrypt.D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule); left = Crypt.D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule);
right = JopCrypt.D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule); right = Crypt.D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule);
} }
t = left; t = left;
left = right; left = right;
...@@ -368,37 +343,16 @@ class JopCrypt { ...@@ -368,37 +343,16 @@ class JopCrypt {
left &= 0xffffffff; left &= 0xffffffff;
right &= 0xffffffff; right &= 0xffffffff;
let results = new Array(2); [right, left] = Crypt.PERM_OP(right, left, 1, 0x55555555);
[left, right] = Crypt.PERM_OP(left, right, 8, 0x00ff00ff);
JopCrypt.PERM_OP(right, left, 1, 0x55555555, results); [right, left] = Crypt.PERM_OP(right, left, 2, 0x33333333);
right = results[0]; [left, right] = Crypt.PERM_OP(left, right, 16, 0x0000ffff);
left = results[1]; [right, left] = Crypt.PERM_OP(right, left, 4, 0x0f0f0f0f);
JopCrypt.PERM_OP(left, right, 8, 0x00ff00ff, results);
left = results[0];
right = results[1];
JopCrypt.PERM_OP(right, left, 2, 0x33333333, results);
right = results[0];
left = results[1];
JopCrypt.PERM_OP(left, right, 16, 0x0000ffff, results);
left = results[0];
right = results[1];
JopCrypt.PERM_OP(right, left, 4, 0x0f0f0f0f, results); return [left, right];
right = results[0];
left = results[1];
let out = new Array(2);
out[0] = left;
out[1] = right;
return (out);
} }
crypt(salt, original) { static crypt(salt, original) {
while (salt.length < 2) { while (salt.length < 2) {
salt += "A"; salt += "A";
} }
...@@ -408,13 +362,11 @@ class JopCrypt { ...@@ -408,13 +362,11 @@ class JopCrypt {
let charOne = salt.charAt(1) + ''; let charOne = salt.charAt(1) + '';
let ccZ = charZero.charCodeAt(0); let ccZ = charZero.charCodeAt(0);
let ccO = charOne.charCodeAt(0); let ccO = charOne.charCodeAt(0);
console.log("charZero", charZero, "charOne", charOne);
buffer = charZero + charOne + " "; buffer = charZero + charOne + " ";
console.log("buffer \"" + buffer + "\""); let Eswap0 = Crypt.con_salt[ccZ];
let Eswap0 = JopCrypt.con_salt[ccZ]; let Eswap1 = Crypt.con_salt[ccO] << 4;
let Eswap1 = JopCrypt.con_salt[ccO] << 4;
let key = [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]; let key = [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0];
...@@ -424,14 +376,13 @@ class JopCrypt { ...@@ -424,14 +376,13 @@ class JopCrypt {
key[i] = iChar << 1; key[i] = iChar << 1;
} }
let schedule = this.des_set_key(key); let schedule = Crypt.des_set_key(key);
let out = this.body(schedule, Eswap0, Eswap1); let out = Crypt.body(schedule, Eswap0, Eswap1);
let b = new Array(9); let b = new Array(9);
Crypt.intToFourBytes(out[0], b);
JopCrypt.intToFourBytes(out[0], b, 0); Crypt.intToFourBytes(out[1], b);
JopCrypt.intToFourBytes(out[1], b, 4); b.push(0);
b[8] = 0;
let y = 0; let y = 0;
for (let i = 2, u = 0x80; i < 13; i++) { for (let i = 2, u = 0x80; i < 13; i++) {
...@@ -449,7 +400,7 @@ class JopCrypt { ...@@ -449,7 +400,7 @@ class JopCrypt {
u = 0x80; u = 0x80;
} }
buffer = buffer =
buffer.substring(0, i) + String.fromCharCode(JopCrypt.cov_2char[c]) + buffer.substring(0, i) + String.fromCharCode(Crypt.cov_2char[c]) +
buffer.substring(i + 1, buffer.length); buffer.substring(i + 1, buffer.length);
} }
} }
......
...@@ -22,11 +22,8 @@ class OpWindMenu { ...@@ -22,11 +22,8 @@ class OpWindMenu {
get_opplace() { get_opplace() {
let query = window.location.search.substring(1); let query = window.location.search.substring(1);
let vars = query.split('&')[0];
console.log("query", query); return vars.substring(8);
let vars = query.split('&');
console.log("vars", vars.length, vars[0].substring(8));
return vars[0].substring(8);
} }
gdh_init_cb() { gdh_init_cb() {
...@@ -85,8 +82,7 @@ class OpWindMenu { ...@@ -85,8 +82,7 @@ class OpWindMenu {
} }
document.getElementById("login_frame").style.visibility = 'hidden'; document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px'; document.getElementById("login_frame").style.height = '0px';
let c = new JopCrypt(); passwd = Crypt.crypt("aa", passwd);
passwd = c.crypt("aa", passwd);
this.user = user; this.user = user;
this.gdh.login(user, passwd).then(this.login_cb); this.gdh.login(user, passwd).then(this.login_cb);
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
</div> </div>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel" src="crypt.ts"></script> <script type="text/babel" src="crypt.ts"></script>
<script type="text/babel" src="pwr.js"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="gdh.js"></script> <script type="text/babel" src="gdh.ts"></script>
<script type="text/babel" src="opwind.ts"></script> <script type="text/babel" src="opwind.ts"></script>
<hr> <hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address> <address><a href="mailto:claes@debian86.ssab.com"></a></address>
......
...@@ -34,10 +34,11 @@ ...@@ -34,10 +34,11 @@
</div> </div>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel" src="pwr.js"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="cli.js"></script> <script type="text/babel" src="cli.ts"></script>
<script type="text/babel" src="gdh.js"></script> <script type="text/babel" src="gdh.ts"></script>
<script type="text/babel" src="plow.js"></script> <script type="text/babel" src="draw.ts"></script>
<script type="text/babel" src="plow.ts"></script>
<script type="text/babel" src="xtt.ts"></script> <script type="text/babel" src="xtt.ts"></script>
<hr> <hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address> <address><a href="mailto:claes@debian86.ssab.com"></a></address>
......
...@@ -64,12 +64,11 @@ ...@@ -64,12 +64,11 @@
#include "rt_io_pnak_locals.h" #include "rt_io_pnak_locals.h"
#include "rt_pn_iface.h" #include "rt_pn_iface.h"
// static int count;
static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event);
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb_profiboard agent Init method for the Pb_profiboard agent
...@@ -345,6 +344,21 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap) ...@@ -345,6 +344,21 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
return sts; return sts;
} }
static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event)
{
switch (event) {
case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
errh_Fatal("Emergency break detected shutting down profinet");
IoAgentClose(ctx, ap);
break;
default:
break;
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
...@@ -352,4 +366,4 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap) ...@@ -352,4 +366,4 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
pwr_dExport pwr_BindIoMethods(PnControllerSoftingPNAK) pwr_dExport pwr_BindIoMethods(PnControllerSoftingPNAK)
= { pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead), = { pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose), pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose),
pwr_NullMethod }; pwr_BindIoMethod(IoAgentSwap), pwr_NullMethod };
...@@ -21,8 +21,19 @@ py_sources := $(sort \ ...@@ -21,8 +21,19 @@ py_sources := $(sort \
) \ ) \
) )
png_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
export_py := $(patsubst %.py, $(exe_dir)/%.py, $(py_sources)) export_py := $(patsubst %.py, $(exe_dir)/%.py, $(py_sources))
export_png := $(patsubst %.png, $(exe_dir)/%.png, $(png_sources))
clean_py := $(patsubst %.py, clean_%.py, $(py_sources)) clean_py := $(patsubst %.py, clean_%.py, $(py_sources))
clean_png := $(patsubst %.png, clean_%.png, $(png_sources))
.PHONY : all init copy lib exe clean realclean\ .PHONY : all init copy lib exe clean realclean\
...@@ -32,7 +43,7 @@ all : init copy | silent ...@@ -32,7 +43,7 @@ all : init copy | silent
init : silent init : silent
copy : $(export_py) | silent copy : $(export_py) $(export_png) | silent
lib : silent lib : silent
...@@ -40,7 +51,7 @@ exe : silent ...@@ -40,7 +51,7 @@ exe : silent
clean : clean :
realclean : clean $(clean_py) realclean : clean $(clean_py) $(clean_png)
silent : silent :
@ : @ :
...@@ -49,5 +60,12 @@ $(export_py) : $(exe_dir)/%.py : %.py ...@@ -49,5 +60,12 @@ $(export_py) : $(exe_dir)/%.py : %.py
@ echo "Exporting $< ..." @ echo "Exporting $< ..."
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
$(export_png) : $(exe_dir)/%.png : %.png
@ echo "Exporting $< ..."
@ $(cp) $(cpflags) $(source) $(target)
$(clean_py) : clean_%.py : %.py $(clean_py) : clean_%.py : %.py
@ rm $(exe_dir)/$*.py @ rm $(exe_dir)/$*.py
$(clean_png) : clean_%.png : %.png
@ rm $(exe_dir)/$*.png
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -140,7 +140,6 @@ private: ...@@ -140,7 +140,6 @@ private:
unique_ptr<QPainter> get_painter(int painter_type, int size); unique_ptr<QPainter> get_painter(int painter_type, int size);
void event_timer(FlowCtx* ctx, QMouseEvent *event, QWidget *target); void event_timer(FlowCtx* ctx, QMouseEvent *event, QWidget *target);
void cancel_event_timer(FlowCtx* ctx);
void (*draw_timer_callback_func)(FlowCtx* ctx); void (*draw_timer_callback_func)(FlowCtx* ctx);
QTimer* draw_timer_id; QTimer* draw_timer_id;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -403,7 +403,7 @@ GtkWidget* scrolledcolpalwidgetgtk_new( ...@@ -403,7 +403,7 @@ GtkWidget* scrolledcolpalwidgetgtk_new(
gtk_container_add(GTK_CONTAINER(viewport), GTK_WIDGET(w)); gtk_container_add(GTK_CONTAINER(viewport), GTK_WIDGET(w));
gtk_container_add(GTK_CONTAINER(form), GTK_WIDGET(viewport)); gtk_container_add(GTK_CONTAINER(form), GTK_WIDGET(viewport));
return (GtkWidget*)form; return form;
} }
GtkWidget* colpalnavwidgetgtk_new(GtkWidget* main_colpal) GtkWidget* colpalnavwidgetgtk_new(GtkWidget* main_colpal)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment