It looks like you're new here. If you want to get involved, click one of these buttons!
<<set $current to "forest">>
<<if $current is "forest">>[img[forest]]<<endif>>
<<if $current is "lake">>[img[lake]]<<endif>>
Be a lot nicer if I could just code:
<<set $current to "forest">>
[img[$current]]
Second thing is image maps. Each would be an array of regions in the image, each associated with a link (and, maybe, a tail).<< set $map to [ { shape: { "rect", top, left, bottom, right }, link: "forest", tail: '$link to "track"' },
{ shape: { "rect", top, left, bottom, right }, link: "lake", tail: '$link to "boat"' }
] >>
[img[areamap][$map]]
Where they click on the image determines which link, if any, gets activated.
Comments
You could have an image scene where there are characters which you can click on one and interview (if playing as a a detective for example) the passage for the conversation with that character could have a closeup of that character and play out the conversation before going back to the previous passage and click on another character etc.
These same popup bubbles could be also used with the image to display a speech or thought bubble like a comic or graphic novel. These bubbles could have an opacity value to help blend in. But maybe the speech bubble popup might be too tricky to implement. Just a thought.
So, I'm thinking of adding a "passage" attribute that you can put on HTML <a>, <img>, <map> and <area> tags. would be equivalent to [[Some text|Distant woods]], but with the advantage that extra attributes can also be included.
So would be equivalent to [img[Trees]].
What this means is that complex structures like image maps can be created through HTML, and Twine passage hyperlinks can then be added quite simply.
Note that the passage attribute would NOT appear in the rendered HTML element - it would be dynamically replaced with the code and event handlers used by normal Twine links.
What this means is that complex structures like image maps can be created through HTML, and Twine passage hyperlinks can then be added quite simply.
Note that the passage attribute would NOT appear in the rendered HTML element - it would be dynamically replaced with the code and event handlers used by normal Twine links.
OK, I've implemented this, with two changes:
1) Images now use "imgpassage" to source imported images, so that they can also link to a passage on click: 2) The "passage" and "imgpassage" attributes DO appear on the rendered HTML element, because some built-in CSS necessary to get the hand cursor working is required.
Does an image passage do anything besides generating a data URL? If not, you could create a more generic mechanism by having the user insert placeholder URLs which are replaced by data URLs on compilation: An advantage of this kind of URL replacement is that it would work for any type of embedded data, such as fonts or audio.
And if they do, should the attribute names not be preceded by "data-"?
Why would do that, rather than: In which case you wouldn't need "imgpassage" and could simply use "passage":
As brought up by greyelf, I'd suggest transforming those into data-* attributes.
I guess the reason is that I like a 1-to-1 relation between HTML attributes and Twine functionality: "passage" maps 1-to-1 with linking, and "imgpassage" maps 1-to-1 with image sourcing. But, maybe it'd be a smidge simpler if just one was present.
So, just one "data-passage" attribute it is, then.
I thought about this, but I don't really like the look of "src='passage:Tree'" - it feels like there's one layer of indirection. And, I prefer having a separate HTML attribute on the (admittedly dubious) basis that someone could CSS-select the attribute (and they couldn't with that URI because it'd be substituted at runtime).
I think we've had a misunderstanding. I was not suggesting that the actual syntax be
data-passage
. I was suggesting that as part of processing thepassage
attribute, it be replaced with thedata-passage
attribute.For example: (this is how it's currently implemented in my local SugarCube repo)
This author code: Would be transformed into: (notionally, that's not actually how the
click
event is attached)IOW, using the non-standard
passage
attribute on the author-side HTML elements is fine, however, don't pass it through to the output as-is. If having source of thepassage
attribute in the output is desirable (and I believe it is), then add a copy prefixed withdata-
and remove the original.(As currently implemented, the only DOM changes data-passage invokes are to change the src of <img>s, and alter the onclick of non-imgs (but I'm changing it to use addEventListener/attachEvent now).)