From 5baf21b979124606cb6503be4e16d403f233ecd4 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Sat, 11 Jun 2016 00:56:30 +0200 Subject: 2016-06-10 23:56:00 --- metapost/context/base/mpiv/mp-mlib.mpiv | 43 ++++++++++++++++-- tex/context/base/context-version.pdf | Bin 4254 -> 4254 bytes tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/mlib-lua.lua | 6 ++- tex/context/base/mkiv/mlib-pps.lua | 50 +++++++++++++++++++-- tex/context/base/mkiv/spac-def.mkiv | 1 + tex/context/base/mkiv/spac-ver.mkiv | 14 ++---- tex/context/base/mkiv/status-files.pdf | Bin 9093 -> 9092 bytes tex/context/base/mkiv/status-lua.pdf | Bin 269012 -> 269008 bytes tex/context/interface/mkiv/i-context.pdf | Bin 821077 -> 821078 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 60789 -> 60789 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 13 files changed, 97 insertions(+), 23 deletions(-) diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index c4f447d41..ad2338bd0 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -507,16 +507,51 @@ def mfun_withshadestep (text t) = t enddef ; +numeric mfun_shade_fx, mfun_shade_fy ; +numeric mfun_shade_lx, mfun_shade_ly ; +numeric mfun_shade_nx, mfun_shade_ny ; +numeric mfun_shade_dx, mfun_shade_dy ; +numeric mfun_shade_tx, mfun_shade_ty ; + +% first + +def mfun_with_shade_method_analyze(expr p) = + mfun_shade_path := p ; + mfun_shade_step := 1 ; + mfun_shade_fx := xpart point 0 of p ; + mfun_shade_fy := ypart point 0 of p ; + mfun_shade_lx := mfun_shade_fx ; + mfun_shade_ly := mfun_shade_fy ; + mfun_shade_nx := 0 ; + mfun_shade_ny := 0 ; + mfun_shade_dx := abs(mfun_shade_fx - mfun_shade_lx) ; + mfun_shade_dy := abs(mfun_shade_fy - mfun_shade_ly) ; + for i=1 upto length(p) : + mfun_shade_tx := abs(mfun_shade_fx - xpart point i of p) ; + mfun_shade_ty := abs(mfun_shade_fy - ypart point i of p) ; + if mfun_shade_tx > mfun_shade_dx : + mfun_shade_nx := i + 1 ; + mfun_shade_lx := xpart point i of p ; + mfun_shade_dx := mfun_shade_tx ; + fi ; + if mfun_shade_ty > mfun_shade_dy : + mfun_shade_ny := i + 1 ; + mfun_shade_ly := ypart point i of p ; + mfun_shade_dy := mfun_shade_ty ; + fi ; + endfor ; +enddef ; + primarydef p withshademethod m = - hide( - mfun_shade_path := p ; - mfun_shade_step := 1 ; - ) + hide(mfun_with_shade_method_analyze(p)) p withprescript "sh_domain=0 1" withprescript "sh_color=into" withprescript "sh_color_a=" & colordecimals white withprescript "sh_color_b=" & colordecimals black + withprescript "sh_first=" & ddecimal point 0 of p % used for support scaling + withprescript "sh_set_x=" & ddecimal (mfun_shade_nx,mfun_shade_lx) % + withprescript "sh_set_y=" & ddecimal (mfun_shade_ny,mfun_shade_ly) % if m = "linear" : withprescript "sh_type=linear" withprescript "sh_factor=1" diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index b4501d335..5017b348e 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 4133c2053..0b726b5f7 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2016.06.10 08:11} +\newcontextversion{2016.06.10 23:51} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 1d5d41a3b..1aeafe0cf 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.06.10 08:11} +\edef\contextversion{2016.06.10 23:51} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua index baf9346c4..5d30d38eb 100644 --- a/tex/context/base/mkiv/mlib-lua.lua +++ b/tex/context/base/mkiv/mlib-lua.lua @@ -66,7 +66,7 @@ local f_pair = formatters["(%.16f,%.16f)"] local f_triplet = formatters["(%.16f,%.16f,%.16f)"] local f_quadruple = formatters["(%.16f,%.16f,%.16f,%.16f)"] -function mp.print(...) +local function mpprint(...) for i=1,select("#",...) do local value = select(i,...) if value ~= nil then @@ -85,6 +85,10 @@ function mp.print(...) end end +mp.print = mpprint + +table.setmetatablecall(mp,function(t,k) mpprint(k) end) + function mp.boolean(n) n = n + 1 buffer[n] = n and "true" or "false" diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 018dbb03d..358bd9f52 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['mlib-pps'] = { local format, gmatch, match, split = string.format, string.gmatch, string.match, string.split local tonumber, type, unpack = tonumber, type, unpack -local round = math.round +local round, sqrt = math.round, math.sqrt local insert, remove, concat = table.insert, table.remove, table.concat local Cs, Cf, C, Cg, Ct, P, S, V, Carg = lpeg.Cs, lpeg.Cf, lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.V, lpeg.Carg local lpegmatch, tsplitat, tsplitter = lpeg.match, lpeg.tsplitat, lpeg.tsplitter @@ -1119,7 +1119,49 @@ local function sh_process(object,prescript,before,after) local domain = lpegmatch(domainsplitter,prescript.sh_domain or "0 1") local centera = lpegmatch(centersplitter,prescript.sh_center_a or "0 0") local centerb = lpegmatch(centersplitter,prescript.sh_center_b or "0 0") - local steps = tonumber(prescript.sh_step) or 1 + -- compensation for scaling + local sx = 1 + local sy = 1 + local sr = 1 + local dx = 0 + local dy = 0 + if true then + local first = lpegmatch(coordinatesplitter,prescript.sh_first or "0 0") + local setx = lpegmatch(coordinatesplitter,prescript.sh_set_x or "0 0") + local sety = lpegmatch(coordinatesplitter,prescript.sh_set_y or "0 0") + + local x = setx[1] -- point that has different x + local y = sety[1] -- point that has different y + + if x == 0 or y == 0 then + -- forget about it + else + local path = object.path + local path1x = path[1].x_coord + local path1y = path[1].y_coord + local path2x = path[x].x_coord + local path2y = path[y].y_coord + + local dxa = path2x - path1x + local dya = path2y - path1y + local dxb = setx[2] - first[1] + local dyb = sety[2] - first[2] + + if dxa == 0 or dya == 0 or dxb == 0 or dyb == 0 then + -- forget about it + else + sx = dxa / dxb ; if sx < 0 then sx = - sx end -- yes or no + sy = dya / dyb ; if sy < 0 then sy = - sy end -- yes or no + + sr = sqrt(sx^2 + sy^2) + + dx = path1x - sx*first[1] + dy = path1y - sy*first[2] + end + end + end + + local steps = tonumber(prescript.sh_step) or 1 local sh_color_a = prescript.sh_color_a_1 or prescript.sh_color_a or "1" local sh_color_b = prescript.sh_color_b_1 or prescript.sh_color_b or "1" -- sh_color_b_ local ca, cb, colorspace, name, model, separation, fractions @@ -1177,13 +1219,13 @@ local function sh_process(object,prescript,before,after) steps = 1 end if sh_type == "linear" then - local coordinates = { centera[1], centera[2], centerb[1], centerb[2] } + local coordinates = { dx + sx*centera[1], dy + sy*centera[2], dx + sx*centerb[1], dy + sy*centerb[2] } lpdf.linearshade(name,domain,ca,cb,1,colorspace,coordinates,separation,steps>1 and steps,fractions) -- backend specific (will be renamed) elseif sh_type == "circular" then local factor = tonumber(prescript.sh_factor) or 1 local radiusa = factor * tonumber(prescript.sh_radius_a) local radiusb = factor * tonumber(prescript.sh_radius_b) - local coordinates = { centera[1], centera[2], radiusa, centerb[1], centerb[2], radiusb } + local coordinates = { dx + sx*centera[1], dy + sy*centera[2], sr*radiusa, dx + sx*centerb[1], dy + sy*centerb[2], sr*radiusb } lpdf.circularshade(name,domain,ca,cb,1,colorspace,coordinates,separation,steps>1 and steps,fractions) -- backend specific (will be renamed) else -- fatal error diff --git a/tex/context/base/mkiv/spac-def.mkiv b/tex/context/base/mkiv/spac-def.mkiv index 7ead3c63e..24913cbf7 100644 --- a/tex/context/base/mkiv/spac-def.mkiv +++ b/tex/context/base/mkiv/spac-def.mkiv @@ -29,6 +29,7 @@ \settopskip % factors set in \forgetverticalstretch \setmaxdepth % factors set in \forgetverticalstretch \synchronizeindenting + \synchronizeskipamounts \synchronizeblank \synchronizewhitespace \synchronizespacecodes % not needed, frozen factors diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv index 5adb048d4..f9d1dd656 100644 --- a/tex/context/base/mkiv/spac-ver.mkiv +++ b/tex/context/base/mkiv/spac-ver.mkiv @@ -1572,21 +1572,13 @@ \unexpanded\def\synchronizeskipamounts {\bigskipamount - \skipfactor\baselineskip - plus\skipgluefactor\baselineskip - minus\skipgluefactor\baselineskip + \skipfactor\baselineskip + \s!plus\skipgluefactor\baselineskip + \s!minus\skipgluefactor\baselineskip \relax \medskipamount \bigskipamount \divide\medskipamount \plustwo \smallskipamount\bigskipamount \divide\smallskipamount\plusfour} -\appendtoks - \synchronizeskipamounts -\to \everysetupglobalinterlinespace - -\appendtoks - \synchronizeskipamounts -\to \everysetuplocalinterlinespace - %D Snapping. \newif\ifgridsnapping diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 923ab4966..a80440c2f 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index 593f5be44..aaf80482e 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 596361bd5..983426585 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index 00ce32411..01be29580 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index bb5109189..350d3cf9b 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 06/10/16 08:11:20 +-- merge date : 06/10/16 23:51:36 do -- begin closure to overcome local limits and interference -- cgit v1.2.3