Re: [NTG-context] image file resolver in Lua?
Am 2018-02-04 um 13:06 schrieb Hans Hagen: > Not sure what you want top know but a lot of image properties can be checked > by prerolling: > \getfiguredimensions[t:/sources/cow.pdf] This is really interesting, but my original question was about the file path resolver, i.e. how to get "t:/sources/cow.pdf" from just "cow"? Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD ___ 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] Scale figure to fill a box
Hi Hans, I want to use a few graphics as page backgrounds but with the \scale command the image always stays within the borders of the page. Can you add a command (probably easier than adding such a function to \scale) which does as same as in the second row of the example below where the image extends outside of the borders of the frame. A option to clip parts – which can be disabled – of the image which are outside of the frame would be a nice extension to this command (e.g. in case you want a image in a table cell). \setupexternalfigure[location=default] \defineframed [PageBorder] [offset=overlay, rulethickness=2pt, framecolor=red, width=6cm, height=6cm] \starttext \startcombination[nx=2,ny=1,distance=4cm] {\PageBorder{\externalfigure[hacker][factor=fit]}}{} {\PageBorder{\externalfigure[mill] [factor=fit]}}{} \stopcombination \blank[4cm] \startcombination[nx=2,ny=1,distance=4cm] {\PageBorder{\clap{\externalfigure[hacker][height=6cm]}}}{} {\PageBorder {\externalfigure[mill] [width=6cm]}} {} \stopcombination \stoptext 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] image file resolver in Lua?
On 2/3/2018 7:57 AM, Rudolf Bahr wrote: On Fri, Feb 02, 2018 at 04:17:32PM +0100, Henning Hraban Ramm wrote: Am 2018-02-02 um 12:08 schrieb Rudolf Bahr: On Fri, Feb 02, 2018 at 08:40:08AM +0100, Henning Hraban Ramm wrote: Ahoi, I’m using a Lua function to calculate image sizes, cropping etc. This snippet: local filename = figures.current().status.fullname local pic = img.scan{filename = filename} ... works most of the time, but sometimes the "current" image is the previous one, might be because I’m using layers and postponing. So I’d like to use just the same filename as I give to \externalfigure, i.e. without path and extension. How can I address the same file path resolver in my Lua function? Moin, Hraban, where could I find something about those lua functions? Maybe here: http://source.contextgarden.net/tex/context/base/mkiv/grph-inc.lua The image placement functions I’m using are something Hans and others helped me accomplish during the last meeting; AFAIK there’s no real documentation. Find attached the lua part. It’s probably more complicated than necessary I could work around my original problem: I’m using my image with \externalfigure in an invisible place first, so it’s current, and figures.current().status is the right one. :) Here’s my (convoluted) placement macro: % image on empty page, caption in margin % usage: % \startpostponing[pagenumber] % \pagefig[reference]{caption}{filename} % \stoppostponing % postponing is important, otherwise the page numbering gets wrong \def\pagefig{\dosingleempty\doPagefig} \def\doPagefig[#1]#2#3{ % calculate image size \startfullpagemakeup \externalfigure[#3][width=1mm] % dummy to set image as current \def\myClipHeight{\ctxlua{ctxClipHeight("#3", \Resolution)}} \def\mystartY{\ctxlua{ctxStartY("#3", \Resolution)}} % image \setlayerframed[bglayer][% frame=off, offset=overlay, x=21mm, y=\mystartY, height=\myClipHeight, width=\textwidth, align=flushleft, ]{% \clip[ width=\textwidth, height=\myClipHeight, hoffset=0mm, voffset=0mm, % i.e. clip bottom! TODO: options! ]{\externalfigure[#3][width=\textwidth]} } \textreference[pre#1]{\myImgHeight} % caption \setlayerframed[bglayer][% frame=off, offset=overlay, linecorrection=on, x=143mm,y=\dimexpr\mystartY + 3pt\relax, height=\myClipHeight, width=\outermarginwidth, align={flushleft,low}, valign=bottom, ]{% \vbox{ \textreference[#1]{\strut #2}\vfill #2 }} \stopfullpagemakeup } usage example: \startpostponing[82] \pagefig[alinari-stelzen]{Gebrüder Alinari (Florenz, 19. Jhd.)}{ka34/img/Gebr-Alinari_Kinder_auf_Stelzen} \stoppostponing Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD Moin Hraban! It's very interesting for me to see, how exactly you calculate the size of images and texts with the help of lua! Up to now I used to use python and a independend lua to provide some necessary data for context. For instance python invokes graphicsmagick in order to get the size of images. Because it's provided in px and not in pt, so often some further manual work is unavoidable. Now, since lua and metafun are well integrated into context it suggests itself to use luatex instead of python, though I like this language very much. Thank you very much, Hraban, for putting your macros and links at my disposal! Not sure what you want top know but a lot of image properties can be checked by prerolling: \starttext \getfiguredimensions[t:/sources/cow.pdf] \starttabulate[|T|T|] \NC \string\figurewidth \NC \figurewidth \NC \NR \NC \string\figureheight\NC \figureheight\NC \NR \NC \string\figurexscale\NC \figurexscale\NC \NR \NC \string\figureyscale\NC \figureyscale\NC \NR \TB \NC \string\figuresize \NC \figuresize \NC \NR \NC \string\figurelabel \NC \figurelabel \NC \NR \NC \string\figurefileoriginal \NC \figurefileoriginal \NC \NR \NC \string\figurefilepage \NC \figurefilepage \NC \NR \NC \string\figurefileoptions \NC \figurefileoptions \NC \NR \NC \string\figurefileconversion\NC \figurefileconversion\NC \NR \NC \string\figurefileresolution\NC \figurefileresolution\NC \NR \NC \string\figurefilecolor \NC \figurefilecolor \NC \NR \NC \string\figurefilearguments \NC \figurefilearguments \NC \NR \NC \string\figurefilecache \NC \figurefilecache \NC \NR \NC \string\figurefileprefix\NC \figurefileprefix\NC \NR \TB \NC \string\figurenaturalwidth \NC \figurenaturalwidth \NC \NR \NC \string\figurenaturalheight \NC \figurenaturalheight \NC \NR \NC \string\figurexresolution \NC \figurexresolution \NC \NR \NC \string\figureyresolution \NC \figureyresolution \NC \NR \NC \string\figureorientation \NC \figureorientation \NC \NR \NC \string\figurerotation
Re: [NTG-context] missing link
On 02/04/2018 11:36 AM, Floris van Manen wrote: > On the contextgarden.net site, at page: > [...] > the link http://luatex.bluwiki.com/ points to a placeholder page. > e.g. not much of an example ;-) Hi Florian, according to http://luatex.org/documentation.html, the wiki is located at http://wiki.luatex.org/. Could you confirm this and update the ConTeXt Garden? 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] Presentation sections identified by color and mark
On 2/3/2018 10:02 PM, jmm...@us.es wrote: Hi, I'm starting a presentation with ConTeXt. I'd like to visually differentiate each section, so I've come up with two complementary approaches to do that: * Use a different color palette for each section, and * Mark the progress bar to indicate the start of each section. I've done an small example (at the end) but: * Last Subject of a Topic take color from next Topic. (e.g. "Some greenB") * I don't like interactionBar styles provided. I'd like something like: |-|-|-|--|-- (horizontal line and a vertical line at the begin of each section and a vertical line of different color for current position) other option I like: ##%%@@HHH&&& (each letter represents a color. It's a bar with colors marking size of text. So it's a series of color rectangles with colors for each section and a vertical line for current position) The main problems are: * How can I pass the first page of each section to MetaPost? you need to get the logic ok yourself, something like: \startuseMPgraphic{PageShape} StartPage ; numeric n ; n := \number\nofsubpages ; numeric m ; m := \number\subpageno ; if (n > 0) and (m > 0) : pair pa ; path p ; p := (100pt,100pt) -- (500pt,100pt) ; draw p withpen pencircle scaled 5pt withcolor "BackgroundColor" ; for i=0,n-1 : pa := point(1/n) of p ; draw (pa + (0,10pt)) -- (pa + (0,-10pt)) withpen pencircle scaled 5pt withcolor "BackgroundColor" ; endfor ; draw point (1/m) of p withpen pencircle scaled 10pt withcolor "PositionColor" ; fi ; StopPage ; \stopuseMPgraphic * How can I protect background color of SomeGreenB to be green and not blue? just look at the definitions you load ... \definecolor [MyBackgroundColor] [s=.85] \setupbackgrounds [page] [background=color, backgroundcolor=MyBackgroundColor] Thanks. ---8< - Start example \usemodule[present-original] \usemodule[present-common] \definecolor [PageColor] [black] \definecolor [BackgroundColor] [s=.85] \definecolor [OrnamentColor] [r=.75] \definecolor [PositionColor] [s=.55] \defineoverlay [PageShape][\useMPgraphic{PageShape}] \startuseMPgraphic{PageShape} StartPage ; path p ; pair pa, pb ; numeric len ; color contrastcolor ; numeric i; numeric sections[]; % simulated load of sections sections[0] := 1; sections[1] := 4; sections[2] := 6; pickup pencircle scaled 5pt ; p := (100pt,100pt)--(500pt,100pt); draw p withcolor \MPcolor{OrnamentColor} ; contrastcolor = \MPcolor{PositionColor} ; if (RealPageNumber > 0) and (NOfPages > 0): len := 1/NOfPages ; i := 0; forever : exitunless known sections[i]; pa := point(0+len*sections[i]) of p ; draw (pa+(0,10pt))--(pa+(0,-10pt)) withcolor \MPcolor{OrnamentColor} ; i := i + 1; endfor ; pa := point (0+len*RealPageNumber) of p ; %draw (pa+(0,10pt))--(pa+(0,-10pt)) withcolor contrastcolor ; draw pa withpen pencircle scaled 10pt withcolor contrastcolor ; fi ; StopPage ; \stopuseMPgraphic \setupbackgrounds [text] [background={PageShape}] \starttext \setupdocument[title={Title},location={Place}] \startdocument \definecolor[BackgroundColor][r=0,g=.7,b=0] \startTopic[title={Topic Green}] Some text A \startSubject[title={Some green 1}] more text B \stopSubject \startSubject[title={Some green 2}] more text B \stopSubject \stopTopic \definecolor[BackgroundColor][r=0,g=0,b=0.7] \startTopic[title={Topic Blue}] Some text C \startSubject[title={Some blue}] more text D \stopSubject \stopTopic \definecolor[BackgroundColor][r=.7,g=0,b=0] \startTopic[title={Topic Red}] Some text E \startSubject[title={Some Red}] more text F \stopSubject \stopTopic \stopdocument \stoptext ___ 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 ___ -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
Re: [NTG-context] Question about an environment
Hello Wolfgang, Thanks. Fabrice 2018-02-03 14:29 GMT+01:00 Wolfgang Schuster: > > Fabrice Couvreur > 3. Februar 2018 um 11:20 > Hi Wolfgang, > Thank you, we get almost what I want. > With your suggestion, we have this : > > 1. First > Second > Third > > Is it possible to have this : > > 1. First > Second > Third > > > Use inline items and add \par (or a empty line) after each line. > > \defineenumeration > [ex] > [alternative=serried, >width=2em, >distance=0pt, >text=] > > \starttext > > \startex > \startitemize[text] > \item First \par > \item Second \par > \item Third \par > \stopitemize > \stopex > > \stoptext > > 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 > > ___ > ___ 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] missing link
On the contextgarden.net site, at page: http://wiki.contextgarden.net/Mark_IV near the end of the page you see: More sample code Other examples of Lua(TeX) code are to be found on Luigi’s user page as well as http://luatex.bluwiki.com/ the link http://luatex.bluwiki.com/ points to a placeholder page. e.g. not much of an example ;-) .F signature.asc Description: Message signed with OpenPGP using GPGMail ___ 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 ___