Login
Remember
IF Answers
Ask a Question

# Centering an image in Inform 7

+2 votes
119 views
asked Aug 18 in Authoring by borabosna (11 points)

Using Basic Screen Effects by Emily Short I am able to center text very easily like this:

    center "this is some text I want centered.";

This is so easy and so wonderful.

Say I am displaying an image called the figure of the ocean by using:

    display the figure of the ocean;

Is there an EASY way to display that image centered, like the text?

- inform7
- authoring

## 1 Answer

+1 vote
answered Aug 18 by bg (692 points)
edited Aug 18 by bg

Hmm. According to §23.6. in the manual,

    display (figure name)

"causes the figure to be displayed in the centre of the screen visible to the player."

But when I try it, it doesn't center the image--it just puts it on the left side. Is that what it does for you? Maybe it's an Inform bug.

EDIT: Ok, from what Draconis said here, you have to include an extension in order to center the image. But the built-in extension that's supposed to do this needs updating. Here's the bug report.

If you don't want to wait for the bug to be fixed, there might be a way to update the extension yourself, and this answer might be of help.

I don't know how one goes about modifying a built-in extension, though.

commented Aug 19 by borabosna (11 points)
edited Aug 19 by borabosna
Yes, it puts the image on the left. I guess I will just have to do with the left image then.
EDIT: I was able to modify the two extensions "Glulx Image Centering by Emily Short" and "Glulx Text Effects by Emily Short" to make it work. Inform does not allow editing a built-in extension but it allows me to save the edited extension in the Inform folder under My Documents/Extensions/(author name) and then uses that version instead of the built-in one.
In "Glulx Image Centering" I changed the table "Table of User Styles (continued) to:
Table of User Styles (continued)
style name justification obliquity indentation first line indentation boldness fixed width relative size
special-style-1 center-justified false 0 0 regular-weight true 0
In "Glulx Text Effects" I changed the table "Table of User Styles" to:
Table of User Styles
style name (a glulx text style) background color (a text) color (a text) first line indentation (a number) fixed width (a truth state) font weight (a font weight) indentation (a number) italic (a truth state) justification (a text justification) relative size (a number) reversed (a truth state) obliquity (a truth state) boldness (a font weight)
with 1 blank row
Now, using
display the figure of the ocean centered;
displays the image centered!
commented Aug 19 by Ryan Veeder (290 points)
I spent about an hour and a half last night trying to figure this out. I didn't realize I also had to edit Glulx Text Effects.
But the upshot is that I'm super impressed with your success! Nice job!!!
commented Aug 20 by borabosna (11 points)
Thanks Ryan! I'm glad my solution helped you out. I believe there is an even simpler solution, just deleting "obliquity" and "boldness" columns from "Table of User Styles (continued)" in Glulx Image Centering should do the job; so editing Glulx Text Effects may be unnecessary after all.
commented Aug 20 by Dannii (329 points)
You only need to include the relevant columns, so Glulx Image Centering should be edited to just have 'style name' and 'justification'.

## Related questions

- Why aren't "if" and "otherwise" doing what I expected in Inform 7?
- Using the Flexible Windows extension, how can I depict a scaled image in my graphics window?
- Is there an easy way to loop text in Inform 7?
- How can I prevent appending (open), (closed) etc. to an object in Inform 7?
- [Inform 7] How to implement a blanket 'not understood' comment for an Inanimate Listener

...