Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
here is my test program.
#!/usr/bin/perl -w # Research For Goo::Canvas Scaling use strict; use Gtk2 '-init'; use Goo::Canvas; my $rect; my $window = Gtk2::Window->new; $window->signal_connect(destroy=>sub{Gtk2->main_quit;}); $window->fullscreen; my $canvas = Goo::Canvas->new; #$canvas->set('integer-layout',1); $canvas->set_size_request(1020,500); $canvas->set_bounds(0,0,1000,500); $canvas->set_scale(1); $canvas->set('background-color','white'); my $base = Goo::Canvas::Group->new($canvas->get_root_item); $base->set('line-width','1','stroke-color','black'); my $vbox = Gtk2::VBox->new; my $holder = Goo::Canvas::Group->new($base); $holder->set_simple_transform((1000/2)-(200/2),(500/2)-(200/2),1,0); $holder->{'x'} = (1000/2)-(200/2); $holder->{'y'} = (500/2)-(200/2); $holder->{'scale'} = 1; $holder->{'angle'} = 0; $holder->{'width'} = 200; $holder->{'height'} = 200; for(my $i = 0; $i <= 1000; $i+=50){ my $line= Goo::Canvas::Polyline->new_line($base,$i,0,$i,700); } for(my $i = 0; $i <= 500; $i+=50){ my $line= Goo::Canvas::Polyline->new_line($base,0,$i,1000,$i); } $rect = Goo::Canvas::Rect->new ($holder,0,0,200,200,'stroke-color','re +d','line-width',5,'fill-color','white'); $rect->signal_connect('motion_notify_event', \&on_motion_notify); $rect->signal_connect('button_press_event', \&on_button_press); $rect->signal_connect('button_release_event', \&on_button_release); my $line= Goo::Canvas::Polyline->new_line($holder,100,0,100,200,'line- +width',1,'stroke-color','blue'); $line= Goo::Canvas::Polyline->new_line($holder,0,100,200,100,'line-wid +th',1,'stroke-color','blue'); $line= Goo::Canvas::Polyline->new_line($holder,0,125,200,125,'line-wid +th',1,'stroke-color','red'); $line= Goo::Canvas::Polyline->new_line($holder,0,75,200,75,'line-width +',1,'stroke-color','red'); $line= Goo::Canvas::Polyline->new_line($holder,125,0,125,200,'line-wid +th',1,'stroke-color','green'); $line= Goo::Canvas::Polyline->new_line($holder,75,0,75,200,'line-width +',1,'stroke-color','green'); my $hbox = Gtk2::HBox->new; my $button = Gtk2::Button->new("Scale Up!"); $button->signal_connect('clicked',sub {scale_norm(.01,$holder);}); $hbox->pack_start($button,0,1,0); $button = Gtk2::Button->new("Scale Down!"); $button->signal_connect('clicked',sub {scale_norm(-.01,$holder);}); $hbox->pack_start($button,0,1,0); $vbox->pack_start($canvas,0,1,0); $vbox->pack_start($hbox,0,1,0); $window->add($vbox); $window->show_all; Gtk2->main; sub scale_norm { my ($factor,$group) = @_; $group->{'scale'}+=$factor; $group->{'x'}-= (($group->{'width'} * $group->{'scale'}) - $group- +>{'width'})/2; $group->set_simple_transform($group->{'x'},$group->{'y'},$group->{ +'scale'},$group->{'angle'}); # I WANT TO GET THE SIMPLE TRANSFORM VALUES SUCH AS THE X AND Y CO +ORDS AND SCALE AND ANGLE # # WITHOUT USING THE DATA RIDER THAT I MADE. PUT A COMMENT ON THE N +EXT LINE TO MAKE IT RUN # my ($x, $y, $scale, $angle) = $group->get_simple_transform; } sub on_motion_notify { my ($item, $target, $event) = @_; $item->{'mouse'}->{'x'} = $event->x; $item->{'mouse'}->{'y'} = $event->y; my $canvas = $item->get_canvas; $canvas->grab_focus($item); if ( $item->{dragging} && $event->state >= 'button1-mask' ) { #($item->get('parent'))->translate($event->x - $item->{drag_x} +,$event->y - $item->{drag_y}); my $holder = $item->get('parent'); $holder->set_simple_transform($holder->{'x'} + $event->x - $it +em->{drag_x},$holder->{'y'} + $event->y - $item->{drag_y},$holder->{' +scale'},$holder->{'angle'}); $holder->{'x'} += $event->x - $item->{drag_x}; $holder->{'y'} += $event->y - $item->{drag_y}; #print $holder->{'x'} , ' - ' , $holder->{'y'} , "\n"; } return 1; } sub on_button_press { my ($item, $target, $ev) = @_; if ( $ev->button == 1 ) { if ( $ev->state >= 'shift-mask' ) { } else { $item->{drag_x} = $ev->x; $item->{drag_y} = $ev->y; my $fleur = Gtk2::Gdk::Cursor->new('fleur'); my $canvas = $item->get_canvas; $canvas->pointer_grab($item, ['pointer-motion-mask', 'butt +on-release-mask'],$fleur, $ev->time); $item->{dragging} = 1; } } return 1; } sub on_button_release { my ($item, $target, $ev) = @_; my $canvas = $item->get_canvas; $canvas->pointer_ungrab($item, $ev->time); $item->{dragging} = 0; return 1; }

In reply to Re^2: usage on get_simple_transform on goocanvas by renegadex
in thread usage on get_simple_transform on goocanvas by renegadex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-06-30 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (98 votes). Check out past polls.

    Notices?