require 'tkmove4.rb' include TestBed require 'draw_common.rb' include DrawCommon def transform_at_cursor( c, matrix ) item = c.find_withtag('current').shift tags = item.gettags a_tag = tags.pop while ( a_tag == 'current' or a_tag == 'selected' ) a_tag = tags.pop end if a_tag.kind_of? Numeric coord = get_item_coords( item ) temp = linear_map( coord, matrix ) set_coords( item, temp ) else coord = get_item_coords( item ) cntr = center( coord ) items = c.find_withtag( a_tag ) items.each{|itm| coord = get_item_coords( itm ) temp = linear_map_with_center( coord, matrix, cntr ) set_coords( itm, temp ) } end end c = TkCanvas.new.pack testbed( c ) move = TkMove.new( c ) f = TkFrame.new.pack TkButton.new(f, 'text'=>'enlarge', 'command'=>proc{ move.unbind c.itembind('item', '1', proc{ transform_at_cursor( c, [1.2, 0, 0, 1.2] ) }) }).pack('side'=>'left') TkButton.new(f, 'text'=>'rotate', 'command'=>proc{ move.unbind c.itembind('item', '1', proc{ transform_at_cursor( c, [0, -1, 1, 0] ) }) }).pack('side'=>'left') TkButton.new(f, 'text'=>'mirror', 'command'=>proc{ move.unbind c.itembind('item', '1', proc{ transform_at_cursor( c, [-1, 0, 0, 1] ) }) }).pack('side'=>'left') Tk.mainloop