Difference between revisions of "StaticImages"
m |
(added historical tag and gave updated problem link) |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/StaticImages.html a newer version of this problem]</p> |
||
<h2>Static Graphic Images: PG Code Snippet</h2> |
<h2>Static Graphic Images: PG Code Snippet</h2> |
||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This code snippet shows the essential PG code to insert a static (pre-generated) graphic image into a problem. Note that these are <b>insertions</b>, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.</em> |
||
+ | <em>The instructions below seem out-of-date. See discussion using [@ ... @]* in https://webwork.maa.org/moodle/mod/forum/discuss.php?d=3287 which works. |
||
+ | |||
+ | OLD: |
||
+ | This code snippet shows the essential PG code to insert a static (pre-generated) graphic image into a problem. Note that these are <b>insertions</b>, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.</em> |
||
</p> |
</p> |
||
<p style="text-align:center;"> |
<p style="text-align:center;"> |
||
Line 21: | Line 27: | ||
\{ image( "imagename.png", width=>150, height=>150, |
\{ image( "imagename.png", width=>150, height=>150, |
||
− | tex_size=> |
+ | tex_size=>700, extra_html_tags=>'alt="Graph of a function."' ) \} |
− | \{ imageRow( ["graph1.png","graph2.png"], ["A","B"], width=>100, height=>150 ) \} |
||
END_TEXT |
END_TEXT |
||
Line 29: | Line 34: | ||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
− | Here it's easy: we just use the <code>image</code> macro in the text section of the problem to include the image. The images to be included should be GIF or PNG files. PNG files are recommended since they generally look better when rescaled. In order for PDF hardcopy generation to work properly, the names of image files must have only one period in them (imagename.png works but image.name.png does not). |
+ | Here it's easy: we just use the <code>image</code> macro in the text section of the problem to include the image. The images to be included should be GIF or PNG or JPG files. PNG files are recommended since they generally look better when rescaled. In order for PDF hardcopy generation to work properly, the names of image files must have only one period in them (imagename.png works but image.name.png does not). PDF files will work on hardcopy but do not immediately render in the browser without first clicking on the image box. In this case, the use of alternate text is needed. |
− | </p> |
||
− | <p> |
||
− | The <code>imageRow</code> function works similarly. Its second argument, <code>["A","B"]</code>, is a list of caption names. The double quotes in caption names are necessary to prevent E from being interpreted as 2.718... |
||
</p> |
</p> |
||
<p> |
<p> |
||
Line 35: | Line 40: | ||
</p> |
</p> |
||
<p> |
<p> |
||
− | We |
+ | We should always, of course, include options such as specifying the <code>tex_size</code>, etc., in this call, as shown in the [[DynamicImages|including dynamic images]] code snippet. Taking the <code>tex_size => "667"</code> and dividing by 10 results in the percentage of the available space used by the graphic -- in this case 66.7 percent. Usually the available space is constrained by the width of one column of a two-column printed page. |
</p> |
</p> |
||
<p> |
<p> |
Latest revision as of 09:48, 29 June 2023
This problem has been replaced with a newer version of this problem
Static Graphic Images: PG Code Snippet
The instructions below seem out-of-date. See discussion using [@ ... @]* in https://webwork.maa.org/moodle/mod/forum/discuss.php?d=3287 which works. OLD: This code snippet shows the essential PG code to insert a static (pre-generated) graphic image into a problem. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
PG problem file | Explanation |
---|---|
BEGIN_TEXT \{ image( "imagename.png" ) \} \{ image( "imagename.png", width=>150, height=>150, tex_size=>700, extra_html_tags=>'alt="Graph of a function."' ) \} END_TEXT |
Here it's easy: we just use the
For each PG problem with static images, you should put both the PG file and the image files into their own separate subdirectory. This subdirectory should be located somewhere under the course
We should always, of course, include options such as specifying the (When the alias() command in dangerousMacros.pl is rewritten in the future, support for JPG, PDF, and SWF files should become available.) |