[NTG-context] Re: About framedtext

2023-12-13 Thread Alan Braslau via ntg-context
On Wed, 13 Dec 2023 18:55:34 +0100
Wolfgang Schuster  wrote:

> This was added a few years ago (AFAIR to provide something similar to 
> the TikZ color command).

You actually mean similar to the MetaPost color command.

Alan ;-)
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: About framedtext

2023-12-13 Thread Henning Hraban Ramm

Am 13.12.23 um 18:55 schrieb Wolfgang Schuster:

Henning Hraban Ramm schrieb am 13.12.2023 um 18:19:

Am 13.12.23 um 19:03 schrieb Fabrice Couvreur:

Hi,
Is this a bug or not ?
The key to coloring the background of the text seems to no longer work.
Thanks
Fabrice

   \definecolor[ColorA][0.8(white)]
   \definecolor[MyColorA][.75(MyColorB,white)]


I never saw this syntax in ConTeXt.


This was added a few years ago (AFAIR to provide something similar to 
the TikZ color command).


I thought it looked like TikZ.
And it’s actually documented in 
https://wiki.contextgarden.net/Command/definecolor

I need to transfer this to https://wiki.contextgarden.net/Color and my book…

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: About framedtext

2023-12-13 Thread Wolfgang Schuster

Henning Hraban Ramm schrieb am 13.12.2023 um 18:19:

Am 13.12.23 um 19:03 schrieb Fabrice Couvreur:

Hi,
Is this a bug or not ?
The key to coloring the background of the text seems to no longer work.
Thanks
Fabrice

   \definecolor[ColorA][0.8(white)]
   \definecolor[MyColorA][.75(MyColorB,white)]


I never saw this syntax in ConTeXt.


This was added a few years ago (AFAIR to provide something similar to 
the TikZ color command).


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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: About framedtext

2023-12-13 Thread Henning Hraban Ramm

Am 13.12.23 um 18:19 schrieb Wolfgang Schuster:

Fabrice Couvreur schrieb am 13.12.2023 um 19:03:

Hi,
Is this a bug or not ?
The key to coloring the background of the text seems to no longer work.


There is a problem with the corner option, you can either hope it gets 
fixed in the next release
(corner=round still works) or create your own background as metapost 
graphic with rounded corners.


Oh, yes, here’s Hans’ fix.

Hraban
if not modules then modules = { } end modules ['lpdf-rul'] = {
version   = 1.001,
comment   = "companion to grph-rul.mkiv",
author= "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license   = "see context related readme files"
}

-- todo: split backend and pdf

local tonumber, tostring, next, type = tonumber, tostring, next, type
local concat, setmetatableindex = table.concat, table.setmetatableindex

local attributes   = attributes
local nodes= nodes

local bpfactor = number.dimenfactors.bp

local nuts = nodes.nuts
local ruleactions  = nuts.rules.ruleactions

local getwhd   = nuts.getwhd

local lefttoright_code = tex.directioncodes.lefttoright

local mpcolor  = attributes.colors.mpcolor

local trace_mp = false  trackers.register("rules.mp", function(v) 
trace_mp = v end)

local report_mp= logs.reporter("rules","mp")

local floor= math.floor
local getrandom= utilities.randomizer.get
local formatters   = string.formatters

local setdimen = tex.setdimen
local isdimen  = tex.isdimen
local setmacro = tokens.setters.macro

local codeinjections   = backends.registered.pdf.codeinjections

local d_rule_width  = isdimen("d_rule_width")
local d_rule_height = isdimen("d_rule_height")
local d_rule_depth  = isdimen("d_rule_depth")
local d_rule_h  = isdimen("d_rule_h")
local d_rule_v  = isdimen("d_rule_v")
local d_rule_line   = isdimen("d_rule_line")
local d_rule_offset = isdimen("d_rule_offset")
local d_rule_factor = isdimen("d_rule_factor")

-- This is very pdf specific. Maybe move some to lpdf-rul.lua some day.

