Hi all,

I face a small abnormality (or maybe it should be so), please correct me, if I am wrong:

Example:

I have an image node, which I can drag, using example from libavg.de

Node.x = Event.x-offset[0]
Node.y = Event.y-offset[1]

where offset (x and y distances between node position and mouse pointer position) is taken on the moment of clicking the node.

Everything works fine until I have the node angled, on the moment of click.

and I noticed, that offset taken on click is not the same as offset on mouse move, particularly, as I start to move, offset is changing as it was for zero angled node. I don't know, if explained clearly, I can give a sample code, that you can try the same:

make  test.avg layout:
----------------------------------------
<?xml version="1.0"?>
<avg id="main" width="1024" height="768">
<div id="desktop" x="0" y="0" width="1024" height="768">
<image id="testimage" x="400" y="200" width="480" height="480" opacity="1" angle="0.78" pivotx="0" pivoty="0" href="./img/test.png" oncursordown="Click" oncursormove="Drag" oncursorup="Drop"/> <words id="status" x="20" y="20" font="arial" color="white" text="0.0"/>
</div>
</avg>
---------------------------------------
and some test.py script:
---------------------------------
#!/usr/bin/python
# -*- coding: utf-8 -*-

from libavg import avg, anim
import math

offset = None

def Click(Event):
   global offset
   Node = Event.node
   offset = Node.getRelPos((Event.x, Event.y))
#    Node.angle = 0
statustext="offset: "+str(offset[0])+", "+str(offset[1])+" | Pos: "+str(Node.x)+", "+str(Node.y)
   st=Player.getElementByID("status")
   st.text=statustext
   Node.setEventCapture()


def Drag(Event):
   global offset
   Node = Event.node
   if offset != None:
       Node.x = Event.x-offset[0]
       Node.y = Event.y-offset[1]
       offset2 = Node.getRelPos((Event.x, Event.y))
statustext="offset: "+str(offset2[0])+", "+str(offset2[1])+" | Pos: "+str(Node.x)+", "+str(Node.y)
       st=Player.getElementByID("status")
       st.text=statustext

def Drop(Event):
     global offset
     Node = Event.node
     if offset != None:
         Node.releaseEventCapture()
         offset = None;

Player = avg.Player()

Player.loadFile("test.avg")
Player.play()
------------------------------------------------------

for this example, the image is rotated on 45 degree (0.78 radians) clockwise. I am attaching the image file, it is just a graph with radial lines and one 45 degree line, to clearly see, how and where offset is jumping.


so there is a question, is it a libavg bug, or it should be like this? what do you suggest to overcome this problem?

Thanks for your help,
Zvi


<<inline: test.png>>

_______________________________________________
libavg-users mailing list
[email protected]
https://mail.datenhain.de/mailman/listinfo/libavg-users

Reply via email to