This approach seems to work fine in Git, Glulxe, and Quixe, but I’m having problems with Gargoyle. After drawing a couple of images at different scales, Gargoyle shuts down (without an error message).
This example exhibits the problem for me. It uses a 500x500 JPG image.
Gargoyle shuts down if I type IMAGE / SCALE 50 / IMAGE.
[code]Main is a room. “You are here.”
the player is in Main.
Figure F is the file “Example.jpg”.
imaging is an action out of world.
understand “image” as imaging.
carry out imaging:
draw Figure F at scale current_scale;
current_scale is a number that varies. current_scale is 100.
scale_setting is an action out of world applying to one number.
understand “scale [a number]” as scale_setting.
carry out scale_setting:
let N be the number understood;
if N < 10 or N > 300:
say “The scale must stay between 10% and 300%.”;
else:
say “Image scaling set to [N]%.”;
now current_scale is N;
w_normal is always 500.
h_normal is always 500.
to draw (F - a figure name) at scale (N - a number):
let width be w_normal;
now width is width * N;
now width is width / 100;
let height be h_normal;
now height is height * N;
now height is height / 100;
display-scaled F at width by height;
To display-scaled (F - figure name) at (W - a number) by (H - a number):
(- DisplayScaledFigure(ResourceIDsOfFigures–>{F}, {W}, {H}); -).
Include (-
[ DisplayScaledFigure id width height;
if (glk_gestalt(gestalt_Graphics, 0)) {
glk_image_draw_scaled(gg_mainwin, id, imagealign_InlineCenter, 0, width, height);
print “^”;
}
];
-)[/code]