Re: [NTG-context] Best way to apply a fill-pattern to a closed shape?

2021-08-28 Thread Ramkumar KB via ntg-context
Hans,

Thank you for the snippets. These are super helpful (I am assuming commands
like `withpatternscale` are MetaFun extensions and Wow!).

I have added them to a new Wiki Page -
https://wiki.contextgarden.net/Fill_Patterns and linked it the main MetaFun
wiki page - https://wiki.contextgarden.net/MetaFun_-_MetaPost_in_ConTeXt

Thanks again!

best regards,
Ramkumar

On Sat, Aug 28, 2021 at 7:02 PM Hans Hagen  wrote:

> On 8/28/2021 11:33 AM, Ramkumar KB via ntg-context wrote:
> > Hello List,
> >
> > I have a use case to apply a particular pattern to a closed shape. I am
> > using Metapost for the figures.
> >
> > After some research this package seems to quite good, in terms of having
> > all the patterns normally used - https://ctan.org/pkg/minim-hatching
> > 
> >
> > But I could not figure out how to use this with ConTeXt. Or maybe there
> > is already a better way to do this in ConTeXt and am missing that trick.
> >
> > Any tips would be really helpful.
> \starttext
>
> \startMPpage[offset=1cm]
>  draw (fullcircle scaled 5cm shifted (0cm,0cm))
>  withpattern image (fill fullcircle scaled 1cm withcolor
> "darkblue" ;)
>  withpatternscale (1/10,1/10)
>  ;
>
>  draw (fullcircle scaled 5cm shifted (5cm,0cm))
>  withpattern image (fill fullcircle scaled 5mm withcolor
> "darkred" ;)
>  withpatternscale (1/20,1/20)
>  ;
>
>  draw (fullcircle scaled 5cm shifted (10cm,0cm))
>  withpattern image (fill fullcircle scaled 5mm withcolor
> "darkgreen" ;)
>  withpatternscale (1/40,1/40)
>  ;
>
>  draw (fullcircle scaled 5cm shifted (0cm,5cm))
>  withpattern image (fill fullcircle scaled 1cm withcolor
> "darkcyan" ;)
>  withpatternscale (1/10,1/20)
>  ;
>
>  draw (fullcircle scaled 5cm shifted (5cm,5cm))
>  withpattern image (fill fullcircle scaled 5mm withcolor
> "darkmagenta" ;)
>  withpatternscale (1/20,1/40)
>  ;
>
>  draw (fullcircle scaled 5cm shifted (10cm,5cm))
>  withpattern image (fill fullcircle scaled 5mm withcolor
> "darkyellow" ;)
>  withpatternscale (1/40,1/80)
>  ;
> \stopMPpage
>
> \startMPpage[offset=1cm]
>  fill fullcircle scaled 11cm
>  withcolor "darkyellow" ;
>
>  draw fullcircle scaled 10cm
>  withpattern image (fill fullcircle scaled 1cm withcolor
> "darkblue" ;)
>  ;
>
>  draw fulldiamond scaled 8cm
>  withpattern image (fill fulldiamond scaled 4mm withcolor
> "darkgreen" ;)
>  rotated 15
>  ;
>
>  draw fulltriangle scaled 9cm
>  withpattern image (fill fulltriangle scaled 3mm withcolor
> "white" ;)
>  rotated 45
>  ;
>
>  draw fullcircle scaled 10cm
>  withpattern image (draw textext("!") withcolor "middlegray" ;)
>  rotated 45
>  ;
>
>  draw fullcircle scaled 10cm
>  withpen pencircle scaled 1mm
>  withcolor "darkgray" ;
> \stopMPpage
>
> \startMPpage[instance=doublefun]
>  fill fullcircle scaled 8cm withcolor "yellow" ;
>  draw fullcircle scaled 8cm
>  withpattern image (draw figure("t:/sources/cow.pdf") rotated 45;)
>  withpatternscale 1/40
>  ;
> \stopMPpage
>
>
> \startMPpage[instance=doublefun]
>  draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
>  withpattern image (fill closedcurve((fullcircle scaled 40
> shifted (25,-25))) withcolor "darkgray" withopacity .5)
>  withpatternscale (1,1)
>  ;
>  draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
>  withpattern image (fill closedcurve((fullcircle scaled 40
> shifted (25,-25))) withcolor "darkred" withopacity .5)
>  withpatternscale (1/2,1/2)
>  ;
>  draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
>  withpattern image (fill closedcurve((fullcircle scaled 40
> shifted (25,-25))) withcolor "darkgreen" withopacity .5)
>  withpatternscale (1/3,1/3)
>  ;
>  draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
>  withpattern image (fill closedcurve((fullcircle scaled 40
> shifted (25,-25))) withcolor "darkblue" withopacity .5)
>  withpatternscale (1/4,1/4)
>  ;
> \stopMPpage
>
> % \startTEXpage
>  \page
>  \startMPcode{doublefun}
>  draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-400))
>  withpattern image (fill closedcurve((fullcircle scaled 40
> shifted (25,-25
>  withpatternscale 1/8
>  ;
>  \stopMPcode
>  \blank
>  \startMPcode{doublefun}
>  draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-400))
>  withpattern image (fill closedcurve((fullcircle scaled 40
> shifted (25,-25
>  withpatternfloat true
>  withpatternscale 1/8
>  ;
>  \stopMPcode
>  \page
> % \stopTEXpage
>
> \stoptext
>
>
> 

Re: [NTG-context] Handling of negative values in the statistical-charts?

2021-08-28 Thread Ramkumar KB via ntg-context
Hi,

I have added an 'advanced' type for line & bar graphs to handle the use
case for -ve y-values / 4th quadrant graphs. It works similar to 'basic'
but works for -ve y-values (i.e. for the 4th quadrant).

PFA the amended lua file (zip file) and sample of line graph.

\def\edudataone{-10,35.55,-20.0,33,31,-25,-32}
\def\yearlabelstwo{2013,2014,2015,2016,
2017}

\linechart[basic][
ylength=5,
xscale=1.6, yscale=0.1,
left=0.5,
distance=1.2,
linecolor=limegreen, linewidth=1.5,
dotscolor=islamicgreen,
dotswidth=8, dotslabels=yes,
axesunits=yes,
xunit=Year,
yunit=Number of graduates
(thousands)][
data={\edudataone},
xlabels={\yearlabelstwo}]

\linechart[advanced][
ylength=5,
xscale=1.6, yscale=0.1,
left=0.5,
distance=1.2,
linecolor=limegreen, linewidth=1.5,
dotscolor=islamicgreen,
dotswidth=8, dotslabels=yes,
axesunits=yes,
xunit=Year,
yunit=Number of graduates
(thousands)][
data={\edudataone},
xlabels={\yearlabelstwo}]

It will be fantastic to get some feedback on this from the original authors
and also next steps to add this across all the relevant charts.

Thank you,

best regards,
Ramkumar

On Sat, Aug 21, 2021 at 3:23 PM Ramkumar KB  wrote:

> Dear List,
>
> I have been exploring the use of the awesome statistical-charts
>  module. So first of all, a
> big thanks to the authors of the same.
>
> I seem to have hit a snag when it comes to handling of -ve values. In my
> example (attached tex & pdf), the y-axis labels and the grids do not seem
> to be working on the -ve side (also, able to flip labels above x-axis for
> -ve values). This seems to be the case of column charts and bar charts (and
> I will test this for the other types of charts also).
>
> If this is a more generic issue across all the types, then I can
> contribute towards enhancing it (as any charts module should handle -ve
> values). Any tips or pointers would be really helpful.
>
> Thank you very much.
>
> best regards,
>
>
>


fourth_quadrant.pdf
Description: Adobe PDF document
<>
___
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
___


[NTG-context] prefixstarter in captions

2021-08-28 Thread Adam Reviczky via ntg-context
Hi,

There was a question on the list before on prepending to the numberpart of
a caption with the 'numberstarter' command, which works just fine (
https://mailman.ntg.nl/pipermail/ntg-context/2017/089142.html).

I wanted to try the same but for prepending to the entire prefix (not just
the number part) when prefixsegments are used, however using
'prefixstarter' does not seem to make a difference.

For the sake of the example I have added the numberstarter in as well, just
for comparison.

Caption with the example reads "Figure 1.S.1" whereas I was expecting
"Figure C.1.S.1".

MWE:

\setupfloatcaption[figure][number=yes,way=bytext,prefix=yes,prefixstarter={C.},numberstarter={S.}]
\starttext
\startchapter[title={Cow}]
\startplacefigure[title={Custom caption}]
\externalfigure[cow]
\stopplacefigure
\stopchapter
\stoptext

Not sure whether prefixstarter is the intended command to use, but the wiki
of setupcation (https://wiki.contextgarden.net/Command/setupcaption) says
it inherits from setupcounter which has both numberstarter and
prefixstarter defined in the same way.

Adam
___
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
___


Re: [NTG-context] Test for displaying a header

2021-08-28 Thread Wolfgang Schuster via ntg-context

Fabrice,

there is difference between putting something on the first page 
regardless of the number of pages in your document or do something when 
your document contains only a single or more pages.



When you have a header or title which is always placed on the first page 
(but not on the following pages) you have to options.


    1. Check the current page when to header is placed which can be 
done with \doif{\pagenumber}{1}{...}


    2. Disable the header on the first page (\setupheader[state=high]) 
and place your own title as a regular element in the running text.



A case where you have to number the number of total pages is when you 
try to show the page counter in the form "Page x of y" for 2 or more 
pages. In this case you have to check against the value for the total 
number of pages which can be done with 
\doifnot{\totalnumberofpages}{1}{...}.



Below are two examples which show how the header/title placement works.

 start example 1
\startsetups [header]
    \startframed [width=max,height=max]
    First page header
    \stopframed
\stopsetups

\startsetups [footer]
    Page \userpagenumber\ of \lastuserpagenumber
\stopsetups

\setupheadertexts
  [\doif{\pagenumber}{1}{\directsetup{header}}]

\setupfootertexts
  [\doifnot{\totalnumberofpages}{1}{\directsetup{footer}}]

\starttext
\dorecurse{12}{\samplefile{lorem}\par}
\stoptext
 stop example 1

 start example 2
\startsetups [header]
    \setupheader[state=high]
    \startframed [width=max,height=3cm]
    First page header
    \stopframed
    \blank
\stopsetups

\startsetups [footer]
    Page \userpagenumber\ of \lastuserpagenumber
\stopsetups

\setuppagenumbering
  [location=none]

\setupfootertexts
  [\doifnot{\totalnumberofpages}{1}{\directsetup{footer}}]

\starttext

\setup[header]

\dorecurse{12}{\samplefile{lorem}\par}

\stoptext
 stop example 2

Wolfgang

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


Re: [NTG-context] Best way to apply a fill-pattern to a closed shape?

2021-08-28 Thread Hans Hagen via ntg-context

On 8/28/2021 11:33 AM, Ramkumar KB via ntg-context wrote:

Hello List,

I have a use case to apply a particular pattern to a closed shape. I am 
using Metapost for the figures.


After some research this package seems to quite good, in terms of having 
all the patterns normally used - https://ctan.org/pkg/minim-hatching 



But I could not figure out how to use this with ConTeXt. Or maybe there 
is already a better way to do this in ConTeXt and am missing that trick.


Any tips would be really helpful.

\starttext

\startMPpage[offset=1cm]
draw (fullcircle scaled 5cm shifted (0cm,0cm))
withpattern image (fill fullcircle scaled 1cm withcolor 
"darkblue" ;)

withpatternscale (1/10,1/10)
;

draw (fullcircle scaled 5cm shifted (5cm,0cm))
withpattern image (fill fullcircle scaled 5mm withcolor 
"darkred" ;)

withpatternscale (1/20,1/20)
;

draw (fullcircle scaled 5cm shifted (10cm,0cm))
withpattern image (fill fullcircle scaled 5mm withcolor 
"darkgreen" ;)

withpatternscale (1/40,1/40)
;

draw (fullcircle scaled 5cm shifted (0cm,5cm))
withpattern image (fill fullcircle scaled 1cm withcolor 
"darkcyan" ;)

withpatternscale (1/10,1/20)
;

draw (fullcircle scaled 5cm shifted (5cm,5cm))
withpattern image (fill fullcircle scaled 5mm withcolor 
"darkmagenta" ;)

withpatternscale (1/20,1/40)
;

draw (fullcircle scaled 5cm shifted (10cm,5cm))
withpattern image (fill fullcircle scaled 5mm withcolor 
"darkyellow" ;)

withpatternscale (1/40,1/80)
;
\stopMPpage

\startMPpage[offset=1cm]
fill fullcircle scaled 11cm
withcolor "darkyellow" ;

draw fullcircle scaled 10cm
withpattern image (fill fullcircle scaled 1cm withcolor 
"darkblue" ;)

;

draw fulldiamond scaled 8cm
withpattern image (fill fulldiamond scaled 4mm withcolor 
"darkgreen" ;)

rotated 15
;

draw fulltriangle scaled 9cm
withpattern image (fill fulltriangle scaled 3mm withcolor 
"white" ;)

rotated 45
;

draw fullcircle scaled 10cm
withpattern image (draw textext("!") withcolor "middlegray" ;)
rotated 45
;

draw fullcircle scaled 10cm
withpen pencircle scaled 1mm
withcolor "darkgray" ;
\stopMPpage

\startMPpage[instance=doublefun]
fill fullcircle scaled 8cm withcolor "yellow" ;
draw fullcircle scaled 8cm
withpattern image (draw figure("t:/sources/cow.pdf") rotated 45;)
withpatternscale 1/40
;
\stopMPpage


\startMPpage[instance=doublefun]
draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
withpattern image (fill closedcurve((fullcircle scaled 40 
shifted (25,-25))) withcolor "darkgray" withopacity .5)

withpatternscale (1,1)
;
draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
withpattern image (fill closedcurve((fullcircle scaled 40 
shifted (25,-25))) withcolor "darkred" withopacity .5)

withpatternscale (1/2,1/2)
;
draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
withpattern image (fill closedcurve((fullcircle scaled 40 
shifted (25,-25))) withcolor "darkgreen" withopacity .5)

withpatternscale (1/3,1/3)
;
draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200))
withpattern image (fill closedcurve((fullcircle scaled 40 
shifted (25,-25))) withcolor "darkblue" withopacity .5)

withpatternscale (1/4,1/4)
;
\stopMPpage

% \startTEXpage
\page
\startMPcode{doublefun}
draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-400))
withpattern image (fill closedcurve((fullcircle scaled 40 
shifted (25,-25

withpatternscale 1/8
;
\stopMPcode
\blank
\startMPcode{doublefun}
draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-400))
withpattern image (fill closedcurve((fullcircle scaled 40 
shifted (25,-25

withpatternfloat true
withpatternscale 1/8
;
\stopMPcode
\page
% \stopTEXpage

\stoptext


-
  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

[NTG-context] Best way to apply a fill-pattern to a closed shape?

2021-08-28 Thread Ramkumar KB via ntg-context
Hello List,

I have a use case to apply a particular pattern to a closed shape. I am
using Metapost for the figures.

After some research this package seems to quite good, in terms of having
all the patterns normally used -  https://ctan.org/pkg/minim-hatching

But I could not figure out how to use this with ConTeXt. Or maybe there is
already a better way to do this in ConTeXt and am missing that trick.

Any tips would be really helpful.

Thank you.

Best regards,
Ramkumar
___
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
___


Re: [NTG-context] getting path and filename from url

2021-08-28 Thread Pablo Rodriguez via ntg-context
On 8/28/21 1:17 AM, Hans Hagen via ntg-context wrote:
> On 8/27/2021 8:53 PM, Pablo Rodriguez via ntg-context wrote:
>> [...]
>> How can I get that match for #1 ends in the last slash (including it
>> "../a/b/cb/ce.b/ca.b/c/") and match for #2 ends in the last period
>> (excluding it, "dabc")?
> it really helps to read the cld manual (or look into l-* files) as there
> are plenty of efficient helpers for these things

Many thanks for your reply, Hans.

It really works like charm and reading cld-mkiv.pdf is one of the things
I want to do in the near future.

Many thanks for your help again,

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] getting path and filename from url

2021-08-28 Thread Pablo Rodriguez via ntg-context
On 8/27/21 10:56 PM, Tomas Hala via ntg-context wrote:
> Hi Pablo,
>
> is the following what you need?
>
> context("2a. " .. url:match "[^/]+/.+[.]") -- path and name with period
> context("2c. " .. (url:match "[^/]+[^.]+$") :match ".+[.]")  -- name with 
> period

Hi Tomáš,

well, I wnanted to remove the ending period in both cases (and to
understand how that patterns might work.

I got the first one with:

  context("2a ok. " .. url:match "[^/]+.+/") -- path and name

But I’m stuck at the second one (sorry, I don’t know how to remove the
final period):

  context("2c. " .. url:match "[^/]+.$":match("^.+%l+[.$]"))

https://pragma-ade.com/general/manuals/cld-mkiv.pdf#search=nameonly is
the way to go, but it won’t hurt me to understand how patterns might
work here.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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
___