From: "Procházka Lukáš Ing." <LPr@pontex.cz>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: image file resolver in Lua?
Date: Tue, 06 Feb 2018 17:09:32 +0100 [thread overview]
Message-ID: <op.zd0u56g13h68c7@lpr> (raw)
In-Reply-To: <65C620D0-F39B-42A3-B45D-D537DB60358C@fiee.net>
Hello Henning,
On Tue, 06 Feb 2018 13:13:12 +0100, Henning Hraban Ramm <texml@fiee.net> wrote:
> I’ll try as soon as I get some time, since algorithmic image placement is a recurring problem for me, as I try to replace InDesign in my workflow.
>
> I thought about providing a module, but each of my projects has so differing needs that either every macro would need a bunch of options, or I need a lot of similar macros. We’ll see...
>
my experience in these situations:
I'm usually implementing complicated solutions via Lua, with functions with obligatory arg(s) first followed by one optional argument of table type:
- it's easy to investigate this optional argument and alter the algorithm depending on table keys (presence and/or value),
- you don't have to be afraid of optional arg(s) rearrangement.
To be more concrete:
---- Sample Lua code
MyPlaceFigure = function(figname,
opts) -- Optional; .scale = .sc, .rotation = .rot, .label, ...
opts = opts or {} -- To simplify code bellow
local scale, rot, lab =
opts.scale or opts.sc, -- I.e. more keys are allowed in long/short alternative
opts.rotation or opts.rotate or opts.rot, -- dtto
opts.label or opts.lab,
nil
if label then
-- E.g. use context.placefloat(...)
else
context.externalfigure({figname}, {scale = 1000 * scale, orientation = rot, })
end
end
----
Best regards,
Lukas
> Greetlings, Hraban
--
Ing. Lukáš Procházka | mailto:LPr@pontex.cz
Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn
Bezová 1658
147 14 Praha 4
Mob.: +420 702 033 396
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2018-02-06 16:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 7:40 Henning Hraban Ramm
2018-02-02 11:08 ` Rudolf Bahr
2018-02-02 15:17 ` Henning Hraban Ramm
2018-02-03 6:57 ` Rudolf Bahr
2018-02-04 12:06 ` Hans Hagen
2018-02-04 18:04 ` Henning Hraban Ramm
2018-02-05 20:22 ` Pablo Rodriguez
2018-02-06 8:34 ` Procházka Lukáš Ing.
2018-02-06 12:13 ` Henning Hraban Ramm
2018-02-06 16:09 ` Procházka Lukáš Ing. [this message]
2018-02-06 19:51 ` Henning Hraban Ramm
2018-02-05 14:12 ` Rudolf Bahr
2018-02-08 20:40 ` Henning Hraban Ramm
2018-02-20 9:03 ` Henning Hraban Ramm
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=op.zd0u56g13h68c7@lpr \
--to=lpr@pontex.cz \
--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).