ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] Fwd: Touch my cow: Overlaying a picture with links to text
Date: Fri, 10 Jan 2025 01:10:08 +0100	[thread overview]
Message-ID: <0bbc190d-797e-4916-b8bf-826a9731e55d@xs4all.nl> (raw)
In-Reply-To: <b07d5924-2f22-44a3-9f22-601ab6803f14@xs4all.nl>




-------- 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
___________________________________________________________________________________

  parent reply	other threads:[~2025-01-10  0:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 19:29 [NTG-context] " Axel Kielhorn
     [not found] ` <b07d5924-2f22-44a3-9f22-601ab6803f14@xs4all.nl>
2025-01-10  0:10   ` Hans Hagen [this message]
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=0bbc190d-797e-4916-b8bf-826a9731e55d@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --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).