Compare commits
No commits in common. "master" and "0.4.14" have entirely different histories.
10
README.md
10
README.md
@ -20,16 +20,6 @@ LZ-String, Copyright 2013 pieroxy under MIT license https://github.com/pieroxy/l
|
||||
|
||||
## Changelog
|
||||
|
||||
### 0.4.16
|
||||
|
||||
* Fixed bug where properties window didn't disappear at certain times when it should
|
||||
|
||||
### 0.4.15
|
||||
|
||||
* Prepending ! or ~ (active low) before a pin name will now overline it when displayed on element
|
||||
* Fixed a bug that disabled a switch after it was disconnected
|
||||
* Fixed bug in how JK flipflops handled PRE and CLR and CLK
|
||||
|
||||
### 0.4.14
|
||||
|
||||
* Added WireNode element, allows you to better manage wires. Please note that signals only flow in the direction of connection! It is NOT a bidirectional element
|
||||
|
||||
@ -32,41 +32,25 @@ class CanvasTools {
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
drawTextCentered(ctx,x,y,x2,y2,text,fontStyle="24px Console",fontColor = "#555", Overline = false) {
|
||||
drawTextCentered(ctx,x,y,x2,y2,text,fontStyle="24px Console",fontColor = "#555") {
|
||||
ctx.save();
|
||||
ctx.font = fontStyle;
|
||||
ctx.fillStyle = fontColor;
|
||||
let textSize = this.textSize(ctx,text,fontStyle);
|
||||
let tHeight = ctx.measureText(text).actualBoundingBoxAscent + ctx.measureText(text).actualBoundingBoxDescent;
|
||||
let tX = x+((x2/2)-(ctx.measureText(text).width/2));
|
||||
let tY = y+tHeight+((y2/2)-(tHeight/2));
|
||||
if (Overline) {
|
||||
ctx.strokeStyle = fontColor;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tX,tY-textSize.height-1);
|
||||
ctx.lineTo(tX+textSize.width,tY-textSize.height-1);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
ctx.fillText(text,tX,tY);
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
drawText(ctx,x,y,text,fontStyle="24px Console",fontColor = "#555",Overline = false) {
|
||||
let textSize = this.textSize(ctx,text,fontStyle);
|
||||
drawText(ctx,x,y,text,fontStyle="24px Console",fontColor = "#555") {
|
||||
ctx.save();
|
||||
ctx.font = fontStyle;
|
||||
ctx.fillStyle = fontColor;
|
||||
ctx.fillText(text,x,y);
|
||||
if (Overline) {
|
||||
ctx.strokeStyle = fontColor;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x,y-textSize.height-2);
|
||||
ctx.lineTo(x+textSize.width,y-textSize.height-2);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ContainerConnection {
|
||||
|
||||
@ -239,7 +239,6 @@ class Element extends CanvasTools {
|
||||
this.OutputConnections.splice(a,1);
|
||||
a--;
|
||||
}
|
||||
this.Disconnecting = false;
|
||||
}
|
||||
this.drawElement(0,0,this.StaticCtx);
|
||||
}
|
||||
@ -355,17 +354,7 @@ class Element extends CanvasTools {
|
||||
if ((mouseDist <= (this.inputCircleRadius)) && this.LogicEngine.ActiveLink) ctx.fillStyle = circleColorHover;
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
let drawOverline = false;
|
||||
let label = this.InputLabels[a];
|
||||
|
||||
if (this.InputLabels[a] && drawFresh) {
|
||||
if (this.InputLabels[a].charAt(0) == "!" || this.InputLabels[a].charAt(0) == "~") {
|
||||
// Draw a NOT line
|
||||
drawOverline = true;
|
||||
label = this.InputLabels[a].substring(1);
|
||||
}
|
||||
this.drawText(ctx,x+(this.inputCircleRadius*2)+ 5,(firstY + (a*24)) + 5,label,"10px Console","#000",drawOverline);
|
||||
}
|
||||
if (this.InputLabels[a] && drawFresh) this.drawText(ctx,x+(this.inputCircleRadius*2)+ 5,(firstY + (a*24)) + 5,this.InputLabels[a],"10px Console","#000");
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
@ -390,18 +379,9 @@ class Element extends CanvasTools {
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
let textSize = false;
|
||||
let drawOverline = false;
|
||||
let label = this.OutputLabels[a];
|
||||
if (this?.OutputLabels[a]?.charAt(0) == "!" || this?.OutputLabels[a]?.charAt(0) == "~") {
|
||||
// Draw a NOT line
|
||||
drawOverline = true;
|
||||
label = this.OutputLabels[a].substring(1);
|
||||
}
|
||||
|
||||
if (this.OutputLabels[a]) textSize = this.textSize(ctx,label,"10px Console");
|
||||
if (this.OutputLabels[a] && drawFresh) {
|
||||
this.drawText(ctx,(x+(this.Width)) - (textSize.width + 5 + (this.outputCircleRadius*2)),(firstY + (a*24)) + 5,label,"10px Console","#000",drawOverline);
|
||||
}
|
||||
if (this.OutputLabels[a]) textSize = this.textSize(ctx,this.OutputLabels[a],"10px Console");
|
||||
if (this.OutputLabels[a] && drawFresh) this.drawText(ctx,(x+(this.Width)) - (textSize.width + 5 + (this.outputCircleRadius*2)),(firstY + (a*24)) + 5,this.OutputLabels[a],"10px Console","#000");
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
@ -3,12 +3,11 @@ class FlipFlopJK extends Element {
|
||||
super(_Container, RestoreData,logicengine,5);
|
||||
this.Name = "JK-FF";
|
||||
this.Outputs = new Array(2);
|
||||
this.InputLabels = new Array("J","!CLK","K","!PRE", "!CLR");
|
||||
this.InputLabels = new Array("J","CLK","K","!PRE", "!CLR");
|
||||
this.OutputLabels = new Array("Q","~Q");
|
||||
this.removeProperty("Inputs");
|
||||
this.Height = 140;
|
||||
this.Outputs[0] = true;
|
||||
this.Outputs[1] = true;
|
||||
|
||||
if (RestoreData) {
|
||||
this.Outputs = RestoreData.OutputStates;
|
||||
}
|
||||
@ -27,12 +26,9 @@ class FlipFlopJK extends Element {
|
||||
if (Value !== false) Value = true;
|
||||
let oldOutput = this.Outputs[0];
|
||||
let oldOutput2 = this.Outputs[1];
|
||||
let oldInput2 = this.Inputs[1];
|
||||
let oldInput3 = this.Inputs[3];
|
||||
let oldInput4 = this.Inputs[4];
|
||||
this.Inputs[Input] = Value;
|
||||
|
||||
if (!this.Inputs[1] && oldInput2) {
|
||||
if (this.Inputs[1]) {
|
||||
if (!this.Inputs[0] && this.Inputs[2]) {
|
||||
// set Q low
|
||||
this.Outputs[0] = false;
|
||||
@ -47,18 +43,11 @@ class FlipFlopJK extends Element {
|
||||
this.Outputs[1] = !this.Outputs[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (this.Inputs[4] && !oldInput4 && this.Outputs[0] && this.Outputs[1]) {
|
||||
this.Outputs[1] = false;
|
||||
}
|
||||
if (this.Inputs[3] && !oldInput3 && this.Outputs[0] && this.Outputs[1]) {
|
||||
this.Outputs[0] = false;
|
||||
}
|
||||
if (!this.Inputs[3] && oldInput3) {
|
||||
if (!this.Inputs[3]) {
|
||||
this.Outputs[0] = true;
|
||||
this.Outputs[1] = false;
|
||||
}
|
||||
if (!this.Inputs[4] && oldInput4) {
|
||||
if (!this.Inputs[4]) {
|
||||
this.Outputs[0] = false;
|
||||
this.Outputs[1] = true;
|
||||
}
|
||||
@ -116,37 +105,26 @@ class FlipFlopSR extends Element {
|
||||
if (Value !== false) Value = true;
|
||||
let oldOutput = this.Outputs[0];
|
||||
let oldOutput2 = this.Outputs[1];
|
||||
let oldInput1 = this.Inputs[1];
|
||||
let oldInput3 = this.Inputs[3];
|
||||
let oldInput4 = this.Inputs[4];
|
||||
|
||||
this.Inputs[Input] = Value;
|
||||
this.redraw = true;
|
||||
|
||||
if (this.Inputs[1] && !oldInput1) {
|
||||
if (this.Inputs[1]) {
|
||||
if (!this.Inputs[0] && this.Inputs[2]) {
|
||||
// set Q low
|
||||
this.Outputs[0] = false;
|
||||
this.Outputs[1] = true;
|
||||
} else if (this.Inputs[0] && !this.Inputs[2]) {
|
||||
// set Q high
|
||||
// set Q low
|
||||
this.Outputs[0] = true;
|
||||
this.Outputs[1] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.Inputs[4] && !oldInput4 && !this.Inputs[3] && this.Outputs[1]) {
|
||||
this.Outputs[1] = false;
|
||||
}
|
||||
if (this.Inputs[3] && !oldInput3 && !this.Inputs[4] && this.Outputs[0]) {
|
||||
this.Outputs[0] = false;
|
||||
}
|
||||
|
||||
if (!this.Inputs[3] && oldInput3) {
|
||||
if (!this.Inputs[3]) {
|
||||
this.Outputs[0] = true;
|
||||
this.Outputs[1] = false;
|
||||
}
|
||||
if (!this.Inputs[4] && oldInput4) {
|
||||
if (!this.Inputs[4]) {
|
||||
this.Outputs[0] = false;
|
||||
this.Outputs[1] = true;
|
||||
}
|
||||
@ -204,8 +182,6 @@ class FlipFlopT extends Element {
|
||||
if (Value !== false) Value = true;
|
||||
let oldOutput = this.Outputs[0];
|
||||
let oldOutput2 = this.Outputs[1];
|
||||
let oldInput2 = this.Inputs[2];
|
||||
let oldInput3 = this.Inputs[3];
|
||||
this.Inputs[Input] = Value;
|
||||
this.redraw = true;
|
||||
|
||||
@ -214,11 +190,11 @@ class FlipFlopT extends Element {
|
||||
this.Outputs[1] = !this.Outputs[0];
|
||||
}
|
||||
|
||||
if (!this.Inputs[2] && oldInput2) {
|
||||
if (!this.Inputs[2]) {
|
||||
this.Outputs[0] = true;
|
||||
this.Outputs[1] = false;
|
||||
}
|
||||
if (!this.Inputs[3] && oldInput3) {
|
||||
if (!this.Inputs[3]) {
|
||||
this.Outputs[0] = false;
|
||||
this.Outputs[1] = true;
|
||||
}
|
||||
@ -278,19 +254,18 @@ class FlipFlopD extends Element {
|
||||
let oldOutput = this.Outputs[0];
|
||||
let oldOutput2 = this.Outputs[1];
|
||||
let oldInput = this.Inputs[1];
|
||||
let oldInput2 = this.Inputs[2];
|
||||
let oldInput3 = this.Inputs[3];
|
||||
this.Inputs[Input] = Value;
|
||||
this.redraw = true;
|
||||
|
||||
if (this.Inputs[1] && !oldInput) {
|
||||
this.Outputs[0] = this.Inputs[0];
|
||||
this.Outputs[1] = !this.Outputs[0];
|
||||
}
|
||||
if (!this.Inputs[2] && oldInput2) {
|
||||
if (!this.Inputs[2]) {
|
||||
this.Outputs[0] = true;
|
||||
this.Outputs[1] = false;
|
||||
}
|
||||
if (!this.Inputs[3] && oldInput3) {
|
||||
if (!this.Inputs[3]) {
|
||||
this.Outputs[0] = false;
|
||||
this.Outputs[1] = true;
|
||||
}
|
||||
|
||||
@ -78,17 +78,9 @@ class ICInput extends Element {
|
||||
this.StaticCanvas.width = this.Width;
|
||||
this.StaticCanvas.height = this.Height;
|
||||
|
||||
let drawOverline = false;
|
||||
let label = (this.Properties[0].CurrentValue) ? this.Properties[0].CurrentValue.toString() : "";
|
||||
if (label.charAt(0) == "!" || label.charAt(0) == "~") {
|
||||
// Draw a NOT line
|
||||
drawOverline = true;
|
||||
label = label.substring(1);
|
||||
}
|
||||
|
||||
this.drawBorderBox(ctx,x+10,y,this.Width-30,this.Height);
|
||||
this.drawTextCentered(ctx,x,y+2,this.Width-10,14,this.Designator,"12px Console");
|
||||
this.drawTextCentered(ctx,x,y,this.Width-10,this.Height,label,"12px Console",undefined,drawOverline);
|
||||
this.drawTextCentered(ctx,x,y,this.Width-10,this.Height,this.Properties[0].CurrentValue,"12px Console");
|
||||
this.drawOutputs(ctx,x,y);
|
||||
}
|
||||
|
||||
@ -194,17 +186,9 @@ class ICOutput extends Element {
|
||||
this.StaticCanvas.width = this.Width;
|
||||
this.StaticCanvas.height = this.Height;
|
||||
|
||||
let drawOverline = false;
|
||||
let label = (this.Properties[0].CurrentValue) ? this.Properties[0].CurrentValue.toString() : "";
|
||||
if (label.charAt(0) == "!" || label.charAt(0) == "~") {
|
||||
// Draw a NOT line
|
||||
drawOverline = true;
|
||||
label = label.substring(1);
|
||||
}
|
||||
|
||||
this.drawBorderBox(ctx,x+20,y,this.Width-10,this.Height);
|
||||
this.drawTextCentered(ctx,x+20,y+2,this.Width-10,14,this.Designator,"12px Console");
|
||||
this.drawTextCentered(ctx,x+20,y,this.Width-10,this.Height,label,"12px Console",undefined,drawOverline);
|
||||
this.drawTextCentered(ctx,x+20,y,this.Width-10,this.Height,this.Properties[0].CurrentValue,"12px Console");
|
||||
this.drawInputs(ctx,x,y,undefined,undefined,undefined,undefined,true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,11 +307,12 @@ class InputKeypad extends inputElement {
|
||||
for (let pX = 0; pX < this.ButtonColumns; pX++) {
|
||||
this.drawBorderBox(ctx, x + (5*(pX+1))+(buttonWidth*pX), y + (5*(pY+1))+(buttonHeight*pY), buttonWidth, buttonHeight, 1, "#ccc", "#777");
|
||||
this.drawTextCentered(ctx,x + (5*(pX+1))+(buttonWidth*pX), y + (5*(pY+1))+(buttonHeight*pY), buttonWidth, buttonHeight, this.Buttons[(pY*this.ButtonColumns) + pX].Text,"16px Console", "#fff");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.drawTextCentered(ctx,x,y+(this.Height-14),this.Width-(this.outputCircleRadius*2),12,this.Designator,"12px Console","#000");
|
||||
this.drawOutputs(ctx,x,y,undefined,undefined,undefined,undefined,true);
|
||||
this.drawOutputs(ctx,x,y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -266,11 +266,6 @@ function HideHelp() {
|
||||
helpWindow.style.display = "none";
|
||||
}
|
||||
|
||||
function HidePropertiesWindow() {
|
||||
let propwin = document.getElementById("PropertiesBox");
|
||||
propwin.style.display = "none";
|
||||
}
|
||||
|
||||
function SaveSettings() {
|
||||
localStorage.setItem("LogicEngineSettings",JSON.stringify(logicEngine.Settings));
|
||||
console.log("Settings Saved");
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
MatCat BrowserLogic Simulator
|
||||
*/
|
||||
|
||||
let Version = "0.4.16";
|
||||
let Version = "0.4.14";
|
||||
|
||||
let spanVersion = document.getElementById("version");
|
||||
spanVersion.innerText = Version;
|
||||
|
||||
@ -34,15 +34,12 @@ function RightClickMenuListeners() {
|
||||
logicEngine.Ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
logicEngine.Panning.OffsetX = 0;
|
||||
logicEngine.Panning.OffsetY = 0;
|
||||
HidePropertiesWindow();
|
||||
disableSelectedMenus(true);
|
||||
|
||||
});
|
||||
|
||||
let rcm_Delete = document.getElementById("rcm_Delete");
|
||||
rcm_Delete.addEventListener('click', function (evt) {
|
||||
logicEngine.Key_Press({ctrlKey: false, key: "Delete"});
|
||||
HidePropertiesWindow();
|
||||
disableSelectedMenus(true);
|
||||
});
|
||||
|
||||
|
||||
@ -80,9 +80,6 @@ function TopMenuListeners() {
|
||||
logicEngine.Ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
logicEngine.Panning.OffsetX = 0;
|
||||
logicEngine.Panning.OffsetY = 0;
|
||||
HidePropertiesWindow();
|
||||
disableSelectedMenus(true);
|
||||
|
||||
setTimeout(function () {
|
||||
hideMenus()
|
||||
}, 10);
|
||||
@ -119,7 +116,6 @@ function TopMenuListeners() {
|
||||
let tfm_Delete = document.getElementById("tfm_Delete");
|
||||
tfm_Delete.addEventListener('click', function (evt) {
|
||||
logicEngine.Key_Press({ctrlKey: false, key: "Delete"});
|
||||
HidePropertiesWindow();
|
||||
disableSelectedMenus(true);
|
||||
setTimeout(function () {
|
||||
hideMenus()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user