- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Raphael.js,但在创建透视变换时遇到了问题。它应该是一个 svg/raphael 解决方案,因为它是创建图像的一个步骤。这是它现在的样子:
目标是使用变换使其在 z 轴上倾斜。它应该看起来像这个图像:
代码:
paper.setStart();
Obj=paper.path('M 2500 3750 L 2500 3481.9 L 0 3481.9 L 0 3750 L 2500 3750Z');
Obj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 3482.2 L 2500 3214.1 L 0 3214.1 L 0 3482.2 L 2500 3482.2Z');
Obj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 3214.3 L 2500 2946.2 L 0 2946.2 L 0 3214.3 L 2500 3214.3Z');
Obj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 2946.5 L 2500 2678.4 L 0 2678.4 L 0 2946.5 L 2500 2946.5Z');
Obj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 2678.6 L 2500 2410.6 L 0 2410.6 L 0 2678.6 L 2500 2678.6Z');
Obj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 2410.8 L 2500 2142.7 L 0 2142.7 L 0 2410.8 L 2500 2410.8Z');
Obj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 2142.9 L 2500 1874.9 L 0 1874.9 L 0 2142.9 L 2500 2142.9Z');
Obj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 1875.1 L 2500 1607 L 0 1607 L 0 1875.1 L 2500 1875.1Z');
Obj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 1607.3 L 2500 1339.2 L 0 1339.2 L 0 1607.3 L 2500 1607.3Z');
Obj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 1339.4 L 2500 1071.3 L 0 1071.3 L 0 1339.4 L 2500 1339.4Z');
Obj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 1071.6 L 2500 803.5 L 0 803.5 L 0 1071.6 L 2500 1071.6Z');
Obj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 803.8 L 2500 535.7 L 0 535.7 L 0 803.8 L 2500 803.8Z');
Obj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 535.9 L 2500 267.8 L 0 267.8 L 0 535.9 L 2500 535.9Z');
Obj.attr({'fill':field_color1,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 2500 268 L 2500 0 L 0 0 L 0 268 L 2500 268Z');
Obj.attr({'fill':field_color2,'stroke':'none', 'fill-opacity': opacity});
Obj=paper.path('M 1237.1 597.3 C 1237.1 604.4 1242.9 610.2 1250 610.2 C 1257.1 610.2 1262.9 604.4 1262.9 597.3 C 1262.9 590.1 1257.1 584.4 1250 584.4 C 1242.9 584.4 1237.1 590.1 1237.1 597.3');
Obj.attr({'fill': line_color,'stroke':'none'});
Obj=paper.path('M 1262.9 3151.7 C 1262.9 3144.6 1257.1 3138.8 1250 3138.8 C 1242.9 3138.8 1237.1 3144.6 1237.1 3151.7 C 1237.1 3158.9 1242.9 3164.7 1250 3164.7 C 1257.1 3164.7 1262.9 3158.9 1262.9 3151.7');
Obj.attr({'fill': line_color,'stroke':'none'});
Obj=paper.path('...');
Obj.attr({'fill': line_color,'stroke':'none'});
var st = paper.setFinish();
编辑:Fiddle
有什么解决办法吗?
最佳答案
我不知道倾斜是否是这里的答案。问题是您正在尝试在纸上应用 3d 效果,而不是 2d 效果。
我不确定是否也可以在纯 svg 和 raphael 中完成,但这是使用 css3 3d 变换 (rotateX) 和透视的纯 css 解决方案:
body {
/* the lower the value, the higher the distortion */
perspective: 600px;
}
#raph-rotate {
width: 500px;
height: 750px;
margin: 0 auto;
transform: rotateX(30deg);
transform-origin: 50% 100%;
}
这是更新后的 fiddle :http://jsfiddle.net/Tj9bJ/2/
关于javascript - Raphael.js 透视变换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24797816/
使用 Raphael,我可以使用以下代码获取对元素的 DOM 对象的引用: element.node 如何获取链接到 DOM 对象的元素?换句话说,上面函数的逆函数(例如 DOMobject.ele
我一直在尝试在集合中嵌套集合,但无济于事。 这个概念来自 photoshop,您可以在其中将元素分组到一个文件夹/集中,然后将它们嵌套到另一个文件夹/集中。 我正在尝试轻松地将两组或更多组合并为一组,
我正在尝试绘制一个矩形,每条边(不在角落)有 4 个连接点。像这样: 因为稍后我需要对它们使用鼠标事件。 最佳答案 是this你在找什么? 关于raphael - 使用 Raphael 绘制带连接点的
您好,我正在按照此页面上的教程进行操作: http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphae
var paper = new Raphael("holder", 320, 200); function testPaper(){
使用 Raphael 2.0 ,我试图以相对于集合中所有对象的方式将变换应用于一组对象。但是,我得到的效果是,无论集合中的其他对象如何,变换都单独应用于每个项目。 例如:http://jsfiddle
我想随着鼠标在纸上的移动画一条线。我只知道如何使用 path 画线。但是想知道是否有人有想法与 mousemove 一起画线。请帮我解决这个问题。 最佳答案 这里有一个使用 raphael 的例子的链
我需要使用 raphael.js 绘制各种大小的同心圆弧。我试图理解背后的代码 http://raphaeljs.com/polar-clock.html ,这与我想要的非常相似,但是,没有评论,很难
我想让堆叠条形图的每个部分(在我的例子中是水平的)都可以单击到特定的超链接(基本上是“向下钻取”)。我认为 g.bar.js 中没有这个功能,但是有人这样做过或者可以为我指出正确的方向吗?在点图上也很
我想用按钮点击事件显示/隐藏我的 raphael svg 图 请知道该怎么做的人。请帮助我 我尝试通过这种方式来做,但它不起作用。 var p = Raphael(900,70,200,200); p
我找不到简单答案的简单问题。 如何查看 Raphael 元素的完整当前人类可读(非矩阵)变换状态,无论该元素的变换状态是否设置或如何设置? 例如,使用 element.transform() 不会为您
我一直在使用raphael.draggable与我目前正在 build 的项目。我已经升级到raphael 2.0现在插件似乎停止工作了,我不知道为什么。 我得到的错误信息是: paper.dragg
我需要检索在 Raphael 中绘制的路径末端的 X/Y 坐标。我找到了一种通过在 SVG 浏览器中自省(introspection)路径的方法,但这种方法在 VML 浏览器中不起作用。 例子: va
我正在将 Raphael 与 Meteor 一起使用,但遇到了问题。我正在创建一个 paper通过使用 var paper = Raphael("paper", 800, 600);如果我将此代码放在
我正在研究项目要使用什么图形,Raphael.js 成为了最佳竞争者。但是,在阅读示例代码和文档时,它显示 Raphael 创建了一个 Canvas (通过 homepage 上的 paper 变量)
出于某种原因,我可以使用矩形变量而不是圆形来使用它。 目前,此代码允许两个圆圈独立拖动,但不能一起拖动 有人知道如何解决这个问题或其他方法吗? addIntermediateSymbol = func
我很难在 Raphael.js 中调整 Canvas 的大小。我以为我可以简单地使用: var paper = Raphael("paper", 100, 100); 这将使用 ID“纸”创建一个宽度
我想使用 raphael.js 渲染 ember.js View 或 d3.js .我的理解是it is possible to do this ,但在阅读了所有文档和谷歌搜索后,我似乎无法弄清楚如何
我认为所有这些基本上都非常酷,并且熟悉它们的明显差异(SVG 与 Canvas ),但我不确定它们在开发时间、性能和支持方面的潜在差异、优势或限制。 最佳答案 我体验过 Processing 作为一个
我最近使用 d3.js 实现了一些数据可视化,我现在正试图让它适用于 Internet Explorer 浏览器版本 7 及更高版本。让它工作的常见建议是将 d3.js 与 raphael.js 结合
我是一名优秀的程序员,十分优秀!