Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
sergey_fedunets
Posts: 8
Registered: ‎02-27-2013
My Device: BlackBerry 10 Dev Alpha
My Carrier: no
Accepted Solution

How to use the property PivotX and PivotY in cascades

Hi,

My target is to rotate the line on my angle.

 

img1

1. I have received two points: A(x1; y1) and B(x2; y2);


2. I have calculated the size of vector AB and the angle of point A:
AB = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
angleA = 44*


3. I set up the line on the coordinate plane (width = AB, height = 3px):
myLine.layoutProperties.positionX = x1;
myLine.layoutProperties.positionY = y1;


4. I have to rotate the line on the angle which has being found.
The start point of line must be the point A, the end point - point B. But, I failed =(
I try to use the rotationZ, but i dont know how to work with its propertyes PivotX and PivotY.
On default PivotX = 0 and PivotY = 0. When I try to set up PivotX = x1 and PivotY = y1 I get incorrect result.

With PivotX = 0 and PivotY = 0 I get it (myLine.rotationZ = 44):

 

img2

Please, help me =)

 

Please use plain text.
New Contributor
sergey_fedunets
Posts: 8
Registered: ‎02-27-2013
My Device: BlackBerry 10 Dev Alpha
My Carrier: no

Re: How to use the property PivotX and PivotY in cascades

P.S.: my line is the image(3px*600px), when I set up it to the coordinate plane the line has the size: 

myLine.preferredHeight = 3;
myLine.preferredWidth = AB;

Please use plain text.
BlackBerry Development Advisor
llevonian
Posts: 2
Registered: ‎08-30-2011
My Device: BlackBerry Z10
My Carrier: O2

Re: How to use the property PivotX and PivotY in cascades

That might be happening because setting pivotX and pivotY to zero makes the rotation around the center of the element. In the case of this image that equals to its central point (300, 1.5), but not it's top left point. Try setting the pivotX to -(image.width/2), which will be: -300; and pivotY to -(image.height/2), which is -1.5; and then rotate again. 

 

Please see more details on that topic here:

http://developer.blackberry.com/native/reference/cascades/bb__cascades__visualnode.html

Please use plain text.