Bläddra i källkod

Small optimizations

master
Pete Shadbolt 8 år sedan
förälder
incheckning
477f62d377
10 ändrade filer med 278 tillägg och 7 borttagningar
  1. Binär
      static/img/ball.png
  2. +91
    -0
      static/img/ball.svg
  3. +3
    -0
      static/img/make_figs.sh
  4. Binär
      static/img/tip.png
  5. +91
    -0
      static/img/tip.svg
  6. +12
    -5
      static/index.html
  7. +15
    -2
      static/main.css
  8. +61
    -0
      static/scripts/editor.js
  9. +4
    -0
      static/scripts/materials.js
  10. +1
    -0
      static/scripts/mouse.js

Binär
static/img/ball.png Visa fil

Before After
Width: 64  |  Height: 64  |  Size: 3.6KB Width: 64  |  Height: 64  |  Size: 2.8KB

+ 91
- 0
static/img/ball.svg Visa fil

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="New document 1">
<defs
id="defs4">
<linearGradient
id="linearGradient3763">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3765" />
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="1"
id="stop3767" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3763"
id="radialGradient3771"
cx="38.780914"
cy="23.33404"
fx="38.780914"
fy="23.33404"
r="32.661938"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.1215552,0.13870084,-0.14202472,1.1484324,1.1779947,-9.189628)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="-12.465613"
inkscape:cy="8.3918647"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-page="false"
inkscape:window-width="1366"
inkscape:window-height="721"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-988.36218)">
<path
sodipodi:type="arc"
style="fill:url(#radialGradient3771);fill-opacity:1;stroke:#000000;stroke-width:1.32387710000000003;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="path2993"
sodipodi:cx="32"
sodipodi:cy="32"
sodipodi:rx="32"
sodipodi:ry="32"
d="M 64,32 A 32,32 0 1 1 0,32 32,32 0 1 1 64,32 z"
transform="matrix(0.94419643,0,0,0.94419643,1.7857143,990.14789)" />
</g>
</svg>

+ 3
- 0
static/img/make_figs.sh Visa fil

@@ -0,0 +1,3 @@
#!/bin/bash
inkscape -z -e ball.png -w 64 -h 64 ball.svg
inkscape -z -e tip.png -w 64 -h 64 tip.svg

Binär
static/img/tip.png Visa fil

Before After
Width: 64  |  Height: 64  |  Size: 1.0KB

+ 91
- 0
static/img/tip.svg Visa fil

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="tip.svg">
<defs
id="defs4">
<linearGradient
id="linearGradient3763">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3765" />
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="1"
id="stop3767" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="5.4453989"
inkscape:cy="4.9448826"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-page="true"
inkscape:window-width="1366"
inkscape:window-height="721"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:snap-center="true"
inkscape:object-nodes="true" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-988.36218)">
<path
sodipodi:type="arc"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.32387710000000003;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;opacity:0.29302326"
id="path2993"
sodipodi:cx="32"
sodipodi:cy="32"
sodipodi:rx="32"
sodipodi:ry="32"
d="M 64,32 A 32,32 0 1 1 0,32 32,32 0 1 1 64,32 z"
transform="matrix(0.94419643,0,0,0.94419643,1.7857143,990.14789)" />
<path
style="color:#000000;fill:none;stroke:#000000;stroke-width:9.65;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 32,996.21932 0,48.28568"
id="path3811"
inkscape:connector-curvature="0" />
<path
style="color:#000000;fill:none;stroke:#000000;stroke-width:9.65;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 7.8571427,1020.3622 48.2857143,0"
id="path3813"
inkscape:connector-curvature="0" />
</g>
</svg>

+ 12
- 5
static/index.html Visa fil

@@ -26,12 +26,19 @@
<div id=server_info class=hidden> </div>

