ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Fabrice Couvreur <fabrice1.couvreur@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Code lua in a table
Date: Tue, 21 Jul 2020 15:08:59 +0200	[thread overview]
Message-ID: <CACyK-erH=KgYxr1Kmf5j=SRFbaV1nbA58t7mGWE=tiPkfO6Jqw@mail.gmail.com> (raw)
In-Reply-To: <1d2543e2-68c6-998c-d00c-32ba3e967f41@xs4all.nl>


[-- Attachment #1.1: Type: text/plain, Size: 3617 bytes --]

Hello,
I am making progress and I almost get what I want to achieve but I still
have two problems :
how to color cells not containing numbers with the same color as the others
?
how to color in salmon, for example, cells 1 2  ?
                                                                     3
Thank you
Fabrice

\usecolors[X11]

\startuseMPgraphic{DiagonalRule}
  rulethickness := \frameddimension{rulethickness};

  drawoptions(
    withpen pencircle scaled rulethickness
    withcolor \MPcolor{\framedparameter{framecolor}});

  pair leftcorner, rightcorner;
  leftcorner  := (rulethickness, \overlayheight-rulethickness);
  rightcorner := (\overlaywidth-rulethickness, rulethickness);

  draw leftcorner -- rightcorner;
\stopuseMPgraphic

\defineoverlay
  [DiagonalRule]
  [\useMPgraphic{DiagonalRule}]

\define[2]\DiagonalLabel{%
  \setuptabulate [after={\blank[\frameddimension{offset}]}]
  \starttabulate [|p|r|]
    \NC    \NC #2 \NC\NR
    \NC #1 \NC    \NC\NR
  \stoptabulate
}


\starttext
\startluacode
   function Binom(n,k)
        if k > n then
             return ""
        elseif (n == 0 or k == 0) then
             return 1
        else
             return math.round((n*Binom(n-1,k-1))/k)
        end
      end
  context.startxtable({"align={middle,lohi},
width=1cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"})
  context.startxrow()

context.startxcell({"background=DiagonalRule,background=color,backgroundcolor=thistle2"})
  context("\\DiagonalLabel{\\m{n}}{\\m{k}}")
  context.stopxcell()
  for j = 0, 7 do
  context.startxcell({"background=color,backgroundcolor=thistle2"})
  context(j)
  context.stopxcell()
  end
  context.startxcell({"background=color,backgroundcolor=thistle2"})
  context("\\dots")
  context.stopxcell()
  context.stopxrow()
  for i = 0, 7 do
  context.startxrow()
  context.startxcell({"background=color,backgroundcolor=thistle2"})
  context(i)
  context.stopxcell()
  for j = 0, 8 do
  context.startxcell()
  context(Binom(i,j))
  context.stopxcell()
  end
  context.stopxrow()
  end
  context.startxrow()
  context.startxcell({"background=color,backgroundcolor=thistle2"})
  context("\\dots")
  context.stopxcell()
  for i = 0, 8 do
  context.startxcell({"background=color,backgroundcolor=thistle2"})
  context("")
  context.stopxcell()
  end
  context.stopxrow()
  context.stopxtable()
\stopluacode
\stoptext

Le lun. 20 juil. 2020 à 14:55, Hans Hagen <j.hagen@xs4all.nl> a écrit :

> On 7/20/2020 2:40 PM, Jeong Dal wrote:
>
> > I also wonder where is the boundary of ConTeXt.
> The boundaries are set and shift by users (the mailing list) and
> curiosity (personal).
>
> 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 /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 5836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

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

  reply	other threads:[~2020-07-21 13:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1.1595152801.23549.ntg-context@ntg.nl>
2020-07-20  5:56 ` Jeong Dal
2020-07-20  8:36   ` Hans Hagen
2020-07-20 10:13     ` Fabrice Couvreur
2020-07-20 12:40     ` Jeong Dal
2020-07-20 12:54       ` Hans Hagen
2020-07-21 13:08         ` Fabrice Couvreur [this message]
2020-07-18 18:05 Fabrice Couvreur
2020-07-18 18:32 ` Wolfgang Schuster
2020-07-18 20:09   ` Fabrice Couvreur
2020-07-18 20:22     ` Wolfgang Schuster
2020-07-18 20:25       ` Fabrice Couvreur
2020-07-18 20:34         ` Fabrice Couvreur
2020-07-18 20:36         ` Wolfgang Schuster
2020-07-18 21:35         ` Otared Kavian
2020-07-18 22:05           ` Otared Kavian

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='CACyK-erH=KgYxr1Kmf5j=SRFbaV1nbA58t7mGWE=tiPkfO6Jqw@mail.gmail.com' \
    --to=fabrice1.couvreur@gmail.com \
    --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).