Author Topic: Preserve aspect ration in wheel using conveyor  (Read 133 times)

calle81

  • Full Member
  • ***
  • Posts: 55
    • View Profile
Preserve aspect ration in wheel using conveyor
« on: August 15, 2017, 12:09:50 PM »
Hi,

How can I mod this layout to preserver the aspect ratio of the wheel images? Its' very hard to get correct aspect using flw*x, flh*x

if ( my_config["enable_list_type"] == "Horizontal Low" )
{
fe.load_module( "conveyor" );
local wheel_x = [ -flx*0.45, -flx*0.3, -flx*0.2, -flx*0.04, flx*0.12 flx*0.28, flx*0.44, flx*0.6, flx*0.76 flx*0.92, flx*1.08, flx*1.24 ];
local wheel_y = [ fly*0.76, fly*0.76, fly*0.76, fly*0.76, fly*0.76, fly*0.76, fly*0.73, fly*0.76, fly*0.76, fly*0.76, fly*0.76, fly*0.76, ];
local wheel_w = [ flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, flw*0.12, ];
local wheel_a = [  255,  255,  255,  255,  255,  255, 255,  255,  255,  255,  255,  255, ];
local wheel_h = [  flh*0.2,  flh*0.2,  flh*0.2,  flh*0.2,  flh*0.2,  flh*0.2, flh*0.2,  flh*0.2,  flh*0.2,  flh*0.2,  flh*0.2,  flh*0.2, ];
local wheel_r = [  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ];
local num_arts = 12;

class WheelEntry extends ConveyorSlot
{
   constructor()
   {
      base.constructor( ::fe.add_artwork( my_config["orbit_art"] ) );
   }

   function on_progress( progress, var )
   {
     local p = progress / 0.1;
      local slot = p.tointeger();
      p -= slot;
      
      slot++;

      if ( slot < 0 ) slot=0;
      if ( slot >=10 ) slot=10;

      m_obj.x = wheel_x[slot] + p * ( wheel_x[slot+1] - wheel_x[slot] );
      m_obj.y = wheel_y[slot] + p * ( wheel_y[slot+1] - wheel_y[slot] );
      m_obj.width = wheel_w[slot] + p * ( wheel_w[slot+1] - wheel_w[slot] );
      m_obj.height = wheel_h[slot] + p * ( wheel_h[slot+1] - wheel_h[slot] );
      m_obj.rotation = wheel_r[slot] + p * ( wheel_r[slot+1] - wheel_r[slot] );
      m_obj.alpha = wheel_a[slot] + p * ( wheel_a[slot+1] - wheel_a[slot] );
   }
};

local wheel_entries = [];
for ( local i=0; i<num_arts/2; i++ )
   wheel_entries.push( WheelEntry() );

local remaining = num_arts - wheel_entries.len();

// we do it this way so that the last wheelentry created is the Center one showing the current
// selection (putting it at the top of the draw order)
for ( local i=0; i<remaining; i++ )
   wheel_entries.insert( num_arts/2, WheelEntry() );

conveyor <- Conveyor();
conveyor.set_slots( wheel_entries );
conveyor.transition_ms = 50;
try { conveyor.transition_ms = my_config["transition_ms"].tointeger(); } catch ( e ) { }
}

calle81

  • Full Member
  • ***
  • Posts: 55
    • View Profile
Re: Preserve aspect ration in wheel using conveyor
« Reply #1 on: August 16, 2017, 11:58:14 AM »
Never mind i figured it out:

conveyor.preserve_aspect_ratio = true;

Example:

// we do it this way so that the last wheelentry created is the Center one showing the current
// selection (putting it at the top of the draw order)
for ( local i=0; i<remaining; i++ )
wheel_entries.insert( num_arts/2, WheelEntry() );

conveyor <- Conveyor();
conveyor.set_slots( wheel_entries );
conveyor.transition_ms = 50;
try { conveyor.transition_ms = my_config["transition_ms"].tointeger(); } catch ( e ) { }
}
conveyor.preserve_aspect_ratio = true;

tonberryhunter

  • Jr. Member
  • **
  • Posts: 21
    • View Profile
Re: Preserve aspect ration in wheel using conveyor
« Reply #2 on: August 17, 2017, 08:11:25 PM »
Have you figured out how to preserve the aspect ratio of the pointer as well?

calle81

  • Full Member
  • ***
  • Posts: 55
    • View Profile
Re: Preserve aspect ration in wheel using conveyor
« Reply #3 on: August 21, 2017, 06:06:45 AM »
Have you figured out how to preserve the aspect ratio of the pointer as well?

Sorry, I always remove the pointer so cant really say :)