[NTG-context] Re: text width shadow background

2023-07-09 Thread Keith McKay
Well this is fun.  Getting the right patterns could make some 
interesting with fonts.


Thanks for the tip Hans!

Best Wishes

Keith McKay

%

\startMPpage
vardef tst (expr x, y, i, n) =
definecolor [ name = "MyColor1", r = uniformdeviate(1), g = 
uniformdeviate(1), b = uniformdeviate(1) ] ;
definecolor [ name = "MyColor2", r = uniformdeviate(1), g = 
uniformdeviate(1), b = uniformdeviate(1) ] ;

draw lmt_outline [
text = "\TeX",
kind = "both",
fillcolor = "MyColor1",
drawcolor = "MyColor2",
rulethickness = 1/2,
]ysized (30+5*i/n) shifted (10x,10y) 
rotatedaround(origin,uniformdeviate(360));

enddef ;
picture p ; p := lmt_outline [
text = "\bf TEST",
kind = "path",
] scaled 5cm;
path q ; q := for i within p :
if picture i :
pathpart i &&
fi endfor cycle ;
picture r; r:= lmt_poisson [
width = 20,
height = 20,
distance = 1,
count = 10,
macro = "tst"
arguments = 4,
] xsized 6cm ;
draw q
withpattern
r
withpatternscale (1/10,1/3)
;
\stopMPpage

On 09/07/2023 18:37, Hans Hagen via ntg-context wrote:

On 7/9/2023 5:56 PM, Henning Hraban Ramm wrote:

Am 09.07.23 um 15:49 schrieb Keith McKay:

Hraban (and others),

You got me thinking so I added this code to end of your code as a 
bit of fun. It's code from the luametafun manual to which I added 
two and a half lines.


That’s funny.
I replaced the text by \TeX and published it here: 
https://fosstodon.org/@context/110684919994406565


But is it possible to fill a path (e.g. an lmt_outline) with a 
lmt_poisson pattern?

Here's something to get you and Keith starting:

\startMPpage
picture p ; p := lmt_outline [
    text = "\bf TEST",
    kind = "path",
] ;

path q ; q := for i within p :
    if picture i :
    pathpart i &&
    fi endfor cycle ;

draw q
    withpattern
    textext("\TEX")
    withpatternscale (1/20,1/20)
    ;
\stopMPpage

so the trick is to come up with a pattern that has the right size

Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-

___ 

If your question is of interest to others as well, please add an entry 
to the Wiki!


maillist : ntg-context@ntg.nl / 
https://www.ntg.nl/mailman/listinfo/ntg-context

webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
__
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: text width shadow background

2023-07-09 Thread Hans Hagen via ntg-context

On 7/9/2023 5:56 PM, Henning Hraban Ramm wrote:

Am 09.07.23 um 15:49 schrieb Keith McKay:

Hraban (and others),

You got me thinking so I added this code to end of your code as a bit 
of fun. It's code from the luametafun manual to which I added two and 
a half lines.


That’s funny.
I replaced the text by \TeX and published it here: 
https://fosstodon.org/@context/110684919994406565


But is it possible to fill a path (e.g. an lmt_outline) with a 
lmt_poisson pattern?

Here's something to get you and Keith starting:

\startMPpage
picture p ; p := lmt_outline [
text = "\bf TEST",
kind = "path",
] ;

path q ; q := for i within p :
if picture i :
pathpart i &&
fi endfor cycle ;

draw q
withpattern
textext("\TEX")
withpatternscale (1/20,1/20)
;
\stopMPpage

so the trick is to come up with a pattern that has the right size

Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: text width shadow background

2023-07-09 Thread Henning Hraban Ramm

Am 09.07.23 um 15:49 schrieb Keith McKay:

Hraban (and others),

You got me thinking so I added this code to end of your code as a bit of 
fun. It's code from the luametafun manual to which I added two and a 
half lines.


That’s funny.
I replaced the text by \TeX and published it here: 
https://fosstodon.org/@context/110684919994406565


But is it possible to fill a path (e.g. an lmt_outline) with a 
lmt_poisson pattern?


Hraban

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: text width shadow background

2023-07-08 Thread Henning Hraban Ramm
Please, can you explain why the result of lmt_outline is shifted to the 
right, if I use it in a macro?



"""
\setupbodyfont[ss,24pt]
\definecolor[tshade][t=.05,a=1,k=1]

\starttexdefinition MyCaption #1
\startMPcode
steps := 5 ; % number of shadow layers
rulesize := BodyFontSize/steps/3;
for step = 1 upto steps:
draw lmt_outline [
text = "\bf\strut #1",
kind = "fillup",
fillcolor = "tshade",
rulethickness = (step*rulesize),
];
endfor;
draw lmt_text [
text = "\bf\strut #1",
%style = "bold",
color = "white",
] yshifted (BodyFontSize*2/3); % TODO
\stopMPcode
\stoptexdefinition


\starttext

% this is OK
\startMPcode
draw lmt_outline [
text = "\bf\strut The quick brown fox jumps over the lazy dog.",
kind = "fillup",
fillcolor = "blue",
rulethickness = 2,
];
\stopMPcode

% here the shadow gets a different offset each time –
% the longer the text, the bigger the offset

\MyCaption{The quick brown fox jumps over the lazy dog.}

\MyCaption{Eine wunderschöne Bildunterschrift}

\MyCaption{Ein ganz anderer Text}

\stoptext
"""

BTW I recognized I need this not only for captions within images but 
also for the glow effect in the CCCamp23 style:

https://events.ccc.de/camp/2023/infos/styleguide.html

InDesign etc. create for stuff like this a pixel image including the 
background – we can do better and keep this vector-only. ;)


Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___

[NTG-context] Re: text width shadow background

2023-07-06 Thread Henning Hraban Ramm

Am 06.07.23 um 21:27 schrieb Henning Hraban Ramm:

* I don’t understand why the white fill is not opaque.


Posted too early. I do understand now (overlapping outlines).
Tried to fix it by overwriting the text again in white, but now I don’t 
understand how to calculate the shifting:


"""
\setupbodyfont[ss,24pt]
\definecolor[tshade][t=.05,a=1,k=1]

\starttexdefinition MyCaption #1
\startMPcode{doublefun}
steps := 10 ;
rulesize := BodyFontSize/steps/3;
for step = 1 upto steps:
draw lmt_outline [
text = "\bf #1",
%style = "bold", % doesn’t work
kind = "both",
fillcolor = "white",
drawcolor = "tshade",
rulethickness = (step*rulesize),
] xshifted -193; % why is this shifted at all?
endfor;
draw lmt_text [
text = "#1",
style = "bold",
color = "white",
] yshifted (steps*rulesize);
\stopMPcode
\stoptexdefinition

\starttext

\MyCaption{Eine wunderschöne Bildunterschrift}

\MyCaption{Ein ganz anderer Text}

\stoptext
"""

Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___