<html>
<head>
<meta name="description" content="Viewdir SVG-Draw: Draw SVG shapes and layers on stuff.">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Viewdir SVG-Draw Demo</title>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://rawgit.com/viewdir/svg-draw-component/master/dist/svg-draw-component.css" />
<script src="https://rawgit.com/viewdir/svg-draw-component/master/dist/svg-draw-component.bundle.js"></script>
</head>
<body class="svg-draw-component">
<div id="svgdraw"></div>
<img id="subject" style="display:none;" src="https://viewdir.github.io/svg-draw-component/examples/img/floorplan.png"/>
<button id="loadSVG">loadSVG</button>
<div class="event-set" style="margin-top:50px;"/>
<script type="text/javascript">
var svgdraw;
$(function() {
svgdraw = new IIIFComponents.SvgDrawComponent({
element: "#svgdraw",
subjectType: "image",
subject: "subject",
toolbars: {
tools: {
show: true,
buttons: [
{ name: 'point', fa_icon:'fa-map-pin'},
{ name: 'line', fa_icon:'fa-pencil'},
{ name: 'cloud', fa_icon:'fa-cloud'},
{ name: 'rect', fa_icon:'fa-stop'},
{ name: 'separator'},
{ name: 'select', fa_icon:'fa-arrows'}
]
},
layers: {
show: true,
presets: [{
name: 'Walkable Areas',
visible: true,
locked: false,
active: false
// load svg?
// export svg?
// trash button?
},
{
name: 'Points of Interest',
visible: true,
locked: false,
active: true
}
]
},
}
});
function displayEvents(eventName, args){
$( ".event-set" ).empty();
var events = $( '<div class="events"/>' );
events.append("<h2>" + eventName + "</h2>");
var pre = $( "<pre/>" );
pre.text(JSON.stringify(args, undefined, 2));
events.append(pre);
$( ".event-set" ).append(events);
$( ".events" ).addClass( "events-flash" );
};
svgdraw.on('shapeCompleted', function(args) {
displayEvents('shapeCompleted',args);
});
svgdraw.on('shapeUpdated', function(args) {
displayEvents('shapeUpdated',args);
});
svgdraw.on('shapeDeleted', function(args) {
displayEvents('shapeDeleted',args);
});
svgdraw.on('svgLoaded', function(args) {
displayEvents('svgLoaded',args);
});
function loadSVG(){
svgdraw.importSVG('<svg xmlns="http://www.w3.org/2000/svg"><rect x="506" y="284" width="71" height="103" fill="#ffffff" fill-rule="nonzero" stroke="#ff0000" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" opacity="0.5" style="mix-blend-mode: normal"></rect></svg>');
return false;
}
$( "#loadSVG" ).on( "click", loadSVG );
});
</script>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |