i'm no good at maths
#!/usr/bin/perl -- use strict; use warnings; use Tk 8; my $mw = tkinit( -width => 500, -height => 500 ); my $canvas = $mw->Canvas()->pack( -expand => 'yes', ); $canvas->createOval( 50, 50, 100, 100, -fill => 'white', -tags => ['le +ft'] ); $canvas->createOval( 60, 50, 70, 60, -fill => 'red', -tags => ['left i +ris'] ); $canvas->createOval( 100 + 50, 50, 100 + 100, 100, -fill => 'white', -tags => ['right'] ); $canvas->createOval( 100 + 80, 80, 100 + 90, 90, -fill => 'red', -tags => ['right iris'] ); $mw->bind( 'Tk::Canvas', '<Motion>' => [ \&marine, Ev('x'), Ev('y') ] +); use Math::Trig qw' atan pi '; sub marine { my ( $w, $x, $y ) = @_; my $iris = 'left iris'; my $r = 25; my $cx = 75; my $cy = 75; my $angle = eval { atan( ( $cy - $y ) / ( $cx - $x ) ) }; $angle += pi if ( $cx - $x ) >= 0; my ( $x1, $y1, $x2, $y2 ) = $w->coords($iris); $x1 = ( ( $r * cos($angle) + $cx ) ); $y1 = ( ( $r * sin($angle) + $cy ) ); $x2 = $x1 + 10; $y2 = $y1 + 10; $w->coords( $iris, $x1, $y1, $x2, $y2 ); } MainLoop;

In reply to Re^2: Mimicking UNIX Eyes by Anonymous Monk
in thread Mimicking UNIX Eyes by merrymonk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.