* [NTG-context] Touch my cow: Overlaying a picture with links to text
@ 2025-01-09 19:29 Axel Kielhorn
[not found] ` <b07d5924-2f22-44a3-9f22-601ab6803f14@xs4all.nl>
0 siblings, 1 reply; 3+ messages in thread
From: Axel Kielhorn @ 2025-01-09 19:29 UTC (permalink / raw)
To: ntg-context
Hello,
I’m trying to make our documentation more interactive.
So far I managed to turn the labels in the picture into links.
The next step would be to mark certain areas in the picture.
When the reader clicks on these areas, they will follow the link.
This is where I am so far:
% !TEX TS-program = ConTeXt (LMTX)
\setupinteraction[state=start, color=middleblue]
\placebookmarks[section]
\setupexternalfigures[location=default]
\starttext
\startMPinclusions
color mycolor;
def gridscaled =
pair ur;
ur = urcorner currentpicture;
width := xpart ur;
height := ypart ur;
xstep := ceiling(width / 10);
ystep := ceiling(height / 10);
enddef;
% Bottom: The annotation is at the bottom of the start point
def annotb (expr a, b, c, d) (text t) =
label.bot ("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{" & t &"}", (a * xstep, b * ystep));
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .8mm withcolor white;
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .5mm withcolor mycolor;
enddef ;
% Top: The annotation is on top of the start point
def annott (expr a, b, c, d) (text t) =
label.top ("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{" & t &"}", (a * xstep, b * ystep));
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .8mm withcolor white;
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .5mm withcolor mycolor;
enddef ;
% Right: The annotation is on the right of the start point
def annotr (expr a, b, c, d) (text t) =
label.rt (t, (a * xstep, b * ystep));
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .8mm withcolor white;
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .5mm withcolor mycolor;
enddef ;
% Left: The annotation is on the left of the start point
def annotl (expr a, b, c, d) (text t) =
label.lft (t, (a * xstep, b * ystep));
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .8mm withcolor white;
drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
withpen pencircle scaled .5mm withcolor mycolor;
enddef ;
% touchtolink
def touchtolink (expr a, b) (text t) =
label ("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{" & t &"}", (a * xstep, b * ystep));
enddef ;
\stopMPinclusions
\startMPpage
% Picture
draw externalfigure "cow.pdf" xsized 16cm;
% Grid
gridscaled;
% Text
annotb (1, 5, .8, 7.3, "\goto{Maul}[Maul]");
touchtolink (.8, 7.3, "\goto{\blackrule[height=2cm, width=4cm, color=transparentwhite]}[Maul]");
annotb (6, 2, 7, 3.2, "\goto{Euter}[Euter]");
annott (9.2, 9.5, 9.6, 3, "Schwanz");
annotb (3, -.5, 3.1, .9, "\goto{Huf}[Huf]");
annotb (3, -.5, 3.9, 1.1, "");
\stopMPpage
\startsection[
title={Das Maul},
reference=Maul,
bookmark={Maul},
]
Lorem ipsum dolor
\stopsection
\startsection[
title={Die Hufe},
reference=Huf,
bookmark={Huf},
]
Lorem ipsum dolor
\stopsection
\startsection[
title={Das Euter},
reference=Euter,
bookmark={Euter},
]
Lorem ipsum dolor
\stopsection
\stoptext
%%%%
I filled the area with a \blackrule, which is transparent and the link works.
Only problem the frame is filled with the link color, in this case blue.
How do I suppress the color for this link only?
Adding [color=transparentwhite] to the \goto command didn’t help.
Is there a more elegant way to define this area?
Greetings from the snowy pastures of northern Germany
Axel
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* [NTG-context] Fwd: Touch my cow: Overlaying a picture with links to text
[not found] ` <b07d5924-2f22-44a3-9f22-601ab6803f14@xs4all.nl>
@ 2025-01-10 0:10 ` Hans Hagen
2025-01-11 13:52 ` [NTG-context] " Axel Kielhorn
1 sibling, 0 replies; 3+ messages in thread
From: Hans Hagen @ 2025-01-10 0:10 UTC (permalink / raw)
To: mailing list for ConTeXt users
-------- Forwarded Message --------
Subject: Re: [NTG-context] Touch my cow: Overlaying a picture with links
to text
Date: Fri, 10 Jan 2025 01:09:47 +0100
From: Hans Hagen <j.hagen@xs4all.nl>
To: Axel Kielhorn <tex@axelkielhorn.de>
On 1/9/2025 8:29 PM, Axel Kielhorn wrote:
> Hello,
>
> I’m trying to make our documentation more interactive.
>
> So far I managed to turn the labels in the picture into links.
>
> The next step would be to mark certain areas in the picture.
> When the reader clicks on these areas, they will follow the link.
>
> This is where I am so far:
>
> % !TEX TS-program = ConTeXt (LMTX)
>
> \setupinteraction[state=start, color=middleblue]
> \placebookmarks[section]
>
> \setupexternalfigures[location=default]
> \starttext
>
> \startMPinclusions
>
> color mycolor;
>
> def gridscaled =
> pair ur;
> ur = urcorner currentpicture;
> width := xpart ur;
> height := ypart ur;
> xstep := ceiling(width / 10);
> ystep := ceiling(height / 10);
> enddef;
> % Bottom: The annotation is at the bottom of the start point
> def annotb (expr a, b, c, d) (text t) =
> label.bot ("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{" & t &"}", (a * xstep, b * ystep));
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .8mm withcolor white;
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .5mm withcolor mycolor;
> enddef ;
> % Top: The annotation is on top of the start point
> def annott (expr a, b, c, d) (text t) =
> label.top ("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{" & t &"}", (a * xstep, b * ystep));
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .8mm withcolor white;
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .5mm withcolor mycolor;
> enddef ;
> % Right: The annotation is on the right of the start point
> def annotr (expr a, b, c, d) (text t) =
> label.rt (t, (a * xstep, b * ystep));
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .8mm withcolor white;
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .5mm withcolor mycolor;
> enddef ;
> % Left: The annotation is on the left of the start point
> def annotl (expr a, b, c, d) (text t) =
> label.lft (t, (a * xstep, b * ystep));
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .8mm withcolor white;
> drawarrow (a * xstep, b * ystep) -- ( c * xstep, d * ystep)
> withpen pencircle scaled .5mm withcolor mycolor;
> enddef ;
> % touchtolink
> def touchtolink (expr a, b) (text t) =
> label ("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{" & t &"}", (a * xstep, b * ystep));
> enddef ;
> \stopMPinclusions
>
> \startMPpage
> % Picture
> draw externalfigure "cow.pdf" xsized 16cm;
> % Grid
> gridscaled;
> % Text
> annotb (1, 5, .8, 7.3, "\goto{Maul}[Maul]");
> touchtolink (.8, 7.3, "\goto{\blackrule[height=2cm, width=4cm, color=transparentwhite]}[Maul]");
> annotb (6, 2, 7, 3.2, "\goto{Euter}[Euter]");
> annott (9.2, 9.5, 9.6, 3, "Schwanz");
> annotb (3, -.5, 3.1, .9, "\goto{Huf}[Huf]");
> annotb (3, -.5, 3.9, 1.1, "");
>
> \stopMPpage
>
>
> \startsection[
> title={Das Maul},
> reference=Maul,
> bookmark={Maul},
> ]
> Lorem ipsum dolor
> \stopsection
>
> \startsection[
> title={Die Hufe},
> reference=Huf,
> bookmark={Huf},
> ]
> Lorem ipsum dolor
> \stopsection
>
> \startsection[
> title={Das Euter},
> reference=Euter,
> bookmark={Euter},
> ]
> Lorem ipsum dolor
> \stopsection
>
> \stoptext
> %%%%
>
> I filled the area with a \blackrule, which is transparent and the link works.
> Only problem the frame is filled with the link color, in this case blue.
>
> How do I suppress the color for this link only?
> Adding [color=transparentwhite] to the \goto command didn’t help.
>
> Is there a more elegant way to define this area?
def touchtolink (expr a, b) (text t) =
label
("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{"
& t &"}", (a * xstep, b * ystep));
enddef ;
but you forgot to define:
\definecolor[transparentwhite][s=1,t=.5,a=1]
> Greetings from the snowy pastures of northern Germany
> Axel
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
--
-----------------------------------------------------------------
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://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* [NTG-context] Re: Touch my cow: Overlaying a picture with links to text
[not found] ` <b07d5924-2f22-44a3-9f22-601ab6803f14@xs4all.nl>
2025-01-10 0:10 ` [NTG-context] Fwd: " Hans Hagen
@ 2025-01-11 13:52 ` Axel Kielhorn
1 sibling, 0 replies; 3+ messages in thread
From: Axel Kielhorn @ 2025-01-11 13:52 UTC (permalink / raw)
To: ntg-context
> Am 10.01.2025 um 01:09 schrieb Hans Hagen <j.hagen@xs4all.nl>:
>
>
> def touchtolink (expr a, b) (text t) =
> label ("\framed[background=color,backgroundcolor=transparentwhite,align=normal,corner=00,frame=no]{" & t &"}", (a * xstep, b * ystep));
> enddef ;
>
> but you forgot to define:
>
> \definecolor[transparentwhite][s=1,t=.5,a=1]
It seems I cut too many lines when making my example minimal.
Thanks, this is exactly what I needed.
> luametafun-mesh.tex
> might be interesting
It says it only works with Acrobat and it doesn’t work with preview.
Greetings Axel
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-11 13:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-09 19:29 [NTG-context] Touch my cow: Overlaying a picture with links to text Axel Kielhorn
[not found] ` <b07d5924-2f22-44a3-9f22-601ab6803f14@xs4all.nl>
2025-01-10 0:10 ` [NTG-context] Fwd: " Hans Hagen
2025-01-11 13:52 ` [NTG-context] " Axel Kielhorn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).