Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion built/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function drawModule(g, module) {
cx: j.x,
cy: j.y,
r: 2,
style: 'fill:#000',
style: 'fill:var(--vscode-foreground)',
}];
});
bends = bends.concat(circles);
Expand Down
2 changes: 1 addition & 1 deletion built/drawModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function drawModule(g, module) {
cx: j.x,
cy: j.y,
r: (numWires > 1 ? 3 : 2),
style: 'fill:#000',
style: 'fill:var(--vscode-foreground)',
class: netName,
}];
});
Expand Down
28 changes: 28 additions & 0 deletions lib/Cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ export default class Cell {
return null;
}

// Gets source attribute from cell attributes
public getSourceAttribute(): string {
if (this.attributes && this.attributes.src) {
return this.attributes.src;
}
return null;
}

public getTemplate(): any {
return Skin.findSkinType(this.type);
}
Expand Down Expand Up @@ -282,6 +290,26 @@ export default class Cell {
}
tempclone[1].id = 'cell_' + this.key;
tempclone[1].transform = 'translate(' + cell.x + ',' + cell.y + ')';

// Add source attribution if available
const src = this.getSourceAttribute();
if (src) {
tempclone[1].onclick = `gotosrc('${src}')`;
tempclone[1].style = 'cursor: pointer; position: relative;';
// Add hit area matching the gate's rectangle
const hitArea = ['rect', {
x: 0,
y: 0,
width: Number(template[1]['s:width']),
height: Number(template[1]['s:height']),
fill: 'transparent',
'pointer-events': 'all',
stroke: 'none',
style: 'cursor: pointer;'
}];
tempclone.splice(2, 0, hitArea);
}

if (this.type === '$_split_') {
setGenericSize(tempclone, Number(this.getGenericHeight()));
const outPorts = Skin.getPortsWithPrefix(template, 'out');
Expand Down
14 changes: 7 additions & 7 deletions lib/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions lib/drawModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function drawModule(g: ElkModel.Graph, module: FlatModule) {
cx: j.x,
cy: j.y,
r: (numWires > 1 ? 3 : 2),
style: 'fill:#000',
style: 'fill:var(--vscode-foreground)',
class: netName,
}]);
bends = bends.concat(circles);
Expand Down Expand Up @@ -79,7 +79,7 @@ export default function drawModule(g: ElkModel.Graph, module: FlatModule) {
width: (e.labels[0].text.length + 2) * 6 - 2,
height: 9,
class: netName,
style: 'fill: white; stroke: none',
style: 'fill: var(--vscode-editor-background); stroke: none',
},
], ['text',
{
Expand Down Expand Up @@ -114,7 +114,7 @@ export default function drawModule(g: ElkModel.Graph, module: FlatModule) {
},
});
const elements: onml.Element[] = [styles, ...nodes, ...lines];
const ret: onml.Element = ['svg', svgAttrs, ...elements];
const ret: onml.Element = ['svg', svgAttrs, elements.map(e => onml.s(e)).join('')];
return onml.s(ret);
}

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "netlistsvg",
"version": "1.0.2",
"name": "@silimate/netlistsvg",
"version": "1.1.4",
Comment on lines +2 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you push a company name into a open source project?

"description": "rendering a schematic from a netlist",
"main": "built/index.js",
"author": "Neil Turley",
Expand Down Expand Up @@ -31,7 +31,7 @@
"lint": "tslint --project . && eslint bin/**/*.js && eslint --global=document demo/**/*.js",
"test": "npm run -s test-examples && npm run -s lint && jest",
"build-demo": "cp demo/index.html . && cp node_modules/elkjs/lib/elk.bundled.js . && browserify demo/demo.js > bundle.js",
"build-module": "browserify -t brfs -s netlistsvg jsmodule/index.js > built/netlistsvg.bundle.js"
"build-module": "tsc && browserify -t brfs -s netlistsvg jsmodule/index.js > built/netlistsvg.bundle.js"
},
"keywords": [
"svg",
Expand All @@ -42,17 +42,17 @@
},
"homepage": "https://github.com/nturley/netlistsvg#readme",
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/jest": "^27.0.0",
"@types/node": "^16.0.0",
"brfs": "^2.0.2",
"browserify": "^17.0.0",
"browserify-shim": "^3.8.14",
"eslint": "^7.30.0",
"jest": "^27.0.6",
"superagent": "^6.1.0",
"ts-jest": "^27.0.3",
"tslint": "^6.1.3",
"typescript": "^3.3.4000",
"brfs": "^2.0.2"
"typescript": "^4.5.0"
},
"browserify-shim": {
"elkjs": "global:ELK"
Expand Down