Hello!

  I have the following code:

USING: kernel typed literals accessors assocs sequences math math.vectors
  opengl ui.gadgets ui.render colors colors.constants locals arrays
  namespaces ;
IN: iqlink.field

TUPLE: inner-gadget < gadget ;
TUPLE: outer-gadget < gadget ;

M: inner-gadget pref-dim*
  drop { 10 10 } ;

M: inner-gadget draw-gadget*
  loc>> { 10 10 } gl-fill-rect ;

: add-inner-gadget ( index parent -- )
  swap 10 * dup 2array
  inner-gadget new swap >>loc
  add-gadget drop ;

: <outer-gadget> ( -- outer-gadget )
  outer-gadget new dup [ add-inner-gadget ] curry
  3 iota swap each ;

M: outer-gadget pref-dim*
  drop { 60 60 } ;

M: outer-gadget draw-gadget*
  drop "red" named-color gl-color gl-error ;

  Run with: [ <outer-gadget> "OuterGadget" open-window ] with-ui

  The outer-gadget simply creates three instances of inner-gadget and keeps 
them as children. All inner-gadgets have the same size 10x10 pixels.
  The outer-gadget positions its children at coordinates { 0 0 }, { 10 10 } and 
{ 20 20 } by setting their loc slot.
  It is therefore expected that the resulting image will consist of three red 
squares aligned diagonally end to end (see "expected.png").
  However, the result is different (see "actual.png").

  Why the difference? Is there a hidden coefficient I'm not taking into account?

  I can get the expected image if I replace 10 with 5 in add-inner-gadget. I 
don't understand this.

---=====---
 Александр
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to