English 中文(简体)
如何在结构中某个特定点进行轮换?
原标题:how to rotate around one specified point in fabric.js?

是否有任何人知道如何在结构中某个特定点进行轮换? 例如,

var line1 = new fabric.Line([70, 20, 70, 100], {
    stroke: "#000000",
    strokeWidth: 6
});

我想根据其终点(70、100)而不是中心轮换。

问题回答

您可以通过<代码>fabric.util.rotatePoint就任意点进行轮换。 这将使您在学位(<条码>、<条码>>、<条码>y1、<条码>、<条码>、<条码>>、<条码>、<条码>、<条码>、<条码>、>条码>、<条码>、<条码>、>条码>、<条码>、<条码>x2>、>条码>、<条码>、>条码>、、<条码>、>、>条码>、、>条/条码>、<>、>、>条、>条、>条、>条、

Note that fabric.util.rotatePoint takes a rotation in radians, even though angles are usually specified in degrees when using fabric.js.

var rotation_origin = new fabric.Point(origin_x, origin_y);
var angle_radians = fabric.util.degreesToRadians(angle);
var start = fabric.util.rotatePoint(new fabric.Point(x1,y1), rotation_origin, angle_radians);
var end = fabric.util.rotatePoint(new fabric.Point(x2,y2), rotation_origin, angle_radians);
var line1 = new fabric.Line([start.x, start.y, end.x, end.y], {
    stroke:  #000000 ,
    strokeWidth: 6
});

你可以与其他物体一样,但你可能需要提供<代码>angle的财产,以便适当轮换物体。

目前没有办法围绕任意点进行轮换。 变革的起源——扩大和安放;轮换——目前是一个目标。 我们重新规划,在不远的将来对变革的任意来源给予更多的支持。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签