Please do open a bug, and attach the test case :) It sounds like some
precision issues - get_abs_position is very complex due to 3D space,
transforms etc.

  == Matthew

On Wed, 2008-04-23 at 13:26 -0700, Bob Dickinson wrote:
> Hmm.  Sound of crickets.
> 
> I took a look at the C code for computing the absolute position.  I
> think that I understand the goal of that code, but I had difficulty
> following the logic / math (being very new to clutter, and not having
> coded in C for a while).  But that process made me wonder if there was
> an issue with conversion to/from clutter units, and whether the
> internal rendering code was using the abs position to do the
> rendering.
> 
> I wrote another sample to see whether the textures were being rendered
> at the wrong position, or just reporting the wrong position when using
> get_abs_position.  It looks like this:
> 
> import clutter
> import sys
> 
> class Test:
> 
>     def __init__ (self):
>         self.stage = clutter.Stage()
>         self.stage.set_color(clutter.color_parse('DarkSlateGrey'))
>         self.stage.connect('key-press-event', clutter.main_quit)
> 
>         self.stage.fullscreen()
>         self.stage.set_property("fullscreen", True)
> 
>         self.boxes = []
> 
>         for y in range(100):
>             box = clutter.Rectangle()
>             box.set_color(clutter.color_parse('Black'))
>             box.set_size(10, 10)
>             box.show()
>             self.stage.add(box)
>             box.set_position(y * 10,y)
>             self.boxes.append(box)
> 
>         self.timeline = clutter.Timeline(1, 15)
>         self.timeline.connect("completed", self.doneInitializing)
> 
>     def doneInitializing(self, timeline):
>         for box in self.boxes:
>             print "abs pos:", box.get_abs_position()
> 
>     def run (self):
>         self.stage.show_all()
>         self.timeline.start()
>         clutter.main()
> 
> def main (args):
>     app = Test()
>     app.run()
>     return 0
> 
> if __name__ == '__main__':
>     sys.exit(main(sys.argv[1:]))
> 
> That code produces a stairstep pattern of 10 x 10 boxes that descend
> exactly one pixed per box, indicating that the position attribute is
> being obeyed.  When reporting the abs position of these boxes, I get
> the same results as before:
> 
> abs pos: (0, 0)
> abs pos: (10, 3)
> abs pos: (20, 3)
> abs pos: (30, 3)
> abs pos: (40, 6)
> abs pos: (50, 6)
> abs pos: (60, 6)
> abs pos: (70, 9)
> abs pos: (80, 9)
> abs pos: (90, 9)
> abs pos: (100, 12)
> abs pos: (110, 12)
> abs pos: (120, 12)
> abs pos: (130, 15)
> abs pos: (140, 15)
> abs pos: (150, 15)
> abs pos: (160, 18)
> abs pos: (170, 18)
> abs pos: (180, 18)
> abs pos: (190, 21)
> abs pos: (200, 21)
> abs pos: (210, 21)
> abs pos: (220, 25)
> abs pos: (230, 25)
> abs pos: (240, 25)
> abs pos: (250, 25)
> abs pos: (260, 28)
> abs pos: (270, 28)
> abs pos: (280, 28)
> abs pos: (290, 31)
> abs pos: (300, 31)
> abs pos: (310, 31)
> abs pos: (320, 34)
> abs pos: (330, 34)
> abs pos: (340, 34)
> abs pos: (350, 37)
> abs pos: (360, 37)
> abs pos: (370, 37)
> abs pos: (380, 40)
> abs pos: (390, 40)
> abs pos: (400, 40)
> abs pos: (410, 43)
> abs pos: (420, 43)
> abs pos: (430, 43)
> abs pos: (440, 46)
> abs pos: (450, 46)
> abs pos: (460, 46)
> abs pos: (470, 50)
> abs pos: (480, 50)
> abs pos: (490, 50)
> abs pos: (500, 50)
> abs pos: (510, 53)
> abs pos: (520, 53)
> abs pos: (530, 53)
> abs pos: (540, 56)
> abs pos: (550, 56)
> abs pos: (560, 56)
> abs pos: (570, 59)
> abs pos: (580, 59)
> abs pos: (590, 59)
> abs pos: (600, 62)
> abs pos: (610, 62)
> abs pos: (620, 62)
> abs pos: (630, 65)
> abs pos: (640, 65)
> abs pos: (650, 65)
> abs pos: (660, 68)
> abs pos: (670, 68)
> abs pos: (680, 68)
> abs pos: (690, 71)
> abs pos: (700, 71)
> abs pos: (710, 71)
> abs pos: (720, 75)
> abs pos: (730, 75)
> abs pos: (740, 75)
> abs pos: (750, 75)
> abs pos: (760, 78)
> abs pos: (770, 78)
> abs pos: (780, 78)
> abs pos: (790, 81)
> abs pos: (800, 81)
> abs pos: (810, 81)
> abs pos: (820, 84)
> abs pos: (830, 84)
> abs pos: (840, 84)
> abs pos: (850, 87)
> abs pos: (860, 87)
> abs pos: (870, 87)
> abs pos: (880, 90)
> abs pos: (890, 90)
> abs pos: (900, 90)
> abs pos: (910, 93)
> abs pos: (920, 93)
> abs pos: (930, 93)
> abs pos: (940, 96)
> abs pos: (950, 96)
> abs pos: (960, 96)
> abs pos: (970, 100)
> abs pos: (980, 100)
> abs pos: (990, 100)
> 
> So clearly the boxes are being rendered at the correct position
> accoring to the set/get position, and reporting an abs position that
> is off by up to 4 pixels at my current screen size (and presumably
> more at larger resolutions).  This is leading me to the conclusion
> that get_abs_position is broken (and if the underlying math it uses is
> broken, there may be other implications).
> 
> Anybody have an opinion about that?  I was a little reluctant to just
> open a bug for this, as I'm a clutter newb, but I'm kind of leaning
> that way now.
> 
> Bob
> 
> On Fri, Apr 18, 2008 at 7:15 PM, Bob Dickinson <[EMAIL PROTECTED]> wrote:
> > I've run into a problem, either with get_abs_position, or with my
> >  understanding of it.
> >
> >  I have been using get_abs_position in order to do coordinate
> >  transformations to position actors relative to each other.  I have a
> >  lot of little spacing problems, which I have tracked down to
> >  get_abs_position returning values with a higher granularity than
> >  get_position (on the order of 3-4 pixels when the stage is full
> >  screen).
> >
> >  I wrote the following simple test app (in Python) that demonstrates the 
> > problem.
> >
> >  import clutter
> >  import sys
> >
> >  class Test:
> >
> >     def __init__ (self):
> >         self.stage = clutter.Stage()
> >         self.stage.set_color(clutter.color_parse('DarkSlateGrey'))
> >
> >         self.stage.fullscreen()
> >         self.stage.set_property("fullscreen", True)
> >
> >         self.testTexture = clutter.Rectangle()
> >         self.testTexture.set_color(clutter.color_parse('Black'))
> >         self.testTexture.set_size(100, 100)
> >         self.testTexture.show()
> >         self.stage.add(self.testTexture)
> >
> >         self.testTexture.set_position(100,100)
> >         print "initial position", self.testTexture.get_position()
> >
> >         self.timeline = clutter.Timeline(1, 15)
> >         self.timeline.connect("completed", self.doneInitializing)
> >
> >     def doneInitializing(self, timeline):
> >         print "done initializing, position:",
> >  self.testTexture.get_position(), ", abs position:",
> >  self.testTexture.get_abs_position()
> >
> >         for y in range(100):
> >             self.testTexture.set_position(100,y)
> >             print "position:", self.testTexture.get_position(), ", abs
> >  position:", self.testTexture.get_abs_position()
> >
> >         clutter.main_quit()
> >
> >     def run (self):
> >         self.stage.show_all()
> >         self.timeline.start()
> >         clutter.main()
> >
> >  def main (args):
> >     app = Test()
> >     app.run()
> >     return 0
> >
> >  if __name__ == '__main__':
> >     sys.exit(main(sys.argv[1:]))
> >
> >  When this app is run, it produces the following output:
> >
> >  initial position (100, 100)
> >  done initializing, position: (100, 100) , abs position: (100, 100)
> >  position: (100, 0) , abs position: (100, 0)
> >  position: (100, 1) , abs position: (100, 3)
> >  position: (100, 2) , abs position: (100, 3)
> >  position: (100, 3) , abs position: (100, 3)
> >  position: (100, 4) , abs position: (100, 6)
> >  position: (100, 5) , abs position: (100, 6)
> >  position: (100, 6) , abs position: (100, 6)
> >  position: (100, 7) , abs position: (100, 9)
> >  position: (100, 8) , abs position: (100, 9)
> >  position: (100, 9) , abs position: (100, 9)
> >  position: (100, 10) , abs position: (100, 12)
> >  position: (100, 11) , abs position: (100, 12)
> >  position: (100, 12) , abs position: (100, 12)
> >  position: (100, 13) , abs position: (100, 15)
> >  position: (100, 14) , abs position: (100, 15)
> >  position: (100, 15) , abs position: (100, 15)
> >  position: (100, 16) , abs position: (100, 18)
> >  position: (100, 17) , abs position: (100, 18)
> >  position: (100, 18) , abs position: (100, 18)
> >  position: (100, 19) , abs position: (100, 21)
> >  position: (100, 20) , abs position: (100, 21)
> >  position: (100, 21) , abs position: (100, 21)
> >  position: (100, 22) , abs position: (100, 25)
> >  position: (100, 23) , abs position: (100, 25)
> >  position: (100, 24) , abs position: (100, 25)
> >  position: (100, 25) , abs position: (100, 25)
> >  position: (100, 26) , abs position: (100, 28)
> >  position: (100, 27) , abs position: (100, 28)
> >  position: (100, 28) , abs position: (100, 28)
> >  position: (100, 29) , abs position: (100, 31)
> >  position: (100, 30) , abs position: (100, 31)
> >  position: (100, 31) , abs position: (100, 31)
> >  position: (100, 32) , abs position: (100, 34)
> >  position: (100, 33) , abs position: (100, 34)
> >  position: (100, 34) , abs position: (100, 34)
> >  position: (100, 35) , abs position: (100, 37)
> >  position: (100, 36) , abs position: (100, 37)
> >  position: (100, 37) , abs position: (100, 37)
> >  position: (100, 38) , abs position: (100, 40)
> >  position: (100, 39) , abs position: (100, 40)
> >  position: (100, 40) , abs position: (100, 40)
> >  position: (100, 41) , abs position: (100, 43)
> >  position: (100, 42) , abs position: (100, 43)
> >  position: (100, 43) , abs position: (100, 43)
> >  position: (100, 44) , abs position: (100, 46)
> >  position: (100, 45) , abs position: (100, 46)
> >  position: (100, 46) , abs position: (100, 46)
> >  position: (100, 47) , abs position: (100, 50)
> >  position: (100, 48) , abs position: (100, 50)
> >  position: (100, 49) , abs position: (100, 50)
> >  position: (100, 50) , abs position: (100, 50)
> >  position: (100, 51) , abs position: (100, 53)
> >  position: (100, 52) , abs position: (100, 53)
> >  position: (100, 53) , abs position: (100, 53)
> >  position: (100, 54) , abs position: (100, 56)
> >  position: (100, 55) , abs position: (100, 56)
> >  position: (100, 56) , abs position: (100, 56)
> >  position: (100, 57) , abs position: (100, 59)
> >  position: (100, 58) , abs position: (100, 59)
> >  position: (100, 59) , abs position: (100, 59)
> >  position: (100, 60) , abs position: (100, 62)
> >  position: (100, 61) , abs position: (100, 62)
> >  position: (100, 62) , abs position: (100, 62)
> >  position: (100, 63) , abs position: (100, 65)
> >  position: (100, 64) , abs position: (100, 65)
> >  position: (100, 65) , abs position: (100, 65)
> >  position: (100, 66) , abs position: (100, 68)
> >  position: (100, 67) , abs position: (100, 68)
> >  position: (100, 68) , abs position: (100, 68)
> >  position: (100, 69) , abs position: (100, 71)
> >  position: (100, 70) , abs position: (100, 71)
> >  position: (100, 71) , abs position: (100, 71)
> >  position: (100, 72) , abs position: (100, 75)
> >  position: (100, 73) , abs position: (100, 75)
> >  position: (100, 74) , abs position: (100, 75)
> >  position: (100, 75) , abs position: (100, 75)
> >  position: (100, 76) , abs position: (100, 78)
> >  position: (100, 77) , abs position: (100, 78)
> >  position: (100, 78) , abs position: (100, 78)
> >  position: (100, 79) , abs position: (100, 81)
> >  position: (100, 80) , abs position: (100, 81)
> >  position: (100, 81) , abs position: (100, 81)
> >  position: (100, 82) , abs position: (100, 84)
> >  position: (100, 83) , abs position: (100, 84)
> >  position: (100, 84) , abs position: (100, 84)
> >  position: (100, 85) , abs position: (100, 87)
> >  position: (100, 86) , abs position: (100, 87)
> >  position: (100, 87) , abs position: (100, 87)
> >  position: (100, 88) , abs position: (100, 90)
> >  position: (100, 89) , abs position: (100, 90)
> >  position: (100, 90) , abs position: (100, 90)
> >  position: (100, 91) , abs position: (100, 93)
> >  position: (100, 92) , abs position: (100, 93)
> >  position: (100, 93) , abs position: (100, 93)
> >  position: (100, 94) , abs position: (100, 96)
> >  position: (100, 95) , abs position: (100, 96)
> >  position: (100, 96) , abs position: (100, 96)
> >  position: (100, 97) , abs position: (100, 100)
> >  position: (100, 98) , abs position: (100, 100)
> >  position: (100, 99) , abs position: (100, 100)
> >
> >  This behavior can be seen in both the x and y dimensions, and the
> >  granularity is larger as the screen/stage gets bigger.
> >
> >  Since get_position is pixel-accurate, I assume I can work around this
> >  by just walking the parents up to the stage using get_position and
> >  doing the math myself.
> >
> >  Is get_abs_position broken, or am I using it incorrectly?  The docs
> >  say "Gets the absolute position of an actor, in pixels, relative to
> >  the stage", which does not seem to be the case.
> >
> >  Any help would be appreciated.
> >
> >  Bob
> >

-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to