简体   繁体   English

如何在Raphael js中获得完整的图像

[英]How to get complete image inside the circle in Raphael js

I am able to fill the image inside the circle. 我能够在圆圈内填充图像。 But the problem is image getting zoomed inside the circle, i want image to be less zoomed or fit into circle. 但是问题是图像在圆圈内变大,我希望图像变少或适合圆圈。

<div class="disp"></div>

JavaScript 的JavaScript

  var r = Raphael("disp");

  var cir=r.circle(100, 100,33).attr({fill:"url(image.jpg)"});
// image get zoomed, how to make image fit into circle or less zoomed

Please help me! 请帮我! Thanks 谢谢

You will need to do some mathematics. 您将需要做一些数学。 Don't use attr(fill) - create an image -object and fit it in your circle. 不要使用attr(fill) -创建image -对象并将其适合您的圈子。
Here is a great example of such behaviour. 是这种行为的一个很好的例子。

BTW, you wrote class ="disp" and var r = Raphael("disp"); 顺便说一句,您编写了“ =“ disp” 类,并且var r = Raphael("disp"); won't work - this function waits for id . 将不起作用-此函数等待id

Here's a solution you can put directly into your code, assuming you're using jQuery as well as Raphael 假设您同时使用jQuery和Raphael, 这是可以直接放入代码中的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM