mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Merge pull request #92 from bdkzero/master
Support for other renderers than Canvas and fixed image rendering in SVG renderer
This commit is contained in:
commit
f49e491fa2
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@
|
|||||||
image.jpg
|
image.jpg
|
||||||
/.project
|
/.project
|
||||||
/.settings/
|
/.settings/
|
||||||
|
.envrc
|
||||||
|
77
build.xml
77
build.xml
@ -22,10 +22,27 @@
|
|||||||
<file name="Queue.js"/>
|
<file name="Queue.js"/>
|
||||||
<file name="Renderer.js"/>
|
<file name="Renderer.js"/>
|
||||||
<file name="Util.js"/>
|
<file name="Util.js"/>
|
||||||
<file name="renderers/Canvas.js"/>
|
<file name="renderers/Canvas.js"/>
|
||||||
<file name="html2canvas-post.txt"/>
|
<file name="html2canvas-post.txt"/>
|
||||||
</filelist>
|
</filelist>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
|
<path id="sourcefiles-allrends">
|
||||||
|
<filelist dir="${src.dir}">
|
||||||
|
<file name="LICENSE"/>
|
||||||
|
<file name="html2canvas-pre.txt"/>
|
||||||
|
<file name="Core.js"/>
|
||||||
|
<file name="Generate.js"/>
|
||||||
|
<file name="Parse.js"/>
|
||||||
|
<file name="Preload.js"/>
|
||||||
|
<file name="Queue.js"/>
|
||||||
|
<file name="Renderer.js"/>
|
||||||
|
<file name="Util.js"/>
|
||||||
|
<file name="renderers/Canvas.js"/>
|
||||||
|
<file name="renderers/SVG.js"/>
|
||||||
|
<file name="html2canvas-post.txt"/>
|
||||||
|
</filelist>
|
||||||
|
</path>
|
||||||
|
|
||||||
<path id="jquery-plugin">
|
<path id="jquery-plugin">
|
||||||
<fileset dir="${src.dir}" includes="LICENSE"/>
|
<fileset dir="${src.dir}" includes="LICENSE"/>
|
||||||
@ -46,11 +63,21 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<pathconvert property="prettty-sourcefiles" pathsep="${line.separator}" refid="sourcefiles"></pathconvert>
|
<pathconvert property="prettty-sourcefiles" pathsep="${line.separator}" refid="sourcefiles"></pathconvert>
|
||||||
|
|
||||||
|
<pathconvert property="prettty-sourcefiles-allrends" pathsep="${line.separator}" refid="sourcefiles-allrends"></pathconvert>
|
||||||
|
|
||||||
<target name="build" depends="build-dir,plugins">
|
<target name="build" depends="build-dir,plugins">
|
||||||
<echo>Concatenating files:${line.separator}${prettty-sourcefiles}${line.separator}into ${build.dir}/${JS_NAME}...</echo>
|
<echo>Concatenating files:${line.separator}${prettty-sourcefiles}${line.separator}into ${build.dir}/${JS_NAME}...</echo>
|
||||||
<concat fixlastline="yes" destfile="${build.dir}/${JS_NAME}">
|
<concat fixlastline="yes" destfile="${build.dir}/${JS_NAME}">
|
||||||
<path refid="sourcefiles"/>
|
<path refid="sourcefiles"/>
|
||||||
|
</concat>
|
||||||
|
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="build-allrends" depends="build-dir,plugins">
|
||||||
|
<echo>Concatenating files:${line.separator}${prettty-sourcefiles-allrends}${line.separator}into ${build.dir}/${JS_NAME}...</echo>
|
||||||
|
<concat fixlastline="yes" destfile="${build.dir}/${JS_NAME}">
|
||||||
|
<path refid="sourcefiles-allrends"/>
|
||||||
</concat>
|
</concat>
|
||||||
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME}" />
|
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME}" />
|
||||||
</target>
|
</target>
|
||||||
@ -75,7 +102,31 @@
|
|||||||
<file name="Queue.js"/>
|
<file name="Queue.js"/>
|
||||||
<file name="Renderer.js"/>
|
<file name="Renderer.js"/>
|
||||||
<file name="Util.js"/>
|
<file name="Util.js"/>
|
||||||
<file name="renderers/Canvas.js"/>
|
<file name="renderers/Canvas.js"/>
|
||||||
|
</sources>
|
||||||
|
</jscomp>
|
||||||
|
<delete file="${build.dir}/${JS_NAME_MIN}.tmp"></delete>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="syntaxcheck-allrends" depends="build-dir,build-allrends">
|
||||||
|
<jscomp compilationLevel="simple" warning="verbose"
|
||||||
|
debug="false"
|
||||||
|
output="${build.dir}/${JS_NAME_MIN}.tmp">
|
||||||
|
<externs dir="${lib.dir}">
|
||||||
|
<file name="${jquery-externs}"/>
|
||||||
|
</externs>
|
||||||
|
<sources dir="${src.dir}">
|
||||||
|
<!-- need to write them again here since the closure compiler doesn't understand filesets,... -->
|
||||||
|
<file name="LICENSE"/>
|
||||||
|
<file name="Core.js"/>
|
||||||
|
<file name="Generate.js"/>
|
||||||
|
<file name="Parse.js"/>
|
||||||
|
<file name="Preload.js"/>
|
||||||
|
<file name="Queue.js"/>
|
||||||
|
<file name="Renderer.js"/>
|
||||||
|
<file name="Util.js"/>
|
||||||
|
<file name="renderers/Canvas.js"/>
|
||||||
|
<file name="renderers/SVG.js"/>
|
||||||
</sources>
|
</sources>
|
||||||
</jscomp>
|
</jscomp>
|
||||||
<delete file="${build.dir}/${JS_NAME_MIN}.tmp"></delete>
|
<delete file="${build.dir}/${JS_NAME_MIN}.tmp"></delete>
|
||||||
@ -95,6 +146,20 @@
|
|||||||
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME_MIN}" />
|
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME_MIN}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="release-allrends" depends="build-dir,build-allrends,syntaxcheck-allrends">
|
||||||
|
<jscomp compilationLevel="simple" warning="verbose"
|
||||||
|
debug="false"
|
||||||
|
output="${build.dir}/${JS_NAME_MIN}">
|
||||||
|
<externs dir="${lib.dir}">
|
||||||
|
<file name="${jquery-externs}"/>
|
||||||
|
</externs>
|
||||||
|
<sources dir="${build.dir}">
|
||||||
|
<file name="${JS_NAME}"/>
|
||||||
|
</sources>
|
||||||
|
</jscomp>
|
||||||
|
<replaceregexp match="@VERSION@" replace="${version}" flags="g" byline="true" file="${build.dir}/${JS_NAME_MIN}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="clean">
|
<target name="clean">
|
||||||
<delete dir="${build.dir}"></delete>
|
<delete dir="${build.dir}"></delete>
|
||||||
</target>
|
</target>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script type="text/javascript" src="external/jquery-1.6.2.min.js"></script>
|
<script type="text/javascript" src="external/jquery-1.6.2.min.js"></script>
|
||||||
<script type="text/javascript" src="build/html2canvas.js"></script>
|
<script type="text/javascript" src="build/html2canvas.js"></script>
|
||||||
@ -2370,4 +2370,4 @@ body
|
|||||||
<div class="copyright">
|
<div class="copyright">
|
||||||
©Copyright Max Design 2010
|
©Copyright Max Design 2010
|
||||||
</div>
|
</div>
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -58,9 +58,9 @@ _html2canvas.Renderer = function(parseQueue, options){
|
|||||||
|
|
||||||
|
|
||||||
sortZ(parseQueue.zIndex);
|
sortZ(parseQueue.zIndex);
|
||||||
if ( typeof options.renderer._create !== "function" ) {
|
if ( typeof options._renderer._create !== "function" ) {
|
||||||
throw new Error("Invalid renderer defined");
|
throw new Error("Invalid renderer defined");
|
||||||
}
|
}
|
||||||
return options.renderer._create( parseQueue, options, document, queue, _html2canvas );
|
return options._renderer._create( parseQueue, options, document, queue, _html2canvas );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
18
src/Util.js
18
src/Util.js
@ -34,14 +34,20 @@ html2canvas = function( elements, opts ) {
|
|||||||
flashcanvas: undefined, // path to flashcanvas
|
flashcanvas: undefined, // path to flashcanvas
|
||||||
width: null,
|
width: null,
|
||||||
height: null,
|
height: null,
|
||||||
taintTest: true // do a taint test with all images before applying to canvas
|
taintTest: true, // do a taint test with all images before applying to canvas
|
||||||
|
renderer: "Canvas"
|
||||||
};
|
}, renderer;
|
||||||
|
|
||||||
options = _html2canvas.Util.Extend(opts, options);
|
options = _html2canvas.Util.Extend(opts, options);
|
||||||
|
|
||||||
options.renderer = options.renderer || _html2canvas.Renderer.Canvas( options );
|
if (typeof options.renderer === "string" && _html2canvas.Renderer[options.renderer] !== undefined) {
|
||||||
|
options._renderer = _html2canvas.Renderer[options.renderer]( options );
|
||||||
|
} else if (typeof options.renderer === "function") {
|
||||||
|
options._renderer = options.renderer( options );
|
||||||
|
} else {
|
||||||
|
throw("Unknown renderer");
|
||||||
|
}
|
||||||
|
|
||||||
_html2canvas.logging = options.logging;
|
_html2canvas.logging = options.logging;
|
||||||
options.complete = function( images ) {
|
options.complete = function( images ) {
|
||||||
|
|
||||||
|
@ -135,10 +135,10 @@ _html2canvas.Renderer.SVG = function( options ) {
|
|||||||
|
|
||||||
el = doc.createElementNS(svgNS, "image");
|
el = doc.createElementNS(svgNS, "image");
|
||||||
el.setAttributeNS(xlinkNS, "xlink:href", renderItem['arguments'][0].src);
|
el.setAttributeNS(xlinkNS, "xlink:href", renderItem['arguments'][0].src);
|
||||||
el.setAttribute("width", renderItem['arguments'][0].width);
|
el.setAttribute("width", renderItem['arguments'][7]);
|
||||||
el.setAttribute("height", renderItem['arguments'][0].height);
|
el.setAttribute("height", renderItem['arguments'][8]);
|
||||||
el.setAttribute("x", renderItem['arguments'][5] - renderItem['arguments'][1]);
|
el.setAttribute("x", renderItem['arguments'][5]);
|
||||||
el.setAttribute("y", renderItem['arguments'][6] - renderItem['arguments'][2]);
|
el.setAttribute("y", renderItem['arguments'][6]);
|
||||||
el.setAttribute("clip-path", "url(#clipId" + clipId + ")");
|
el.setAttribute("clip-path", "url(#clipId" + clipId + ")");
|
||||||
// el.setAttribute("xlink:href", );
|
// el.setAttribute("xlink:href", );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user