Class to use an image with background-clip

56 views
Skip to first unread message

taale...@gmail.com

unread,
Nov 8, 2021, 2:52:06 PM11/8/21
to TiddlyWiki
I'm trying to make a class that will allow me to fill text with an image. For example, making a drop cap for a manuscript-inspired theme that looks like it's been gilded, by using an image of gold leaf.

The interwebz tell me that I want to use background-clip, but I'm not sure how to set that up in a CSS class. Does anyone have any pointers?

All I have so far, which doesn't work (and I didn't think it would):

.dropcap { font-size: 40px;
margin: 10pc;
border: 5px double black;
float: left; background-image: url(<$macrocall $name="datauri" title="paua.jpg" $output="text/plain"/>) background-clip: text; }

Thanks,
Aidan

Charlie Veniot

unread,
Nov 8, 2021, 7:08:23 PM11/8/21
to TiddlyWiki
G'day Aidan,

What text?  Where is the text?  Do you mean all of the content showing in a tiddler?

Or just the text in a specific area in a tiddler?

Aidan Grey

unread,
Nov 8, 2021, 7:42:31 PM11/8/21
to TiddlyWiki
Yeah, it was text that I would apply the class to. I've since realized that there will at least have to be several different classes depending on where it is i.e. styling the titles will be different than styling buttons or in a tiddler, etc. since the backgrounds and such will need to be in different dom locations.

I want to gild titles, the editor buttons (of all the varieties), drop caps, bits and bobs on sidebars, and on demand for specific words or icons in the tiddler on demand, so to speak. 

I'm also planning to use the same technique for a different theme, based on a Tlingit soulcatcher, which is usually a carved and styled bone with inlays of mother of pearl (hence the paua.jpg).

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/13f105b9-b296-4652-9e6d-b881b42b12fen%40googlegroups.com.

Mat

unread,
Nov 8, 2021, 8:09:05 PM11/8/21
to TiddlyWiki
This works on tiddlywiki.com


<style>
.jack {
  font-size: 72px;
  background: url(<$macrocall $name="datauri" title="Motovun Jack.jpg" $output="text/plain"/>);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
</style>

<div class="jack">

!GOLD
</div>

<:-)

Aidan Grey

unread,
Nov 8, 2021, 8:34:47 PM11/8/21
to TiddlyWiki
Well, that works for me too Mat - as long as I use inline HTML/CSS like you did above. 

But if I use the TW class caller (I can't think of the word) like this, no bueno, empty tiddler: 

@@.jack
!!JACK
@@

Which I suppose answers my question. Everything has to be styled in line, classes won't work here.


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

Charlie Veniot

unread,
Nov 8, 2021, 9:01:28 PM11/8/21
to TiddlyWiki
Is this what you are looking for?

Download attached json and drag it into tiddlywiki.com to try/analyze.
GoldLeafTester.json

Aidan Grey

unread,
Nov 8, 2021, 9:13:49 PM11/8/21
to TiddlyWiki
Thanks Mat and Charlie!

So, it looks like I CAN create the class, but have to call it in a span/div to apply it. 

Which is better than I was expecting, because It was looking like I'd have to copy/paste the css into every relevant bit.

Thanks a ton!!





Charlie Veniot

unread,
Nov 8, 2021, 9:33:03 PM11/8/21
to TiddlyWiki
Good stuff !

There are so many ways of applying a particular style to a specific bit of text.

Myself, considering the example I gave in the attachment ...

I'd probably prefer do this:  {{ Whatever Text || tGoldLeaf }}, or the shorter version {{ Whatever Text || tGL }}.

Try the attached. 

GoldLeafTester.json

Aidan Grey

unread,
Nov 8, 2021, 10:20:07 PM11/8/21
to TiddlyWiki
Thanks! I don't think the transclusion is gonna work, given what I wanna do, but it's a possibility.

By the way

<span class="goldleaf">JACK</span>
!! This Heading

EVERYTHING is gilded, including the "This Heading" - any thoughts on why?


Charlie Veniot

unread,
Nov 8, 2021, 10:24:44 PM11/8/21
to TiddlyWiki
Yeah, sneak a peek at the CSS file included in the attached.

You'll see that I added a little something there to make H2 adopt the CSS style, just to show folk the ability to set all instances of a particular element with a custom style.

Aidan Grey

unread,
Nov 8, 2021, 10:26:58 PM11/8/21
to TiddlyWiki
Oh, durr.  I did see that.  Sorry. 

Charlie Veniot

unread,
Nov 8, 2021, 10:27:57 PM11/8/21
to TiddlyWiki
BTW, the neat thing about a transclusion is that there doesn't have to be an existing tiddler related to the transclusion.

The template tiddler just assumes that there exists a related tiddler and trucks along.

On Monday, November 8, 2021 at 11:20:07 PM UTC-4 taale...@gmail.com wrote:

Mat

unread,
Nov 9, 2021, 3:50:09 AM11/9/21
to TiddlyWiki
I didn't look at Charlies solution but I don't get any problem putting the styleblock I proposed in a dedicated stylesheet tiddler, and then applying e.g like so:

asdf @@.jack
!GOLD
@@asdf

! This Heading

<:-)

Mat

unread,
Nov 9, 2021, 4:35:42 AM11/9/21
to TiddlyWiki
By the way, I found this for making the background image animate. If you want the gold to "shine" that might be a solution. My experience with "gold color" is that it typically appears too static, missing out on the very goldy appearance one wants. Especially so for smaller areas.

To make an image appropriate for infinite spinning, the linked solution has used this image, i.e a mirrored image. Clever.

<:-)

Reply all
Reply to author
Forward
0 new messages