Hello Monks, I'm new to this forum. I'm currently trying to create something akin to paint. I've created a grid of pixels. Everything seems to be working just fine except when i draw something too quickly the pixels in between seem to be getting skipped. It is as if the mouse is too fast for the perl program. How can I deal with this? Here is my code: (left click will start the drawing process)
use Tk; use strict; use warnings;
###Configurable Variables### my $pixel_size = 20; my $window_width = 1800; my $window_height = 1000;
#####create the Main Window##### my $mw = new MainWindow(-title => "BACnet Brush 1.0"); $mw -> geometry("1800x1000"); #resize the main window
#####Clear Button##### # This button clears the screen my $clear_button = $mw -> Button(-text => "Clear",-command => \&clear) + -> place(-x => $window_width*.5, -y => $window_height*.05);
#####create the canvas##### my $canv_width = .75*$window_width; my $canv_height = .8*$window_height; my $canvas = $mw -> Canvas(-width => $canv_width, -height => $canv_hei +ght, -relief => "sunken"); $canvas -> place(-x => .1*$window_width, -y => .1*$window_height);
#####creating the pixel grid on the canvas##### #pixel size> my $pixel_width = $pixel_size;> my $pixel_height = $pixel_size;>
#position variables for the grid> my $init_x = 0; my $init_y = 0; my $next_x = $pixel_width; my $next_y = $pixel_height;
#the pixel grid my @pixel_id; # this array stores all of the unique ids for each pixel $pixel_counter = 0; for(my $j = $init_y; $j < $canv_height; $j = $j + $pixel_height) { <for(my $i = $init_x; $i < $canv_width;$i = $i + $pixel_width) { $pixel_id[$pixel_counter] = $canvas -> createRectangle($init_x,$ +init_y,$next_x,$next_y,-fill => "white",-outline => "gray"); $init_x = $next_x; $next_x = $next_x + $pixel_width; $pixel_counter++; } $init_x = 0; $next_x = $pixel_width; $init_y = $next_y; $next_y = $next_y + $pixel_height; }
#####configuring the pixel grid #### for( my $k = 1; $k <= scalar(@pixel_id); $k++) { my $l = $k; $canvas->bind($k, "<M1-Enter>", sub { $canvas->itemconfigure($l, -fill => "blue"); }); }
##### Functions ##### ###Clear Function### sub clear { <$canvas -> itemconfigure('all', -fill => "white"); } MainLoop();

In reply to Event Recognition seems to be too slow by popp0102

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.