local pdfprint ; pdfprint = function(...) pdfprint = lpdf.print return 
pdfprint(...) end

do

local simplemetapost = metapost.simple
local cachesize  = 0
local maxcachesize   = 256*1024
local cachethreshold = 1024
local caching= false -- otherwise random issues so we need a 
dedicated randomizer first

 -- local maxcachesize   = 8*1024
 -- local cachethreshold = 1024/2

local cache = setmetatableindex(function(t,k)
local v = simplemetapost("rulefun",k) -- w, h, d
cachesize = cachesize + #v
if cachesize > maxcachesize then
 -- print("old",cachesize)
for k, v in next, t do
local n = #v
if n > cachethreshold then
t[k] = nil
cachesize = cachesize - n
end
end
 -- print("new",cachesize)
end
 -- print(cachesize,maxcachesize,cachethreshold,#v)
t[k] = v
return v
end)

local replacer = utilities.templates.replacer

-- todo: RuleColor -> just string ?
-- todo: fetch them instead fo push them

-- local predefined = {
-- ["fake:word"] = replacer [[
-- FakeWord(%width%,%height%,%depth%,%line%,%color%);
-- ]],
-- ["fake:rule"] = replacer[[
-- %initializations%
-- FakeRule(%width%,%height%,%depth%,%line%,%color%);
-- ]],
-- ["fake:rest"] = replacer [[
-- RuleDirection := "%direction%" ;
-- RuleOption := "%option%" ;
-- RuleWidth := %width% ;
-- RuleHeight := %height% ;
-- RuleDepth := %depth% ;
-- RuleH := %h% ;
-- RuleV := %v% ;
-- RuleThickness := %line% ;
-- RuleFactor := %factor% ;
-- RuleOffset := %offset% ;
-- def RuleColor = %color% enddef ;
-- %data%;
-- ]]
-- }

local predefined = {
["fake:word"] = replacer [[
FakeWord(RuleWidth,RuleHeight,RuleDepth,RuleThickness,RuleColor);
]],
["fake:rule"] = replacer[[
%initializations%
FakeRule(RuleWidth,RuleHeight,RuleDepth,RuleThickness,RuleColor);
]],
["fake:rest"] = replacer [[
%data%;
]]
}

local initialized = false ;

local function rule_mp(p,h,v,i,n)
local name  = p.name or "fake:rest"
local ht= p.height or 0
local dp= p.depth  or 0
local total = ht + dp
local code  = (predefined[name] or predefined["fake:rest"]) {
data  = p.data or "",
  -- -- width = p.width * bpfactor,
  -- -- height= p.height * bpfactor,
  -- -- depth = p.depth * bpfactor,
  --width = h * bpfactor,
  --height= v * bpfactor * ht / total,
  --depth = v * bpfactor * dp / total,
  --factor= (p.factor or 0) * bpfactor, -- needs checking
  --offset= p.offset or 0,
  --line  = 

[NTG-context] Re: About framedtext

2023-12-13 Thread Wolfgang Schuster

Fabrice Couvreur schrieb am 13.12.2023 um 19:03:

Hi,
Is this a bug or not ?
The key to coloring the background of the text seems to no longer work.


There is a problem with the corner option, you can either hope it gets 
fixed in the next release
(corner=round still works) or create your own background as metapost 
graphic with rounded corners.


Wolfgang

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: About framedtext

2023-12-13 Thread Henning Hraban Ramm

Am 13.12.23 um 19:03 schrieb Fabrice Couvreur:

Hi,
Is this a bug or not ?
The key to coloring the background of the text seems to no longer work.
Thanks
Fabrice

   \definecolor[ColorA][0.8(white)]
   \definecolor[MyColorA][.75(MyColorB,white)]


I never saw this syntax in ConTeXt.
That doesn’t mean it’s wrong, but I’d suggest looking into 
https://wiki.contextgarden.net/Spot_Colors#Multitones


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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___