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_height, -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) { 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, "", sub { $canvas->itemconfigure($l, -fill => "blue"); }); } #### ##### Functions ##### ###Clear Function### sub clear { <$canvas -> itemconfigure('all', -fill => "white"); } MainLoop();