Forum archive 2000-2006

Michael Gage - simple_drawing.pg

Michael Gage - simple_drawing.pg

by Arnold Pizer -
Number of replies: 0
inactiveTopicsimple_drawing.pg topic started 3/24/2003; 8:11:35 PM
last post 3/24/2003; 8:11:35 PM
userMichael Gage - simple_drawing.pg  blueArrow
3/24/2003; 8:11:35 PM (reads: 566, responses: 0)
This is an example of doing very simple drawing using WWPlot.pm directly. More complicated constructions can be constructed by using the properties described in the file GD.pm on CPAN.

The object created by

$graph = init_graph(-5,5,5,5);

has the GD object

$graph->im()

as it's drawing canvas.

 



gage-1234-setMAAtutorialprob1image1.png

 

 


WARNINGS
µ¦å{h­
##DESCRIPTION
## A very simple drawing problem
##ENDDESCRIPTION

##KEYWORDS('algebra')

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGgraphmacros.pl",
"PGauxiliaryFunctions.pl"
);


$graph = init_graph(-5,-5,5,5,ticks=>[4,4],axes=>[0,0],pixels=>[400,400]);

$graph->moveTo(-2,1);
$graph->lineTo(2,2,'blue');
$graph->lineTo(-1,2,'red');
$graph->lineTo(-2,1,'green');
$graph->fillRegion([0,1.7,'yellow']);
BEGIN_TEXT
\{image(insertGraph($graph),width=>400,height=>400)\}


END_TEXT

# At the moment there is no easy way to change the weight of the lines being drawn. To do so one would want
# to incorporate some of the code in Fun.pm into WWPlot.pm itself. The code involves gdBrushed.
# Since GD has
# gone through many revisions since the WWPlot.pm code was written it may now be possible to write some of
# this code more efficiently.



ENDDOCUMENT(); # This should be the last executable line in the problem.


<| Post or View Comments |>