<div id=pallette>
<h3>Node (5,2)</h3>
<ul>
<li>add_qubit</li>
<li>delete_qubit</li>
<li>hadamard</li>
<li>cz</li>
<li>clear</li>
<li>VOP: Hadamard</li>
<li>x: 0 | y: 5 | z: 10</li>
<li><a href="#">Measure in X</a></li>
<li><a href="#">Measure in Y</a></li>
<li><a href="#">Measure in Z</a></li>
<li><a href="#">Act Hadamard</a></li>
<li>
<a href="#">IA</a>
<a href="#">IB</a>
</li>
<li><a href="#">Delete</a></li>
</ul>
</div>



+ 15
- 2
static/main.css Visa fil

@@ -21,7 +21,7 @@ html, body { margin: 0; padding: 0; overflow: hidden; font-size: 10pt; font-fam
padding: 10px;
font-family:"courier new";
position: absolute;
bottom: 10px;
top: 10px;
right: 10px;
font-size: 9pt;
}
@@ -34,7 +34,7 @@ html, body { margin: 0; padding: 0; overflow: hidden; font-size: 10pt; font-fam
font-family:"courier new";
position: absolute;
top: 10px;
right: 10px;
left: 10px;
font-size: 9pt;
}

@@ -45,6 +45,12 @@ ul {
margin: 0px;
}

li{
padding:3px;
}



.visible {
visibility: visible;
opacity: 1;
@@ -62,3 +68,10 @@ ul {
a {
color: yellow;
}

h3 {
padding-top: 0px;
padding-bottom: 0px;
margin-top: 2px;
margin-bottom: 2px;
}

+ 61
- 0
static/scripts/editor.js Visa fil

@@ -0,0 +1,61 @@
var editor = {};
editor.nearest = undefined;

editor.onFreeMove = function() {
var n = editor.nearestNode(mouse.ray);
if (editor.nearest !== n) {
editor.nearest = n;
if (n) {
gui.nodeMessage("Node " + n + " (VOP:" + abj.vops[n] + ")" +
"<br/>" + "Click to edit neighbourhood");
} else {
gui.hideNodeMessage();
}
}
};

editor.onClick = function() {
var n = editor.nearestNode(mouse.ray);
if (n) {
var p = abj.meta[n].position;
editor.gimbal.position.set(p.x, p.y, p.z);
gui.controls.target.set(p.x, p.y, p.z);
gui.hideNodeMessage();
editor.nearest = undefined;
gui.render();
}
};

editor.prepare = function() {
mouse.onFreeMove = editor.onFreeMove;
mouse.onClick = editor.onClick;
editor.makeGimbal();
};

// Gets a reference to the node nearest to the mouse cursor
editor.nearestNode = function(ray) {
for (var i in abj.meta) {
if (ray.distanceSqToPoint(abj.meta[i].position) < 0.03) {
return i;
}
}
return undefined;
};

editor.makeGimbal = function(center) {
editor.gimbal = new THREE.Object3D();

var pointGeometry = new THREE.Geometry();
pointGeometry.vertices = [
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(0, 1, 0),
new THREE.Vector3(0, 0, 1),
new THREE.Vector3(-1, 0, 0),
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(0, 0, -1)
];
var tips = new THREE.Points(pointGeometry, materials.tip);

editor.gimbal.add(tips);
gui.scene.add(editor.gimbal);
};

+ 4
- 0
static/scripts/materials.js Visa fil

@@ -15,6 +15,10 @@ materials.prepare = function() {
transparent: false,
linewidth: 1
});
materials.gimbalEdge = new THREE.LineBasicMaterial({
color: "black",
linewidth: 1,
});
materials.tip = new THREE.PointsMaterial({
size: 0.4,
map: tipSprite,


+ 1
- 0
static/scripts/mouse.js Visa fil

@@ -47,6 +47,7 @@ mouse.onUp = function(event) {
};

mouse.onMove = function(event) {
// TODO: wasclick sux
mouse.wasClick = false;
mouse.position_absolute = {
x: event.clientX,


Laddar…
Avbryt
Spara