3

I am trying to fill a portion near point 0 of a circularpath.

path circle ; circle = circularpath(10) scaled 200 ;
pair a, b ; a = point 35 of circle ; b := point 5 of circle ;

fill buildcycle((origin--a), (origin--b), circle) withcolor lightgray ; draw circle ; dotlabel.top("A", a) ; dotlabel.top("B", b) ;

I tried any possible combinations I can thought on buildcycle arguments and reverse it all, but it always gives the following wrong output:

Indeed, my goal here is to swap the colors and to have only the small area in gray.

How can I achieve that?

  • 1
    As noted in the answers, you don't need buildcycle. But if you are curious to understand why it gives you the "wrong" segment, see here: https://tex.stackexchange.com/a/236226/15036 – Thruston Oct 21 '22 at 15:18
  • Thank you! Thanks to this comment and your answer where you use numerics, I managed to understand that it is also possible to use negative numbers to do it. For example, if we use your (or mickep) answer and apply it to my question by setting a to -5 (point 35 of circularpath(10)) and b to 5 (point 5 circularpath(10)) in order to apply fill origin -- subpath (a, b) of circle -- cycle, then we get the correct result. –  Oct 21 '22 at 16:58

2 Answers2

3

No need for buildcycle here.

I've simplified slightly to make it work with plain MP, but this should also work in Context with the metafun format.

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
path circle; 
circle = fullcircle scaled 200;

numeric a, b; a = 3; b = 1; fill origin -- subpath (a, b) of circle -- cycle withcolor 7/8;

draw circle; dotlabel.ulft("A", point a of circle); dotlabel.urt("B", point b of circle); endfig; \end{mplibcode} \end{document}

Compile this with lualatex (or adapt for your environment) to get this:

enter image description here

Thruston
  • 42,268
1

I have never really understood how buildcycle is working. In this case, you do not need it. You could try something like this:

\startMPpage[offset=1dk]
path circle ; circle := fullcircle scaled 200 ;
z[0] = point 1 of circle ;
z[1] = point 3 of circle ;

fill subpath(1,3) of circle -- origin -- cycle withcolor lightgray ; draw circle ; freedotlabel("B", z[0],origin) ; freedotlabel("A", z[1],origin) ; \stopMPpage

Since you seem to use MetaFun, I have also changed your dotlabels to freedotlabels.

cake result

mickep
  • 8,685