Skip to content

Instantly share code, notes, and snippets.

@dk

dk/1

Created July 15, 2014 10:58
Show Gist options
  • Save dk/502a4ffc99997f122f57 to your computer and use it in GitHub Desktop.
Save dk/502a4ffc99997f122f57 to your computer and use it in GitHub Desktop.
diff --git a/examples/analog_clock.pl b/examples/analog_clock.pl
index 9a9ef17..b40da48 100644
--- a/examples/analog_clock.pl
+++ b/examples/analog_clock.pl
@@ -85,23 +85,24 @@ my($width, $height);
my $w = Prima::MainWindow->new(
text => 'Analog clock',
size => [300,300],
+ buffered => 1,
onPaint => sub {
#on paint event
+ my ($self,$canvas) = @_;
+ $canvas->clear;
+ my @size = $canvas->size;
+ ($width, $height) = @size;
+ my $cr = $canvas->cairo_context( transform => 0 );
+ my $matrix = Cairo::Matrix->init_identity;
+ $cr->scale($size[0]/300, $size[1]/300);
+ $cr->transform($matrix);
+ create_image($cr);
},
onCreate => sub {
my $timer = $_[0]->insert( Timer => timeout => 1000, name => 'Timer',
onTick => sub {
- my $canvas = $_[0]->owner;
- $canvas->clear;
- my @size = $canvas->size;
- ($width, $height) = @size;
- my $cr = $canvas->cairo_context( transform => 0 );
- my $matrix = Cairo::Matrix->init_identity;
- $cr->scale($size[0]/300, $size[1]/300);
- $cr->transform($matrix);
- create_image($cr);
- }
- );
+ $_[0]->owner->repaint;
+ });
$timer->start;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment