Raphael-GWT:形状(矩形)的填充图像出现偏移。如何解决这个问题?
我想知道 {Shape}.attr("fill","url({image.path})")
的行为。
将填充图像应用于形状时:
public class AppMapCanvas extends Raphael {
public AppMapCanvas(int width, int height) {
super(width, height);
this.hCenter = width / 2;
this.vCenter = height / 2;
...
Rect rect = this.new Rect(hCenter, vCenter, 144, 40, 4);
rect.attr("fill", "url('../images/app-module-1-bg.png')"); // <--
...
}
}
背景图像似乎在形状后面的画布上呈青色,因此位置很奇怪(附有插图快照 - 我将原始图像边框标记为红色)。
这似乎在沿路径存在动画的情况下自行解决(仅 path.M(0,0)
就足够了)。
我怎样才能正确定位填充图像?
I'm wondering about the behavior of {Shape}.attr("fill","url({image.path})")
.
when applying a fill image to a shape:
public class AppMapCanvas extends Raphael {
public AppMapCanvas(int width, int height) {
super(width, height);
this.hCenter = width / 2;
this.vCenter = height / 2;
...
Rect rect = this.new Rect(hCenter, vCenter, 144, 40, 4);
rect.attr("fill", "url('../images/app-module-1-bg.png')"); // <--
...
}
}
The background image seem to teal accross the canvas behind the shape, thus gets weird positioning (an illustration snapshot is enclosed - i marked the original image borders in red).
This seem to resolve itself in the presence of an animation along a path (a mere path.M(0,0)
is sufficiant).
How can i position the fill-image properly in the first place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,执行此操作的正确方法是使用 SVG 模式声明来指定您想要使用的图像的部分和位置。然后您将使用该图案来填充矩形元素。不幸的是,Raphael javascript 库不支持模式...因此没有直接的方法使用图像来填充矩形。
The proper way to do this from what I can understand would be to use an SVG pattern declaration to specify the portion and position of the image you would want to use. Then you would use that pattern to fill the rectangle element. Unfortunately, the Raphael javascript library doesn't have support for patterns... so there's no direct way to use an image to fill a rectangle.