Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chemlambda committed Nov 9, 2022
1 parent 27f4419 commit b89aee3
Show file tree
Hide file tree
Showing 12 changed files with 19,596 additions and 0 deletions.
Binary file added chemlambda-gui/cc-by-4-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions chemlambda-gui/d3.min.js

Large diffs are not rendered by default.

234 changes: 234 additions & 0 deletions chemlambda-gui/firstpart_q.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
<!DOCTYPE html>
<html>
<head>
<title>Chemlambda movies productions presents:</title>
<!-- <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> -->

<script src="d3.min.js" charset="utf-8"></script>
<script src="jquery.min.js"></script>
<style>


.link line {
stroke: #696969;
}

.link line.separator {
stroke: #95A5A6;
stroke-width: 2px;
}

.node circle {
stroke: #95A5A6;
stroke-width: 1.5px;
}

.node text {
font: 10px sans-serif;
pointer-events: none;
}



</style>
</head>
<body style="background-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"
alink="#ee0000" link="#000250" vlink="#551a8b">

<!-- <button onclick="addNodes()">Start!</button> -->




<script>
var graph;
function myGraph() {

// Add and remove elements on the graph object
this.addNode = function (id, atom, size, colour) {
nodes.push({"id": id, "atom": atom, "size": size, "colour": colour});
update();
};

this.removeNode = function (id) {
var i = 0;
var n = findNode(id);
while (i < links.length) {
if ((links[i]['source'] == n) || (links[i]['target'] == n)) {
links.splice(i, 1);
}
else i++;
}
nodes.splice(findNodeIndex(id), 1);
update();
};

this.removeLink = function (source, target) {
for (var i = 0; i < links.length; i++) {
if (links[i].source.id == source && links[i].target.id == target) {
links.splice(i, 1);
break;
}
}
update();
};

this.removeallLinks = function () {
links.splice(0, links.length);
update();
};

this.removeAllNodes = function () {
nodes.splice(0, links.length);
update();
};

this.addLink = function (source, target, bond) {
links.push({"source": findNode(source), "target": findNode(target), "bond": bond});
update();
};

var findNode = function (id) {
for (var i in nodes) {
if (nodes[i]["id"] === id) return nodes[i];
}
;
};

var findNodeIndex = function (id) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].id == id) {
return i;
}
}
;
};

// set up the D3 visualisation in the specified element
var w = 500,
h = 500;

// var radius = d3.scale.sqrt()
// .range([0, 4]);

var vis = d3.select("body")
.append("svg:svg")
.attr("width", w)
.attr("height", h)
.attr("id", "svg")
.attr("pointer-events", "all")
.attr("viewBox", "0 0 " + w + " " + h)
.attr("perserveAspectRatio", "xMinYMid")
.append('svg:g');

var force = d3.layout.force();

var nodes = force.nodes(),
links = force.links();



var update = function () {
var link = vis.selectAll("line")
.data(links, function (d) {
return d.source.id + "-" + d.target.id;
});

link.enter().append("line")
.style("stroke-opacity",0.4).style("fill-opacity",0.4)
.attr("id", function (d) {
return d.source.id + "-" + d.target.id;
})
.attr("stroke-width", function (d) {
return (d.bond * 2 - 1) * 2 + "px";
})
.attr("stroke", "#FFFFFF");
// #ADD8E6
link.filter(function(d) { return d.bond > 1; }).append("line")
// .attr("class", "separator");
.attr("class", "link");
// link.append("title")
// .text(function (d) {
// return d.value;
// });
link.exit().remove();


var node = vis.selectAll("g.node")
.data(nodes, function (d) {
return d.id;
});

var nodeEnter = node.enter().append("g")
.attr("class", "node")
.call(force.drag);

nodeEnter.append("svg:circle")
.style("stroke-opacity",0.4).style("fill-opacity",0.8)
.attr("r", function(d) { return d.size*2;})
.attr("id", function (d) {
return "Node;" + d.id;
})
.attr("class", "nodeStrokeClass")
.attr("fill", function(d) { return d.colour; })
// .transition()
// .delay(700000)
// .attr("r", 2);

// node.append("text")
// .attr("dy", ".35em")
// .attr("dx", function(d) { return (0 - ((12/4) * (d.size + 0.5 )* (d.size + 0.5)) );})
// // .attr("text-anchor", "middle")
// .text(function(d) { return d.atom; });

node.on("dblclick", function(d) { d.fixed = false; });

node.on("mousedown", function(d) { d.fixed = true; });

node.exit().remove();

force.on("tick", function () {

node.attr("transform", function (d) {
return "translate(" + d.x + "," + d.y + ")";
});

link.attr("x1", function (d) {
return d.source.x;
})
.attr("y1", function (d) {
return d.source.y;
})
.attr("x2", function (d) {
return d.target.x;
})
.attr("y2", function (d) {
return d.target.y;
});
});

// Restart the force layout.

force
// .friction(.01)
.charge(-20)
.gravity(.38)
.linkStrength(8.8)
.linkDistance( function(d) { return ((d.source.size + d.target.size + 3)/(40*d.bond)); } )
.size([w, h])
.start();
};


// Make it all go
update();
}



function drawGraph() {

graph = new myGraph("#svgdiv");


41 changes: 41 additions & 0 deletions chemlambda-gui/getmoves.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh


printf "choose a file from the list: \n"

ls *.html

printf "> "

read firstarg

filename=${firstarg%%.*}



awk '{ sub(/^[ \t]+/, ""); print }' $firstarg > lista.txh

awk '/^graph\./{print}' lista.txh > lista2.txh

rm lista.txh

awk '{ sub(/\(/,","); print }' lista2.txh > lista3.txh

rm lista2.txh

awk '{ sub(/\);/,""); print }' lista3.txh > lista4.txh

rm lista3.txh

awk '{ sub(/graph\./,""); print }' lista4.txh > lista5.txh

rm lista4.txh

awk -f modifier.awk lista5.txh

rm lista5.txh

mv essy.txt universal.js



4 changes: 4 additions & 0 deletions chemlambda-gui/jquery.min.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions chemlambda-gui/lastpart.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

}

drawGraph();
// because of the way the network is created, nodes are created first, and links second,
// so the lines were on top of the nodes, this just reorders the DOM to put the svg:g on top
function keepNodesOnTop() {
$(".nodeStrokeClass").each(function( index ) {
var gnode = this.parentNode;
gnode.parentNode.appendChild(gnode);
});
}
function addNodes() {
d3.select("svg")
.remove();
drawGraph();
}


</script>
</body>
</html>
82 changes: 82 additions & 0 deletions chemlambda-gui/modifier.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
BEGIN {

FS =",";
printf("function commands\(\) \{ var commandsArray = \[") > "essy.txt" ;
# this variant 07.09.2019


#
# used for turning the addNode, etc, commands from a simulation into a js function (array)
# I started from removing spaces at the beginning
# awk '{ sub(/^[ \t]+/, ""); print }' bigpred.html > lista.txt
# awk '/^graph\./{print}' lista.txt > lista2.txt
# awk '{ sub(/\(/,","); print }' lista2.txt > lista3.txt
# awk '{ sub(/\);/,""); print }' lista3.txt > lista4.txt
# awk '{ sub(/graph\./,""); print }' lista4.txt > lista5.txt
# awk -f modifier.awk lista5.txt
# mv essy.txt whatever.js
#


#
#
#
#

}


{


#

if ($1 == "removeLink") {

a="\{c:\"" "rl" "\", a:\{s:" $2 ", t:" $3 "\}\}, \n";


}

if ($1 == "addLink") {

a="\{c:\"" "al" "\", a:\{s:" $2 ", t:" $3 ", b:" $4 "\}\}, \n";

}

if ($1 == "removeNode") {

a="\{c:\"" "rn" "\", a:\{i:" $2 "\}\}, \n";

}

if ($1 == "addNode") {

a="\{c:\"" "an" "\", a:\{i:" $2 ", a:" $3 ", si:" $4 ", co:" $5 "\}\}, \n";

}

b=a "";
printf(b) >> "essy.txt";





}

END {

printf("\{c:\"\" , a:\{i:\"\", a:\"\", si:0, co:\"\" \}\}\]; \n return commandsArray; \n \}") >> "essy.txt";


}









Loading

0 comments on commit b89aee3

Please sign in to comment.