6 Commits

Author SHA1 Message Date
020f4f2cb0 Merge branch 'ed' into svg 2013-06-26 17:23:51 -04:00
f0add78ee5 Merge branch 'ed' into svg 2013-06-25 17:25:09 -04:00
471fcd6ddc Performance improvements 2012-02-03 22:18:43 -05:00
7ac0424f6c Only redraw if node state changes 2012-02-03 22:05:42 -05:00
050906f305 Use SVG DOM to highlight nodes 2012-02-03 21:42:34 -05:00
ae185ff06b Changed chip layout to use SVGs 2012-01-31 22:58:22 -05:00
5 changed files with 77 additions and 19 deletions

2
6502N.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

@ -72,7 +72,7 @@ More information in the <a href="http://visual6502.org/wiki/index.php?title=Jssi
</span>
<div class="frame" id="frame">
<div class="chip" id="chip">
<canvas class="chip" id="chipbg"></canvas>
<object data="6502N.svg" type="image/svg+xml" id="chipbg" style="position: absolute; width: 600px; height:600px;"></object>
<canvas class="chip" id="overlay"></canvas>
<canvas class="chip" id="hilite"></canvas>
<canvas class="chip" id="hitbuffer"></canvas>

View File

@ -50,6 +50,13 @@ canvas.chip {
height: 600px;
}
object.chipbg {
position: absolute;
width: 600px;
height: 600px;
}
div.buttons{
position: absolute;
top: -5px;
@ -91,4 +98,4 @@ table.memtable {
#title {
font-size:30px;
font-weight:bold;
}
}

View File

@ -144,12 +144,19 @@ function mouseUp(e){
}
function setZoom(n){
var svg = chipbg.getSVGDocument();
svg = svg.childNodes[0];
zoom = n;
setChipStyle({
width: 600*n+'px',
height: 600*n+'px'
});
svg.style.width = 600*n+'px';
svg.style.height = 600*n+'px';
recenter();
}
function recenter(){
@ -193,7 +200,7 @@ function handleClick(e){
function setChipStyle(props){
for(var i in props){
chipbg.style[i] = props[i];
overlay.style[i] = props[i];
// overlay.style[i] = props[i];
hilite.style[i] = props[i];
hitbuffer.style[i] = props[i];
}

View File

@ -22,6 +22,11 @@
var frame, chipbg, overlay, hilite, hitbuffer, ctx;
var nodes = new Array();
var lastState = new Array();
var polyAttr = new Array();
var metalAttr = new Array();
var polyOffFill;
var metalOffFill;
var transistors = {};
var nodenamelist=[];
@ -40,6 +45,7 @@ function setupNodes(){
state: false, gates: new Array(), c1c2s: new Array()};
if(w==ngnd) continue;
if(w==npwr) continue;
lastState[i] = 0;
nodes[w].segs.push(seg.slice(3));
}
}
@ -73,8 +79,20 @@ function setupLayerVisibility(){
function setupBackground(){
chipbg = document.getElementById('chipbg');
chipbg.width = grCanvasSize;
chipbg.height = grCanvasSize;
chipbg.width = 4000;
chipbg.height = 4000;
var svg = chipbg.getSVGDocument();
svg = svg.childNodes[0];
var poly = svg.getElementById('poly');
var metal = svg.getElementById('metal');
polyOffFill = poly.getAttribute('fill');
metalOffFill = metal.getAttribute('fill');
for(var i in nodes){
polyAttr[i] = poly.getElementsByClassName(i+'')[0];
metalAttr[i] = metal.getElementsByClassName(i+'')[0];
}
return;
var ctx = chipbg.getContext('2d');
ctx.fillStyle = '#000000';
ctx.strokeStyle = 'rgba(255,255,255,0.5)';
@ -93,10 +111,10 @@ function setupBackground(){
}
function setupOverlay(){
overlay = document.getElementById('overlay');
overlay.width = grCanvasSize;
overlay.height = grCanvasSize;
ctx = overlay.getContext('2d');
// overlay = document.getElementById('overlay');
// overlay.width = grCanvasSize;
// overlay.height = grCanvasSize;
// ctx = overlay.getContext('2d');
}
function setupHilite(){
@ -137,20 +155,44 @@ function hexdigit(n){return '0123456789ABCDEF'.charAt(n);}
function refresh(){
if(!chipLayoutIsVisible) return;
ctx.clearRect(0,0,grCanvasSize,grCanvasSize);
// ctx.clearRect(0,0,grCanvasSize,grCanvasSize);
// for(i in nodes){
// if(isNodeHigh(i)) overlayNode(nodes[i].segs);
// }
for(i in nodes){
if(isNodeHigh(i)) overlayNode(nodes[i].segs);
}
if(isNodeHigh(i)){
if(lastState[i]==1)continue;
var n = polyAttr[i];
var n2 = metalAttr[i];
if(n!=undefined)
n.setAttribute('fill', 'rgb(0,255,255)');
if(n2!=undefined)
n2.setAttribute('fill', 'rgb(0,255,255)');
lastState[i] = 1;
} else {
if(lastState[i]==0)continue;
var n = polyAttr[i];
var n2 = metalAttr[i];
if(n!=undefined)
n.setAttribute('fill', polyOffFill);
if(n2!=undefined)
n2.setAttribute('fill', metalOffFill);
lastState[i] = 0;
}
}
hiliteNode(hilited);
}
function overlayNode(w){
ctx.fillStyle = 'rgba(255,0,64,0.4)';
for(i in w) {
drawSeg(ctx, w[i]);
ctx.fill();
}
}
//function overlayNode(w){
// ctx.fillStyle = 'rgba(255,0,64,0.4)';
// for(i in w) {
// drawSeg(ctx, w[i]);
// ctx.fill();
// }
//}
// originally to highlight using a list of node numbers
// but can now include transistor names