#!/usr/bin/perl -w use strict; use Tk 8; my $MWin = new Tk::MainWindow(-background => 'white', -width => 630 , -height => 400 , ,); my $CANVAS = $MWin->Canvas(-width => 612 , -height => 340 , -background => "white", -borderwidth => 0, -highlightthickness => 0, -selectborderwidth => 0, ,)->pack(-expand => 'no', -anchor => 'center', ,); &make_us_up_the_stripes($CANVAS); &draw_us_up_the_stars($CANVAS); &MainLoop(); sub draw_us_up_the_stars { my ($C) = shift; my $star = q'#define star_width 20 #define star_height 16 static unsigned char star_bits[] = { 0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x0f,0x00,0x00,0x0f,0x00, 0xfc,0xff,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0xc0,0x3f,0x00, 0xc0,0x3f,0x00,0xe0,0x7f,0x00,0xe0,0x79,0x00,0xf0,0xf0,0x00,0x30,0xc0,0x00, 0x00,0x00,0x00};'; $star = $C->Bitmap(-background => '#000099', -foreground => 'white', -data => $star, ,); ## the #000099 thing $C->create("rectangle", 1, 1, 244, 183, -fill => "#000099", ); #define star_width 20 #define star_height 16 #6 + 5 * 20 = 220 | 244 #5 + 4 * 16 = 144 | 183 ## the even rows of stars (odd # of stars, even # rows) for my $x (0..5) #6 { for my $y (0..4) #5 { $C->create('image', 22 + $x * 40, 25 + $y * 16 *2, -image => $star, ,); } } ## the even rows of stars (odd # of stars, even # rows) for my $x (0..4) #5 { for my $y (0..3) #4 { $C->create('image', 40 + $x * 40, 40 + $y * 16 * 2, -image => $star, ,); } } } sub make_us_up_the_stripes { ## thar be 13 stripes, 7 red, and 6 white my ($CANVAS) = shift; for(0..12) { printf "%s\n", my $color = ( ($_ % 2) == 0 ) ? "red" : "white"; printf "%s\n", $CANVAS->create('rectangle', 1, ( $_ * 26+ 1), 609 , ( ( $_ * 26 ) + 26 + 1), -fill => $color, ,); } }