--- loncom/homework/randomlylabel.pm 2007/09/25 22:56:48 1.29 +++ loncom/homework/randomlylabel.pm 2007/09/25 23:16:13 1.30 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # randomlabel.png: composite together text and images into 1 image # -# $Id: randomlylabel.pm,v 1.29 2007/09/25 22:56:48 albertel Exp $ +# $Id: randomlylabel.pm,v 1.30 2007/09/25 23:16:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -267,6 +267,23 @@ sub get_color_from_hexstring { return $imcolor; } +sub add_click { + my ($image) = @_; + + my $length=6; + my $bgcolor=&get_color_from_hexstring($image,'FFFFFF'); + my $fgcolor=&get_color_from_hexstring($image,'009999'); + + my ($x,$y) = split(':',$env{'form.clickdata'}); + + $image->setThickness(3); + $image->line($x-$length,$y, $x+$length,$y, $bgcolor); + $image->line($x, $y-$length,$x, $y+$length,$bgcolor); + $image->setThickness(1); + $image->line($x-$length,$y, $x+$length,$y, $fgcolor); + $image->line($x, $y-$length,$x, $y+$length,$fgcolor); +} + sub handler { my $r = shift; $r->content_type('image/png'); @@ -429,6 +446,7 @@ sub handler { &Apache::lonnet::logthis("randomlylabel unable to handle object of type $type"); } } + if (exists($env{'form.clickdata'})) { &add_click($image); } $image->setThickness(1); $r->print($image->png); return OK;