ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Axel Kielhorn <tex@axelkielhorn.de>
To: ntg-context <ntg-context@ntg.nl>
Subject: [NTG-context] Touch my cow: Overlaying a picture with links to text
Date: Thu, 9 Jan 2025 20:29:21 +0100	[thread overview]
Message-ID: <60DA94CE-C196-45F1-901E-071D26393E25@axelkielhorn.de> (raw)

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
___________________________________________________________________________________

             reply	other threads:[~2025-01-09 19:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 19:29 Axel Kielhorn [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60DA94CE-C196-45F1-901E-071D26393E25@axelkielhorn.de \
    --to=tex@axelkielhorn.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).