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?

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'.
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...