forked from tsayen/dom-to-image
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
165 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
bower_components | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,74 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head lang="en"> | ||
<meta charset="UTF-8"> | ||
<style> | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
#root { | ||
height: 100px; | ||
width: 100px; | ||
} | ||
|
||
#dom-content { | ||
border: 1px solid black; | ||
height: 100%; | ||
} | ||
|
||
.red { | ||
background-color: red; | ||
} | ||
|
||
.green { | ||
background-color: lightgreen; | ||
} | ||
|
||
.blue { | ||
background-color: lightblue; | ||
} | ||
|
||
.red, .green, .blue { | ||
height: 33.333333%; | ||
width: 100%; | ||
} | ||
|
||
.image { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
#root { | ||
height: 100px; | ||
width: 100px; | ||
} | ||
|
||
#dom-content { | ||
border: 1px solid black; | ||
height: 100%; | ||
} | ||
|
||
.red { | ||
background-color: red; | ||
} | ||
|
||
.green { | ||
background-color: green; | ||
} | ||
|
||
.blue { | ||
background-color: blue; | ||
} | ||
|
||
.red, | ||
.green, | ||
.blue { | ||
height: 33.333333%; | ||
width: 100%; | ||
border: 1px solid lightgrey; | ||
border-radius: 6px; | ||
} | ||
|
||
.image { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
</style> | ||
<script src="../../src/domvas.js"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
exportToImage = function () { | ||
<script> | ||
exportToImage = function() { | ||
var canvas = document.getElementById('canvas'); | ||
var context = canvas.getContext('2d'); | ||
|
||
domvas.toImage(document.getElementById('root'), function (image) { | ||
domvas.toImage(document.getElementById('root'), function(image) { | ||
context.drawImage(image, 0, 0); | ||
}); | ||
}; | ||
</script> | ||
<div id="root"> | ||
<div id="dom-content"> | ||
<div class="red">red</div> | ||
<div class="green">green</div> | ||
<div class="blue">blue</div> | ||
</script> | ||
<div id="root"> | ||
<div id="dom-content"> | ||
<div class="red"></div> | ||
<div class="green"></div> | ||
<div class="blue"></div> | ||
</div> | ||
</div> | ||
<button onclick="exportToImage()">draw</button> | ||
<div class="image"> | ||
<canvas id="canvas" width="100" height="100"></canvas> | ||
</div> | ||
</div> | ||
<button onclick="exportToImage()">draw</button> | ||
<div class="image"> | ||
<canvas id="canvas" width="100" height="100"></canvas> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
describe('domvas', function () { | ||
'use strict'; | ||
|
||
var assert = chai.assert; | ||
|
||
it('should load', function () { | ||
assert.ok(domvas); | ||
}); | ||
|
||
it('should render simple css correctly', function (done) { | ||
loadHtml('regression-simple.html').then(function (html) { | ||
document.write(html); | ||
var dom_node = $('#dom-node')[0]; | ||
console.log('hey! ' + dom_node); | ||
done(); | ||
}); | ||
}); | ||
|
||
function loadHtml(path) { | ||
return new Promise(function (resolve) { | ||
var request = new XMLHttpRequest(); | ||
console.log('request ' + request); | ||
request.open('GET', '/base/spec/resources/' + path, true); | ||
request.responseType = 'text/html'; | ||
request.onload = function () { | ||
if (this.status == 200) resolve(request.response.toString()); | ||
}; | ||
request.send(); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head lang="en"> | ||
<meta charset="UTF-8"> | ||
<style> | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
#dom-node { | ||
border: 1px solid black; | ||
height: 100px; | ||
width: 100px; | ||
} | ||
|
||
.red { | ||
background-color: red; | ||
} | ||
|
||
.green { | ||
background-color: green; | ||
} | ||
|
||
.blue { | ||
background-color: blue; | ||
} | ||
|
||
.red, | ||
.green, | ||
.blue { | ||
height: 33.333333%; | ||
width: 100%; | ||
border: 1px solid lightgrey; | ||
border-radius: 6px; | ||
} | ||
|
||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="dom-node"> | ||
<div class="red"></div> | ||
<div class="green"></div> | ||
<div class="blue"></div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.