small changes to code

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Sandu Victor 2019-10-14 21:00:42 +03:00 committed by prescientmoon
parent cfd5714220
commit c0ea9eb319
Signed by: prescientmoon
SSH key fingerprint: SHA256:WFp/cO76nbarETAoQcQXuV+0h7XJsEsOCI0UsyPIy6U
16 changed files with 1171 additions and 1264 deletions

View file

@ -1,5 +1,6 @@
<html>
<head>.
<head>.
<title>
Logic simulator
</title>
@ -13,9 +14,10 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
!--Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body id="body">
<svg height = "100%" width = "100%" id = "svg1" viewbox = "0 0 700 700">
</head>
<body id="body">
<svg height="100%" width="100%" id="svg1" viewbox="0 0 700 700">
</svg>
<!--And-->
@ -48,15 +50,15 @@
<script src="scripts/main.js"></script>
<div class = "modal fade" id = "addel">
<div class = "modal-dialog">
<div class = "modal-content">
<div class = "modal-header">
<div class="modal fade" id="addel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<p>
Add a piece!
</p>
</div>
<div class = "modal-body">
<div class="modal-body">
<select id="sel">
<option value = "not">Not gate</option>
<option value = "light">Light bulb</option>
@ -67,12 +69,11 @@
<option value = "nand">Nand gate</option>
<option value = "nand3">Nand gate (3 inputs)</option>
<option value = "xor">Xor gate</option>
</select>
Quantity:
<input id = "times" type = "number">
</select> Quantity:
<input id="times" type="number">
</div>
<div class = "modal-footer">
<button type="button" onclick = '$("#addel").modal("hide"); addel();' class="btn btn-primmary" id = "done">
<div class="modal-footer">
<button type="button" onclick='$("#addel").modal("hide"); addel();' class="btn btn-primmary" id="done">
Add!!!
</button>
</div>
@ -80,17 +81,6 @@
</div>
</div>
<link href="st.css" rel="Stylesheet" type="text/css" />
</body>
</body>
</html>

View file

@ -1,83 +1,79 @@
console.log("and");
function and(id){
class and {
constructor(id) {
this.id = id;
this.rep = add(80,80,"blue","black",this.id,false);
this.rep = add(80, 80, "blue", "black", this.id, false);
this.pin1 = new pin(0);
this.pin2 = new pin(0);
this.o = new pin(1);
this.o.nei = this;
this.activation = function(){
if (this.pin1.val && this.pin2.val){
this.activation = function() {
if (this.pin1.val && this.pin2.val) {
return true;
}
return false;
}
this.x = function(){
};
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
};
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
};
//design
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
let skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
x: "50",
y: "50",
id: (id+"-skin"),
width:"80",
height:"80"
id: (id + "-skin"),
width: "80",
height: "80"
});
var img = $(document.createElement('img')).attr({
height:"72",
width:"72",
src:"textures/gates/and_gate.jpg"
let img = $(document.createElement('img')).attr({
height: "72",
width: "72",
src: "textures/gates/and_gate.jpg"
});
var iDiv = document.createElement("div");
let iDiv = document.createElement("div");
$(iDiv).append(img);
this.skin = skin;
this.img = img;
$(skin).append(iDiv);
//noname(this);
$(g).append(skin);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//updating
this.update = function(){
this.update = function() {
//the main object and his pins
let x = this.x();
let y = this.y();
this.pin1.set(x-20,y);
this.pin2.set(x-20,y+60);
this.o.set(x+80,y+30);
this.pin1.set(x - 20, y);
this.pin2.set(x - 20, y + 60);
this.o.set(x + 80, y + 30);
//and the skin
var name = "#"+this.id+"-skin";
var skin = $(name);
skin.attr("x",(parseFloat($((this.rep)).attr("x"))+4).toString());
skin.attr("y",(parseFloat($((this.rep)).attr("y"))+4).toString());
}
let name = "#" + this.id + "-skin";
let skin = $(name);
skin.attr("x", (parseFloat($((this.rep)).attr("x")) + 4).toString());
skin.attr("y", (parseFloat($((this.rep)).attr("y")) + 4).toString());
};
pieces[pieces.length] = this;
addclk(this);
}
}
function addclk(ob){
var rep = ob.rep;
$((ob.img)).on("mousedown touchstart",function(e){
function addclk(ob) {
$((ob.img)).on("mousedown touchstart", function(e) {
e.preventDefault();
var svg = document.getElementById("svg1");
let svg = document.getElementById("svg1");
$(svg).append(ob.rep);
$(svg).append($(ob.pin1.rep));
$(svg).append($(ob.pin2.rep));
@ -85,20 +81,7 @@ function addclk(ob){
$(svg).append($(ob.skin));
selected = ob.id;
});
$((ob.img)).on("mouseup touchend",function(e){
$((ob.img)).on("mouseup touchend", function() {
selected = "yay";
});
}
/*
function noname(ob){
$((ob.img)).on("mousedown touchstart",function(e){
selected = ob.id;
console.log("Clicked!!!");
});
$((ob.img)).on("mouseup touchend",function(e){
selected = "yay";
});
}
*/

View file

@ -1,70 +1,70 @@
function buffer(id){
function buffer(id) {
this.id = id;
this.name = "#" + this.id;
this.rep = add(80,80,"green","black",this.id,true);
this.rep = add(80, 80, "green", "black", this.id, true);
this.pin1 = new pin(0);
this.o = new pin(1);
this.o.nei = this;
//this.text = new text(this,"Or-gate");
this.activation = function(){
if (this.pin1.val){
this.activation = function() {
if (this.pin1.val) {
return true;
}
return false;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
//design
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
let skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
x: "50",
y: "50",
id: (id+"-skin"),
width:"80",
height:"80"
id: (id + "-skin"),
width: "80",
height: "80"
});
var img = $(document.createElement('img')).attr({
height:"80",
width:"80",
src:"textures/gates/buffer_gate.jpg"
let img = $(document.createElement('img')).attr({
height: "80",
width: "80",
src: "textures/gates/buffer_gate.jpg"
});
var iDiv = document.createElement("div");
let iDiv = document.createElement("div");
$(iDiv).append(img);
this.skin = skin;
this.img = img;
$(skin).append(iDiv);
//noname(this);
$(g).append(skin);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//updating
this.update = function(){
this.update = function() {
//the main object and his pins
let x = this.x();
let y = this.y();
this.pin1.set(x-20,y+30);
this.o.set(x+80,y+30);
this.pin1.set(x - 20, y + 30);
this.o.set(x + 80, y + 30);
//and the skin
var name = "#"+this.id+"-skin";
var skin = $(name);
skin.attr("x",(parseFloat($((this.rep)).attr("x"))+4).toString());
skin.attr("y",(parseFloat($((this.rep)).attr("y"))+4).toString());
let name = "#" + this.id + "-skin";
let skin = $(name);
skin.attr("x", (parseFloat($((this.rep)).attr("x")) + 4).toString());
skin.attr("y", (parseFloat($((this.rep)).attr("y")) + 4).toString());
}
pieces[pieces.length] = this;

View file

@ -1,79 +1,63 @@
console.log("nut");
function but(id){
function but(id) {
this.wait = true;
this.id = id;
this.rep = add(80,80,"orange","black",this.id,true);
this.rep = add(80, 80, "orange", "black", this.id, true);
this.o = new pin(1);
this.val = false;
addevt(this);
$((this.rep)).attr("stroke-width",4);
$((this.rep)).attr("stroke","black");
$((this.rep)).attr("stroke-width", 4);
$((this.rep)).attr("stroke", "black");
this.o.nei = this;
this.activation = function(){
this.activation = function() {
return this.val;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
//design
this.init = function(){
this.init = function() {
return 0;
}
this.update = function(){
this.update = function() {
let x = this.x();
let y = this.y();
this.o.set(x+80,y+30);
this.o.set(x + 80, y + 30);
}
pieces[pieces.length] = this;
}
function addevt(ob){
/*
$((ob.rep)).on("click touchstart",function(){
ob.val = (ob.val+1)%2;
if (ob.val){
$((ob.rep)).attr("fill","red");
}
else{
$((ob.rep)).attr("fill","orange");
}
});
*/
$((ob.rep)).on("mousedown touchstart",function(e){
var svg = document.getElementById("svg1");
function addevt(ob) {
$((ob.rep)).on("mousedown touchstart", function(e) {
let svg = document.getElementById("svg1");
$(svg).append(ob.rep);
$(svg).append($(ob.o.rep));
selected = ob.id;
e.preventDefault();
if (ob.wait){
ob.val = (ob.val+1)%2;
if (ob.val){
$((ob.rep)).attr("fill","red");
}
else{
$((ob.rep)).attr("fill","orange");
if (ob.wait) {
ob.val = (ob.val + 1) % 2;
if (ob.val) {
$((ob.rep)).attr("fill", "red");
} else {
$((ob.rep)).attr("fill", "orange");
}
ob.wait = false;
}
});
$((ob.rep)).on("mouseup touchend",function(e){
$((ob.rep)).on("mouseup touchend", function() {
selected = "yay";
ob.wait = true;
});
}

View file

@ -1,66 +1,66 @@
var l_count = 0;
var lines = [];
let l_count = 0;
let lines = [];
console.log("started2");
function edge(start,end){
this.id = l_count.toString()+"line";
function edge(start, end) {
this.id = l_count.toString() + "line";
l_count++;
this.start = start;
this.end = end;
console.log(start+end);
console.log(start + end);
console.log(this.end);
console.log(this.start);
lines[lines.length] = this;
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var el = $(document.createElementNS('http://www.w3.org/2000/svg', 'line')).attr({
let el = $(document.createElementNS('http://www.w3.org/2000/svg', 'line')).attr({
x1: "50",
y1:"50",
x2:"55",
y2:"55",
y1: "50",
x2: "55",
y2: "55",
id: this.id,
fill:"yellow",
fill: "yellow",
stroke: "black"
});
$(el).attr("stroke-width","2");
$(el).attr("stroke-width", "2");
$(g).append(el);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//console.log("succes"+lines);
this.rep = el;
this.name = "#"+this.id;
this.name = "#" + this.id;
this.update = function(){
this.update = function() {
let adr = this.start.name;
let temp = $(adr).attr("x");
let n = this.name;
//console.log("updating"+adr+temp+n);
temp = (parseFloat(temp)).toString();
$(n).attr("x1",temp);
$(n).attr("x1", temp);
temp = $(adr).attr("y");
temp = (parseFloat(temp)+10).toString();
$(n).attr("y1",temp);
temp = (parseFloat(temp) + 10).toString();
$(n).attr("y1", temp);
adr = this.end.name;
temp = $(adr).attr("x");
temp = (parseFloat(temp)+20).toString();
$(n).attr("x2",temp);
temp = (parseFloat(temp) + 20).toString();
$(n).attr("x2", temp);
temp = $(adr).attr("y");
temp = (parseFloat(temp)+10).toString();
$(n).attr("y2",temp);
temp = (parseFloat(temp) + 10).toString();
$(n).attr("y2", temp);
//and the color based on the state
if (this.start.val){
$((this.rep)).attr("stroke","yellow");
}
else{
$((this.rep)).attr("stroke","black");
if (this.start.val) {
$((this.rep)).attr("stroke", "yellow");
} else {
$((this.rep)).attr("stroke", "black");
}
}
@ -68,11 +68,11 @@ function edge(start,end){
rem_edge(this);
}
function rem_edge(ob){
$((ob.rep)).on("click touchstart",function(e){
function rem_edge(ob) {
$((ob.rep)).on("click touchstart", function(e) {
e.preventDefault();
//removing the edge from the array
for (var i = 0; i < lines.length; i++) {
for (let i = 0; i < lines.length; i++) {
if (lines[i] == (ob.id)) {
lines.splice(i, 1);
}
@ -89,7 +89,3 @@ function rem_edge(ob){
ob.end.state = true;
});
}

View file

@ -1,85 +1,80 @@
window.addEventListener("keydown", function(e) {
// space and arrow keys
if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
if ([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
e.preventDefault();
}
}, false);
var xvb = 0;
var yvb=0;
var zoomx = window.innerWidth;
var zoomy = window.innerHeight;
let xvb = 0;
let yvb = 0;
let zoomx = window.innerWidth;
let zoomy = window.innerHeight;
updatescr();
function updatescr(){
if (zoomx < 51){
function updatescr() {
if (zoomx < 51) {
zoomx += 50;
}
if (zoomy < 51){
if (zoomy < 51) {
zoomy += 50;
}
let newname = xvb.toString() + " " + yvb.toString() + " " + zoomx.toString() + " " + zoomy.toString();
$("#svg1").removeAttr("viewBox");
$("#svg1").each(function(){$(this)[0].setAttribute("viewBox",newname)});
$("#svg1").each(function() { $(this)[0].setAttribute("viewBox", newname) });
}
document.addEventListener("keydown",e=> {
if(e.keyCode == 40){
document.addEventListener("keydown", e => {
if (e.keyCode == 40) {
yvb += 10;
updatescr();
}
else if(e.keyCode == 39){
} else if (e.keyCode == 39) {
xvb += 10;
updatescr();
}
else if(e.keyCode == 38){
} else if (e.keyCode == 38) {
yvb -= 10;
updatescr();
}
else if(e.keyCode == 37){
} else if (e.keyCode == 37) {
xvb -= 10;
updatescr();
}
else if(e.keyCode == 187){
if (!(zoomx < 101)&&!(zoomy < 101)){
} else if (e.keyCode == 187) {
if (!(zoomx < 101) && !(zoomy < 101)) {
xvb += 25;
yvb += 25;
}
zoomx -= 50;
zoomy -= 50;
updatescr();
}
else if(e.keyCode == 189){
} else if (e.keyCode == 189) {
xvb -= 25;
yvb -= 25;
zoomx += 50;
zoomy += 50;
updatescr();
}
},false);
}, false);
var zooming = false;
var xbeg = 0;
var ybeg = 0;
var moveing = false;
let zooming = false;
let xbeg = 0;
let ybeg = 0;
let moveing = false;
$("svg").on("mousemove touchmove",function(e){
if (moveing && selected == "yay"){
if (!(zooming)){
$("svg").on("mousemove touchmove", function(e) {
if (moveing && selected == "yay") {
if (!(zooming)) {
zooming = true;
//setting our first mouse poitions
xbeg = e.pageX * zoomx/window.innerWidth;
ybeg = e.pageY * zoomy/window.innerHeight;
xbeg = e.pageX * zoomx / window.innerWidth;
ybeg = e.pageY * zoomy / window.innerHeight;
xbeg += xvb;
ybeg += yvb;
console.log("started zooming"+xbeg+"and"+ybeg);
console.log("started zooming" + xbeg + "and" + ybeg);
//moveing = (moveing +1)%2;
}
var newx = e.pageX * zoomx/window.innerWidth;
var newy = e.pageY * zoomy/window.innerHeight;
let newx = e.pageX * zoomx / window.innerWidth;
let newy = e.pageY * zoomy / window.innerHeight;
newx += xvb;
newy += yvb;
@ -88,31 +83,20 @@ $("svg").on("mousemove touchmove",function(e){
yvb -= newy - ybeg;
updatescr();
console.log(xvb+"newx"+newx+"xbeg"+xbeg);
console.log(xvb + "newx" + newx + "xbeg" + xbeg);
}
});
$("svg").on("mousedown touchstart",function(e){
$("svg").on("mousedown touchstart", function() {
//e.preventDefault();
moveing = true;
});
$("svg").on("mouseup touchend",function(e){
$("svg").on("mouseup touchend", function(e) {
e.preventDefault();
selected = "yay";
zooming = false;
moveing = false;
});

View file

@ -1,84 +1,78 @@
console.log("bulb");
function light(id){
function light(id) {
this.id = id;
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var el = $(document.createElementNS('http://www.w3.org/2000/svg', 'circle')).attr({
let el = $(document.createElementNS('http://www.w3.org/2000/svg', 'circle')).attr({
cx: "50",
cy:"50",
cy: "50",
r: "40",
id: this.id,
fill:"white",
fill: "white",
stroke: "black"
});
$(el).attr("stroke-width","2");
$(el).attr("class","light");
$(el).attr("stroke-width", "2");
$(el).attr("class", "light");
$(g).append(el);
//$(el).attr("onmousedown","selected='"+this.id+"';");
$(el).attr("onmouseup","selected='yay';");
var elem = document.getElementById("svg1");
$(el).attr("onmouseup", "selected='yay';");
let elem = document.getElementById("svg1");
elem.appendChild(g);
this.rep = el;
this.i = new pin(0);
this.val = false;
//addevt(this);
$((this.rep)).attr("stroke-width",4);
$((this.rep)).attr("stroke-width", 4);
this.activation = function(){
this.activation = function() {
return this.i.val;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("cx"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("cy"));
}
//design
this.init = function(){
this.init = function() {
return 0;
}
this.update = function(){
if (this.i.val != "yay"){
if ((this.activation())){
$((this.rep)).attr("fill","yellow");
}
else{
$((this.rep)).attr("fill","white");
this.update = function() {
if (this.i.val != "yay") {
if ((this.activation())) {
$((this.rep)).attr("fill", "yellow");
} else {
$((this.rep)).attr("fill", "white");
}
}
//console.log($((this.rep)).attr("fill"));
let x = this.x();
let y = this.y();
this.i.set(x-60,y-10);
this.i.set(x - 60, y - 10);
}
pieces[pieces.length] = this;
addclk_light(this);
}
function addclk_light(ob){
var rep = ob.rep;
$(ob.rep).on("mousedown touchstart",function(e){
function addclk_light(ob) {
$(ob.rep).on("mousedown touchstart", function(e) {
e.preventDefault();
var svg = document.getElementById("svg1");
let svg = document.getElementById("svg1");
$(svg).append(ob.rep);
$(svg).append($(ob.i.rep));
selected=ob.id;
selected = ob.id;
});
}

View file

@ -6,22 +6,19 @@
//====================first adding the modal=================================
//order is used to generate new id's for components
var order = 0;
//selected indicates what is the last element the user clicked on
var selecte="yay"
let order = 0;
//piece would contain all the components
//(without pins and edges)
//we will use that array for updating the value and the position
var pieces = [];
let pieces = [];
//this 'modal' variable is used to keep the blue box
//this 'modal' letiable is used to keep the blue box
//basically when you click on it the modal for adding components will pop
var modal = add(40,40,"blue","black","butt",false);
let modal = add(40, 40, "blue", "black", "butt", false);
//adding the event for clicking
$(modal).on("mousedown touchstart",function(e){
$(modal).on("mousedown touchstart", function() {
//showing the modal
//actually 'modal' is just the button
@ -36,32 +33,32 @@ $(modal).on("mousedown touchstart",function(e){
});
//the event for finishing the drag and drop on the blue box
$(modal).on("mouseup touchend",function(e){
$(modal).on("mouseup touchend", function() {
//telling that we dont want to drag it anymore
selected = "yay";
});
//changing the positon of the blue box
//we dont want it to be in the left top corner at 0 0
$(modal).attr("y","500");
$(modal).attr("x","500");
$(modal).attr("y", "500");
$(modal).attr("x", "500");
//var desc = new text(modal,"+")
//let desc = new text(modal,"+")
//used for actually getting the new ids
function getname(){
function getname() {
//getting the 'order'
//than making it bigger by 1
//convert it to string
//than add 'piece' to it for avoiding confusion between pieces and pins
return ((order++).toString()+"piece")
return ((order++).toString() + "piece")
}
//the function that fires when you tap 'add'
function addel(){
for (var i = 0;i < parseFloat($("#times").val());i++){
var added = eval("new "+$("#sel option:selected").attr("value")+"(getname())");
function addel() {
for (let i = 0; i < parseFloat($("#times").val()); i++) {
let added = eval("new " + $("#sel option:selected").attr("value") + "(getname())");
}
}
@ -71,32 +68,32 @@ function addel(){
//================================preventing deafult actions==========================
//nothing to say here
$("img,rect,circle,p,foreignObject").on("mousedown touchstart",function(e){
$("img,rect,circle,p,foreignObject").on("mousedown touchstart", function(e) {
e.preventDefault();
});
$("*").on("mouseup touchend",function(e){
$("*").on("mouseup touchend", function(e) {
e.preventDefault();
moveing = false;
});
$("img").on("click touchstart",function(e){
$("img").on("click touchstart", function(e) {
e.preventDefault();
});
//===============================variables============================================
//===============================letiables============================================
//setting the drag and drop to our value
//'yay' means 'nothing selected'
var selected = "yay";
let selected = "yay";
//the first positios of the clicks
var firstx = 0;
var firsty = 0;
let firstx = 0;
let firsty = 0;
//the first position of an element dragged
var fx = 0;
var fy = 0;
let fx = 0;
let fy = 0;
//snap settings
let snap = false;
@ -105,36 +102,35 @@ let snap = false;
//nothing to say here...
//just some basic things
$("body").on("mousemove touchmove",function(e){
$("body").on("mousemove touchmove", function(e) {
//calling the drag function
drag(e,selected);
drag(e, selected);
});
$("body").on("mouseup touchend",function(e){
$("body").on("mouseup touchend", function(e) {
selected = "yay";
console.log("got a mouse up");
});
$("body").on("mousedown touchstart",function(e){
$("body").on("mousedown touchstart", function(e) {
//beeing sure that we actually want to drag something
if (selected!="yay"){
if (selected != "yay") {
//setting our first mouse poitions
firstx = e.pageX * zoomx/window.innerWidth;
firsty = e.pageY * zoomy/window.innerHeight;
firstx = e.pageX * zoomx / window.innerWidth;
firsty = e.pageY * zoomy / window.innerHeight;
firstx += xvb;
firsty += yvb;
//conveerting the id to an actual thing
name = "#"+selected;
name = "#" + selected;
//beeing sure we get the corect attributes
//circle have 'cx' and 'cy'
//and rectangles have 'x' and 'y'
if ($(name).attr("class")=="light"){
if ($(name).attr("class") == "light") {
fx = parseFloat($(name).attr("cx"));
fy = parseFloat($(name).attr("cy"));
}
else{
} else {
fx = parseFloat($(name).attr("x"));
fy = parseFloat($(name).attr("y"));
}
@ -147,7 +143,7 @@ $("body").on("mousedown touchstart",function(e){
//thefunction that tranfers the data from the event to our set_position function
function drag(e,selected){
function drag(e, selected) {
//the name
let name = "#" + selected;
@ -156,17 +152,17 @@ function drag(e,selected){
let x = e.pageX;
let y = e.pageY;
x *= zoomx/window.innerWidth;
y *= zoomy/window.innerHeight;
x *= zoomx / window.innerWidth;
y *= zoomy / window.innerHeight;
//updating positions
set_position(name,x,y);
set_position(name, x, y);
}
//our main place to change things
function set_position(name,x,y){
var obj,objx,objy;
obj = "#"+selected;
function set_position(name, x, y) {
let obj, objx, objy;
obj = "#" + selected;
x = parseFloat(x);
y = parseFloat(y);
@ -176,9 +172,9 @@ function set_position(name,x,y){
if ($(name).attr("class")!="light"){
//getting the variables
obj = "#"+selected;
if ($(name).attr("class") != "light") {
//getting the letiables
obj = "#" + selected;
objx = parseFloat($(obj).attr("x"));
objy = parseFloat($(obj).attr("y"));
@ -193,19 +189,18 @@ function set_position(name,x,y){
//x -= parseFloat($(obj).attr("width"));
//y -= parseFloat($(obj).attr("height"));
if (snap){
x = Math.floor(x/80)*80;
y = Math.floor(y/80)*80;
if (snap) {
x = Math.floor(x / 80) * 80;
y = Math.floor(y / 80) * 80;
}
//console.log("obj:"+obj+"objx:"+objx+"objy:"+objy+"xdif:"+xdif+"ydif:"+ydif)
//setting the new positions
$(obj).attr("x",(x).toString());
$(obj).attr("y",(y).toString());
}
else{
$(obj).attr("x", (x).toString());
$(obj).attr("y", (y).toString());
} else {
//for circles
//getting the variables
obj = "#"+selected;
//getting the letiables
obj = "#" + selected;
objx = parseFloat($(obj).attr("cx"));
objy = parseFloat($(obj).attr("cy"));
@ -220,57 +215,58 @@ function set_position(name,x,y){
//x -= parseFloat($(obj).attr("width"));
//y -= parseFloat($(obj).attr("height"));
if (snap){
x = Math.floor(x/80)*80+40;
y = Math.floor(y/80)*80+40;
if (snap) {
x = Math.floor(x / 80) * 80 + 40;
y = Math.floor(y / 80) * 80 + 40;
}
//console.log("obj:"+obj+"objx:"+objx+"objy:"+objy+"xdif:"+xdif+"ydif:"+ydif)
//setting the new positions
$(obj).attr("cx",(x).toString());
$(obj).attr("cy",(y).toString());
$(obj).attr("cx", (x).toString());
$(obj).attr("cy", (y).toString());
}
}
function add(h,w,color,stroke,id,on){
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
function add(h, w, color, stroke, id, on) {
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var el = $(document.createElementNS('http://www.w3.org/2000/svg', 'rect')).attr({
let el = $(document.createElementNS('http://www.w3.org/2000/svg', 'rect')).attr({
x: "50",
y:"50",
y: "50",
id: id,
fill:color,
height: h.toString()+"px",
width: w.toString()+"px",
fill: color,
height: h.toString() + "px",
width: w.toString() + "px",
stroke: stroke,
rx:"20",
ry:"20"
rx: "20",
ry: "20"
});
if (on){
$(el).attr("onmousedown","selected='"+id+"';");
$(el).attr("onmouseup","selected='yay';");
if (on) {
$(el).attr("onmousedown", "selected='" + id + "';");
$(el).attr("onmouseup", "selected='yay';");
}
$(el).attr("stroke-width","4");
$(el).attr("stroke-width", "4");
$(g).append(el);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
return el;
}
console.log(pieces);
setInterval(function(){
for (var i = 0;i < pieces.length;i++){
setInterval(function() {
for (let i = 0; i < pieces.length; i++) {
pieces[i].update();
}
for (var i = 0;i < lines.length;i++){
for (let i = 0; i < lines.length; i++) {
lines[i].update();
}
for (var i = 0;i < pins.length;i++){
for (let i = 0; i < pins.length; i++) {
pins[i].update();
}
},0.001);
}, 0.001);

View file

@ -1,72 +1,72 @@
function nand(id){
function nand(id) {
this.id = id;
this.name = "#" + this.id;
this.rep = add(80,80,"green","black",this.id,true);
this.rep = add(80, 80, "green", "black", this.id, true);
this.pin1 = new pin(0);
this.pin2 = new pin(0);
this.o = new pin(1);
this.o.nei = this;
//this.text = new text(this,"Or-gate");
this.activation = function(){
if (!(this.pin1.val && this.pin2.val)){
this.activation = function() {
if (!(this.pin1.val && this.pin2.val)) {
return true;
}
return false;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
//design
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
let skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
x: "50",
y: "50",
id: (id+"-skin"),
width:"80",
height:"80"
id: (id + "-skin"),
width: "80",
height: "80"
});
var img = $(document.createElement('img')).attr({
height:"80",
width:"80",
src:"textures/gates/nand_gate.jpg"
let img = $(document.createElement('img')).attr({
height: "80",
width: "80",
src: "textures/gates/nand_gate.jpg"
});
var iDiv = document.createElement("div");
let iDiv = document.createElement("div");
$(iDiv).append(img);
this.skin = skin;
this.img = img;
$(skin).append(iDiv);
//noname(this);
$(g).append(skin);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//updating
this.update = function(){
this.update = function() {
//the main object and his pins
let x = this.x();
let y = this.y();
this.pin1.set(x-20,y);
this.pin2.set(x-20,y+60);
this.o.set(x+80,y+30);
this.pin1.set(x - 20, y);
this.pin2.set(x - 20, y + 60);
this.o.set(x + 80, y + 30);
//and the skin
var name = "#"+this.id+"-skin";
var skin = $(name);
skin.attr("x",(parseFloat($((this.rep)).attr("x"))+4).toString());
skin.attr("y",(parseFloat($((this.rep)).attr("y"))+4).toString());
let name = "#" + this.id + "-skin";
let skin = $(name);
skin.attr("x", (parseFloat($((this.rep)).attr("x")) + 4).toString());
skin.attr("y", (parseFloat($((this.rep)).attr("y")) + 4).toString());
}
pieces[pieces.length] = this;

View file

@ -1,93 +1,92 @@
function nand3(id){
function nand3(id) {
this.id = id;
this.rep = add(80,80,"blue","black",this.id,false);
this.rep = add(80, 80, "blue", "black", this.id, false);
this.pin1 = new pin(0);
this.pin2 = new pin(0);
this.pin3 = new pin(0);
this.o = new pin(1);
this.o.nei = this;
this.activation = function(){
if (!((this.pin1.val && this.pin2.val)&&this.pin3.val)){
this.activation = function() {
if (!((this.pin1.val && this.pin2.val) && this.pin3.val)) {
return true;
}
return false;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
//design
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
let skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
x: "50",
y: "50",
id: (id+"-skin"),
width:"80",
height:"80"
id: (id + "-skin"),
width: "80",
height: "80"
});
var img = $(document.createElement('img')).attr({
height:"72",
width:"72",
src:"textures/gates/nand_gate.jpg"
let img = $(document.createElement('img')).attr({
height: "72",
width: "72",
src: "textures/gates/nand_gate.jpg"
});
var iDiv = document.createElement("div");
let iDiv = document.createElement("div");
$(iDiv).append(img);
this.skin = skin;
this.img = img;
$(skin).append(iDiv);
//noname(this);
$(g).append(skin);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//updating
this.update = function(){
this.update = function() {
//the main object and his pins
let x = this.x();
let y = this.y();
this.pin1.set(x-20,y);
this.pin2.set(x-20,y+60);
this.pin3.set(x-20,y+30);
this.o.set(x+80,y+30);
this.pin1.set(x - 20, y);
this.pin2.set(x - 20, y + 60);
this.pin3.set(x - 20, y + 30);
this.o.set(x + 80, y + 30);
//and the skin
var name = "#"+this.id+"-skin";
var skin = $(name);
skin.attr("x",(parseFloat($((this.rep)).attr("x"))+4).toString());
skin.attr("y",(parseFloat($((this.rep)).attr("y"))+4).toString());
let name = "#" + this.id + "-skin";
let skin = $(name);
skin.attr("x", (parseFloat($((this.rep)).attr("x")) + 4).toString());
skin.attr("y", (parseFloat($((this.rep)).attr("y")) + 4).toString());
}
pieces[pieces.length] = this;
clk(this,[this.pin1,this.pin2,this.pin3,this.o]);
clk(this, [this.pin1, this.pin2, this.pin3, this.o]);
}
function clk(ob,arr){
var rep = ob.rep;
$((ob.img)).on("mousedown touchstart",function(e){
function clk(ob, arr) {
$((ob.img)).on("mousedown touchstart", function(e) {
e.preventDefault();
var svg = document.getElementById("svg1");
let svg = document.getElementById("svg1");
$(svg).append(ob.rep);
$(svg).append($(ob.pin1.rep));
for (var i = 0; i < arr.length;i++){
for (let i = 0; i < arr.length; i++) {
$(svg).append($(i.rep));
}
$(svg).append($(ob.skin));
selected = ob.id;
});
$((ob.img)).on("mouseup touchend",function(e){
$((ob.img)).on("mouseup touchend", function() {
selected = "yay";
});
}

View file

@ -1,94 +1,87 @@
function not(id){
function not(id) {
this.id = id;
this.name = "#" + this.id;
this.rep = add(80,80,"green","black",this.id,true);
this.rep = add(80, 80, "green", "black", this.id, true);
this.pin1 = new pin(0);
this.o = new pin(1);
this.o.nei = this;
//this.text = new text(this,"Or-gate");
this.activation = function(){
if (!this.pin1.val){
this.activation = function() {
if (!this.pin1.val) {
return true;
}
return false;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
//design
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
let skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
x: "50",
y: "50",
id: (id+"-skin"),
width:"80",
height:"80"
id: (id + "-skin"),
width: "80",
height: "80"
});
var img = $(document.createElement('img')).attr({
height:"80",
width:"80",
src:"textures/gates/not_gate.jpg"
let img = $(document.createElement('img')).attr({
height: "80",
width: "80",
src: "textures/gates/not_gate.jpg"
});
var iDiv = document.createElement("div");
let iDiv = document.createElement("div");
$(iDiv).append(img);
this.skin = skin;
this.img = img;
$(skin).append(iDiv);
//noname(this);
$(g).append(skin);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//updating
this.update = function(){
this.update = function() {
//the main object and his pins
let x = this.x();
let y = this.y();
this.pin1.set(x-20,y+30);
this.o.set(x+80,y+30);
this.pin1.set(x - 20, y + 30);
this.o.set(x + 80, y + 30);
//and the skin
var name = "#"+this.id+"-skin";
var skin = $(name);
skin.attr("x",(parseFloat($((this.rep)).attr("x"))+4).toString());
skin.attr("y",(parseFloat($((this.rep)).attr("y"))+4).toString());
let name = "#" + this.id + "-skin";
let skin = $(name);
skin.attr("x", (parseFloat($((this.rep)).attr("x")) + 4).toString());
skin.attr("y", (parseFloat($((this.rep)).attr("y")) + 4).toString());
}
pieces[pieces.length] = this;
addclk11(this);
}
function addclk11(ob){
var rep = ob.rep;
$((ob.img)).on("mousedown touchstart",function(e){
function addclk11(ob) {
$((ob.img)).on("mousedown touchstart", function(e) {
e.preventDefault();
var svg = document.getElementById("svg1");
let svg = document.getElementById("svg1");
$(svg).append(ob.rep);
$(svg).append($(ob.pin1.rep));
$(svg).append($(ob.o.rep));
$(svg).append($(ob.skin));
selected = ob.id;
});
$((ob.img)).on("mouseup touchend",function(e){
$((ob.img)).on("mouseup touchend", function() {
selected = "yay";
});
}

View file

@ -1,86 +1,74 @@
function or(id){
function or(id) {
this.id = id;
this.name = "#" + this.id;
this.rep = add(80,80,"green","black",this.id,true);
this.rep = add(80, 80, "green", "black", this.id, true);
this.pin1 = new pin(0);
this.pin2 = new pin(0);
this.o = new pin(1);
this.o.nei = this;
//this.text = new text(this,"Or-gate");
this.activation = function(){
if (this.pin1.val || this.pin2.val){
this.activation = function() {
if (this.pin1.val || this.pin2.val) {
return true;
}
return false;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
//design
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
let skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
x: "50",
y: "50",
id: (id+"-skin"),
width:"80",
height:"80"
id: (id + "-skin"),
width: "80",
height: "80"
});
var img = $(document.createElement('img')).attr({
height:"80",
width:"80",
src:"textures/gates/or_gate.jpg"
let img = $(document.createElement('img')).attr({
height: "80",
width: "80",
src: "textures/gates/or_gate.jpg"
});
var iDiv = document.createElement("div");
let iDiv = document.createElement("div");
$(iDiv).append(img);
this.skin = skin;
this.img = img;
$(skin).append(iDiv);
//noname(this);
$(g).append(skin);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//updating
this.update = function(){
this.update = function() {
//the main object and his pins
let x = this.x();
let y = this.y();
this.pin1.set(x-20,y);
this.pin2.set(x-20,y+60);
this.o.set(x+80,y+30);
this.pin1.set(x - 20, y);
this.pin2.set(x - 20, y + 60);
this.o.set(x + 80, y + 30);
//and the skin
var name = "#"+this.id+"-skin";
var skin = $(name);
skin.attr("x",(parseFloat($((this.rep)).attr("x"))+4).toString());
skin.attr("y",(parseFloat($((this.rep)).attr("y"))+4).toString());
let name = "#" + this.id + "-skin";
let skin = $(name);
skin.attr("x", (parseFloat($((this.rep)).attr("x")) + 4).toString());
skin.attr("y", (parseFloat($((this.rep)).attr("y")) + 4).toString());
}
pieces[pieces.length] = this;
addclk(this);
}
/*
function addclk(ob){
var rep = ob.rep;
$(ob.rep).on("mousedown touchstart",function(e){
var svg = document.getElementById("svg1");
$(svg).append(ob.rep);
$(svg).append($(ob.pin1.rep));
$(svg).append($(ob.pin2.rep));
$(svg).append($(ob.o.rep));
});
}
*/

View file

@ -1,67 +1,64 @@
var count = 0;
var pins = [];
var sels = "yay";
var sele = "yay";
var num;
function pin(type){
let count = 0;
let pins = [];
let sels = "yay";
let sele = "yay";
let num;
function pin(type) {
this.state = true;
this.nei = "yay";
this.val = false;
if (type == 0){
if (type == 0) {
this.type = true;
color = "black";
}
else{
} else {
this.type = false;
color = "red";
}
this.update = function(){
if (this.nei != "yay"){
if (!(this.type)){
this.update = function() {
if (this.nei != "yay") {
if (!(this.type)) {
this.val = this.nei.activation();
}
else{
} else {
this.val = this.nei.val;
}
}
if (this.val){
$((this.rep)).attr("fill","red");
}
else{
$((this.rep)).attr("fill","yellow");
if (this.val) {
$((this.rep)).attr("fill", "red");
} else {
$((this.rep)).attr("fill", "yellow");
}
}
this.id = count.toString();
this.name = "#"+this.id;
this.rep = add(20,20,"yellow","black",this.id,false);
this.name = "#" + this.id;
this.rep = add(20, 20, "yellow", "black", this.id, false);
clicked(this);
count++;
this.name = "#"+this.id;
this.set = function(x,y){
$(this.name).attr("x",x.toString());
$(this.name).attr("y",y.toString());
this.name = "#" + this.id;
this.set = function(x, y) {
$(this.name).attr("x", x.toString());
$(this.name).attr("y", y.toString());
}
pins[pins.length] = this;
this.num = pins.length-1;
this.num = pins.length - 1;
}
function clicked(ob){
$(ob.rep).on("click touchstart",function(e){
function clicked(ob) {
$(ob.rep).on("click touchstart", function(e) {
e.preventDefault();
if (ob.type == true){
if (ob.type == true) {
sels = ob;
}
else{
} else {
sele = ob;
}
console.log("click"+sels+sele+ob.type);
if ((sels!="yay")&&(sele!="yay")){
console.log("click" + sels + sele + ob.type);
if ((sels != "yay") && (sele != "yay")) {
console.log("step 2");
if ((sels.state)){
if ((sels.state)) {
sels.nei = sele;
sels.state = false;
sele.state = false;
a = new edge(sels,sele);
a = new edge(sels, sele);
sels = "yay";
sele = "yay";
console.log("end");

View file

@ -1,39 +1,40 @@
var t_count = 0;
function text(parent,value){
//variables
let t_count = 0;
function text(parent, value) {
//letiables
this.parent = parent;
this.val = value;
this.id = t_count.toString() + "text";
t_count++;
this.name = "#"+this.id;
this.name = "#" + this.id;
//adding the text to the SVG
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var el = $(document.createElementNS('http://www.w3.org/2000/svg', 'text')).attr({
let el = $(document.createElementNS('http://www.w3.org/2000/svg', 'text')).attr({
x: "50",
y:"50",
y: "50",
id: this.id,
fill:"white",
fill: "white",
stroke: "black"
});
$(el).text(value);
$(el).attr("class","heavy");
$(el).attr("class", "heavy");
$(g).append(el);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
this.rep = el;
$((this.rep)).on("click touchstart",function(e){
$((this.rep)).on("click touchstart", function(e) {
e.preventDefault();
});
//updating
this.update = function(){
$((this.name)).attr("x",(parseFloat($((this.parent)).attr("x"))+15).toString());
$((this.name)).attr("y",(parseFloat($((this.parent)).attr("y"))+25).toString());
this.update = function() {
$((this.name)).attr("x", (parseFloat($((this.parent)).attr("x")) + 15).toString());
$((this.name)).attr("y", (parseFloat($((this.parent)).attr("y")) + 25).toString());
}
//beeing sure it would be updated

View file

@ -1,73 +1,73 @@
function xor(id){
function xor(id) {
this.id = id;
this.name = "#" + this.id;
this.rep = add(80,80,"green","black",this.id,true);
this.rep = add(80, 80, "green", "black", this.id, true);
this.pin1 = new pin(0);
this.pin2 = new pin(0);
this.o = new pin(1);
this.o.nei = this;
//this.text = new text(this,"Or-gate");
this.activation = function(){
if (!(this.pin1.val && this.pin2.val) && (this.pin1.val || this.pin2.val)){
this.activation = function() {
if (!(this.pin1.val && this.pin2.val) && (this.pin1.val || this.pin2.val)) {
return true;
}
return false;
}
this.x = function(){
this.x = function() {
let name = "#" + this.id;
return parseFloat($(name).attr("x"));
}
this.y = function(){
this.y = function() {
let name = "#" + this.id;
//console.log("y"+parseFloat($(name).attr("y")));
return parseFloat($(name).attr("y"));
}
//design
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
$(g).attr({
width: "100%",
height: "100%"
});
var skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
let skin = $(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')).attr({
x: "50",
y: "50",
id: (id+"-skin"),
width:"80",
height:"80"
id: (id + "-skin"),
width: "80",
height: "80"
});
var img = $(document.createElement('img')).attr({
height:"80",
width:"80",
src:"textures/gates/xor.jpg"
let img = $(document.createElement('img')).attr({
height: "80",
width: "80",
src: "textures/gates/xor.jpg"
});
var iDiv = document.createElement("div");
let iDiv = document.createElement("div");
$(iDiv).append(img);
this.skin = skin;
this.img = img;
$(skin).append(iDiv);
//noname(this);
$(g).append(skin);
var elem = document.getElementById("svg1");
let elem = document.getElementById("svg1");
elem.appendChild(g);
//updating
this.update = function(){
this.update = function() {
//the main object and his pins
let x = this.x();
let y = this.y();
this.pin1.set(x-20,y);
this.pin2.set(x-20,y+60);
this.o.set(x+80,y+30);
this.pin1.set(x - 20, y);
this.pin2.set(x - 20, y + 60);
this.o.set(x + 80, y + 30);
//and the skin
var name = "#"+this.id+"-skin";
var skin = $(name);
skin.attr("x",(parseFloat($((this.rep)).attr("x"))+4).toString());
skin.attr("y",(parseFloat($((this.rep)).attr("y"))+4).toString());
let name = "#" + this.id + "-skin";
let skin = $(name);
skin.attr("x", (parseFloat($((this.rep)).attr("x")) + 4).toString());
skin.attr("y", (parseFloat($((this.rep)).attr("y")) + 4).toString());
}
pieces[pieces.length] = this;
clk(this,[this.pin1,this.pin2,this.output]);
clk(this, [this.pin1, this.pin2, this.output]);
}

12
st.css
View file

@ -1,14 +1,16 @@
body {
background-color:rgba(0,0,0,0.7);
background-color: rgba(0, 0, 0, 0.7);
/*
background-image: url("bg.jpg");
background-repeat: no-repeat;
background-size: cover;
*/
margin:0;
margin: 0;
}
.heavy { font: bold 20px sans-serif; }
.heavy {
font: bold 20px sans-serif;
}
img {
border-radius: 17px;
@ -17,6 +19,6 @@ img {
}
#butt {
rx: 10;
ry: 10;
rx: 5;
ry: 5;
}