Working with CSS in certain ways in Harlowe can be very complicated. The following example will do what you asked, but it might not be what you want.
(link-repeat: "Show Image") [
(set: $imageOpacity to 1)
(live: 0.5s)[
(css: "opacity: " + (text: $imageOpacity) )[<img src="https://twinery.org/homepage/img/logo.svg" width="200" height="200">]
(set: $imageOpacity to $imageOpacity - 0.10)
(if: $imageOpacity <= 0)[
(set: $imageOpacity to 1)
(stop:)
]
]
]
First, (set: $imageOpacity to 1)
is used to set $imageOpacity
to 1. CSS opacity has a range from 0 to 1. Since you asked about moving from 100% to 0%, that’s the start: 1 (100%).
Next, the (live:)
macro is used. This creates a looping structure based on time. It is given the argument “0.5s”, which means 0.5 seconds. Every 0.5 seconds, everything within the hook associated with the macro will run. (And will keep running until it encounters the (stop:)
macro.)
Next, the (css:)
macro is used. This applies the “styles” given to it on an associated hook. Inside of the macro is another, (text:)
. This converts a number into a string, a collection of letters and numbers enclosed in quotation marks. The full line, then, takes $imageOpacity
, a number, converts it into a string, and then uses it as part of (css:)
to apply the “opacity” rule to a hook.
In this example, the hook contains an image. As part of the question, this is where another image would go.
After that is another (set:)
macro. This changes the value of $imageOpacity
by 0.10 each loop. Since the movement is from 100% to 0%, this decreases the opacity each loop by 10%.
Next is the stopping condition. Since (live:)
will contain to run forever, it needs some code to stop it at some point. The use of the (if:)
macro tests to see if $imageOpacity
is less than or equal to 0. If so, it runs its contents.
Within the (if:)
macro is the value of $imageOpacity
is reset to 1 and the (stop:)
macro is finally used. This ends the loop.
Around all of this code is the use of the (link-repeat:)
macro. Clicking its link text once will start the (live:)
looping, which will, itself, end once enough loops happen to decrease the value of $imageOpacity
below 0.
Why (link-repeat:)
is probably not what you want
All that written, you probably don’t want to use (link-repeat:)
for this. Why? Because, as per its documentation, it “appends”. This means that each re-run of the link adds an image, loops until the opacity is below 0, and then ends. Clicking the link again adds another image and starts the cycle over again. Perhaps this is what you want, but probably not.