Comments (4)
Please create a codepen or jsfiddle with the reproduction.
You can also post the most relevant code here.
I am not downloading any files
from svg.js.
Please create a codepen or jsfiddle with the reproduction. You can also post the most relevant code here. I am not downloading any files
@Fuzzyma
I don't know how to upload svg file to jsfiddle, so here is the relevant code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0, maximum-scale=3.0, minimum-scale=0.2,shrink-to-fit=YES">
<title>img_svg_test</title>
</head>
<body>
<div id="canvas"></div>
<script src="./vendor/svg.min.js"></script>
<script>
var draw = SVG().addTo('#canvas')
var image = draw.image();
image.on(['load'],function(e){
console.log("success");
console.log(image.width());
console.log(image.height());
});
image.on('error',function(e){
console.log("error");
console.log(image.width());
console.log(image.height());
});
image.load("./1.svg");
</script>
</body>
</html>
and 1.svg
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"
preserveAspectRatio="none" x="0px" y="0px" width="200px" height="100px" viewBox="0 0 200 100">
<defs>
<g id="Layer0_0_FILL">
<path fill="#0000FF" stroke="none" d="
M 200 100
L 200 0 0 0 0 100 200 100 Z" />
</g>
</defs>
<g transform="matrix( 1, 0, 0, 1, 0,0) ">
<use xlink:href="#Layer0_0_FILL" />
</g>
</svg>
from svg.js.
Seems i used it wrong , this one is correct :
var image = draw.image('/path/to/image.jpg', function (event) {
// image loaded
// this is the loading event for the underlying img element
// you can access the natural width and height of the image with
// event.target.naturalWidth, event.target.naturalHeight
})
or
image.load('/path/to/another/image.jpg', callback)
Works fine now 👍
from svg.js.
glad it resolved itself!
from svg.js.
Related Issues (20)
- Update website on node package README HOT 1
- It would be nice if we can destroy timeline gracefully. HOT 3
- Error: Unbound namespace prefix: "svgjs" HOT 8
- How to judge the <g> container exist the child element <rect>?
- npm install for nodejs HOT 1
- how to move while rotating
- Text alignment differs between 3.0 and 3.1 HOT 1
- (documentation) animating shapes along a path example needs rewrite HOT 5
- Moving a text with an inside title element fails HOT 4
- Migrating SVG window events HOT 6
- Incomplete typings - measurements should accept percentages HOT 3
- No Fragment declaration in svg.js.d.ts HOT 2
- Custom Bezier Function HOT 2
- Negative scale value in animation do not work properly. HOT 4
- TypeError: Cannot read properties of undefined (reading 'call') for PATHs in NodeJS HOT 8
- svgjs.com redirect to 'gacor.poker' scammy site HOT 1
- How can I draw a Polyline from a svg => g => svg => rect (responsive) to an Dom Element on the right side? HOT 1
- Testing overloaded methods is hard HOT 1
- Issues with rolling a timeline backwards with non-animating functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg.js.