summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-core.mpiv183
-rw-r--r--metapost/context/base/mp-idea.mpiv30
-rw-r--r--metapost/context/base/mp-tool.mpiv16
3 files changed, 138 insertions, 91 deletions
diff --git a/metapost/context/base/mp-core.mpiv b/metapost/context/base/mp-core.mpiv
index 6613c5703..2d1a80759 100644
--- a/metapost/context/base/mp-core.mpiv
+++ b/metapost/context/base/mp-core.mpiv
@@ -739,80 +739,106 @@ def prepare_multi_pars (expr fn,fx,fy,fw,fh,fd,
TopSkipCorrection := 0 ;
fi ;
- fi ;
+ fi ;
- if ypart llxy[fpos] = ypart llxy[tpos] :
+ if ypart llxy[fpos] = ypart llxy[tpos] :
- multipar :=
- llxy[fpos] --
- lrxy[tpos] --
- _pmp_snapped_multi_pos_(urxy[tpos]) --
- _pmp_snapped_multi_pos_(ulxy[fpos]) --
- cycle ;
+ multipar :=
+ llxy[fpos] --
+ lrxy[tpos] --
+ _pmp_snapped_multi_pos_(urxy[tpos]) --
+ _pmp_snapped_multi_pos_(ulxy[fpos]) --
+ cycle ;
- save_multipar (i,1,multipar) ;
+ save_multipar (i,1,multipar) ;
- elseif (ypart llxy[fpos] = ypart ulxy[tpos]) and (xpart llxy[tpos] < xpart llxy[fpos]) :
+ elseif (ypart llxy[fpos] = ypart ulxy[tpos]) and (xpart llxy[tpos] < xpart llxy[fpos]) :
- % two loners
+ % two loners
- multipar := if obey_multi_par_hang :
+ multipar := if obey_multi_par_hang :
- _pmp_right_bottom_hang_(true) --
- _pmp_right_top_hang_(true) --
- _pmp_snapped_multi_pos_(urxy[fpos]) --
- lrxy[fpos] --
+ _pmp_right_bottom_hang_(true) --
+ _pmp_right_top_hang_(true) --
+ _pmp_snapped_multi_pos_(urxy[fpos]) --
+ lrxy[fpos] --
- else :
+ else :
- llxy[fpos] --
- (xpart urcorner multipar, ypart llxy[fpos]) --
- (xpart urcorner multipar, ypart ulxy[fpos]) --
- _pmp_snapped_multi_pos_(ulxy[fpos]) --
+ llxy[fpos] --
+ (xpart urcorner multipar, ypart llxy[fpos]) --
+ (xpart urcorner multipar, ypart ulxy[fpos]) --
+ _pmp_snapped_multi_pos_(ulxy[fpos]) --
- fi cycle ;
+ fi cycle ;
- save_multipar (i,1,multipar) ;
+ save_multipar (i,1,multipar) ;
- multipar := _pmp_set_multipar_(i) ;
+ multipar := _pmp_set_multipar_(i) ;
- multipar := if obey_multi_par_hang :
+ multipar := if obey_multi_par_hang :
- _pmp_left_bottom_hang_(true) --
- llxy[tpos] --
- _pmp_snapped_multi_pos_(ulxy[tpos]) --
- _pmp_left_top_hang_(true) --
+ _pmp_left_bottom_hang_(true) --
+ llxy[tpos] --
+ _pmp_snapped_multi_pos_(ulxy[tpos]) --
+ _pmp_left_top_hang_(true) --
+
+ else :
+
+ (xpart llcorner multipar, ypart llxy[tpos]) --
+ llxy[tpos] --
+ _pmp_snapped_multi_pos_(ulxy[tpos]) --
+ (xpart llcorner multipar, ypart ulxy[tpos]) --
+
+ fi cycle ;
+
+ save_multipar (i,1,multipar) ;
else :
- (xpart llcorner multipar, ypart llxy[tpos]) --
- llxy[tpos] --
- _pmp_snapped_multi_pos_(ulxy[tpos]) --
- (xpart llcorner multipar, ypart ulxy[tpos]) --
+ multipar := if obey_multi_par_hang :
- fi cycle ;
+ _pmp_left_bottom_hang_(true) --
+ llxy[tpos] --
+ _pmp_snapped_multi_pos_(ulxy[tpos]) --
+ _pmp_right_bottom_hang_(true) --
+ _pmp_right_top_hang_(true) --
+ _pmp_snapped_multi_pos_(urxy[fpos]) --
+ lrxy[fpos] --
+ _pmp_left_top_hang_(true) --
- save_multipar (i,1,multipar) ;
+ else :
+
+ (xpart llcorner multipar, ypart llxy[tpos]) --
+ llxy[tpos] --
+ _pmp_snapped_multi_pos_(ulxy[tpos]) --
+ (xpart lrcorner multipar, ypart ulxy[tpos]) --
+ (xpart urcorner multipar, ypart urxy[fpos]) --
+ _pmp_snapped_multi_pos_(urxy[fpos]) --
+ lrxy[fpos] --
+ (xpart ulcorner multipar, ypart lrxy[fpos]) --
+
+ fi cycle ;
+
+ save_multipar (i,1,multipar) ;
+
+ fi ;
else :
multipar := if obey_multi_par_hang :
- _pmp_left_bottom_hang_(true) --
- llxy[tpos] --
- _pmp_snapped_multi_pos_(ulxy[tpos]) --
- _pmp_right_bottom_hang_(true) --
- _pmp_right_top_hang_(true) --
+ _pmp_left_bottom_hang_(false) --
+ _pmp_right_bottom_hang_(false) --
+ _pmp_right_top_hang_(false) --
_pmp_snapped_multi_pos_(urxy[fpos]) --
lrxy[fpos] --
- _pmp_left_top_hang_(true) --
+ _pmp_left_top_hang_(false) --
else :
- (xpart llcorner multipar, ypart llxy[tpos]) --
- llxy[tpos] --
- _pmp_snapped_multi_pos_(ulxy[tpos]) --
- (xpart lrcorner multipar, ypart ulxy[tpos]) --
+ llcorner multipar --
+ lrcorner multipar --
(xpart urcorner multipar, ypart urxy[fpos]) --
_pmp_snapped_multi_pos_(urxy[fpos]) --
lrxy[fpos] --
@@ -824,32 +850,6 @@ def prepare_multi_pars (expr fn,fx,fy,fw,fh,fd,
fi ;
- else :
-
- multipar := if obey_multi_par_hang :
-
- _pmp_left_bottom_hang_(false) --
- _pmp_right_bottom_hang_(false) --
- _pmp_right_top_hang_(false) --
- _pmp_snapped_multi_pos_(urxy[fpos]) --
- lrxy[fpos] --
- _pmp_left_top_hang_(false) --
-
- else :
-
- llcorner multipar --
- lrcorner multipar --
- (xpart urcorner multipar, ypart urxy[fpos]) --
- _pmp_snapped_multi_pos_(urxy[fpos]) --
- lrxy[fpos] --
- (xpart ulcorner multipar, ypart lrxy[fpos]) --
-
- fi cycle ;
-
- save_multipar (i,1,multipar) ;
-
- fi ;
-
elseif (nxy[tpos]=RealPageNumber) and (InsideTextArea(i,par_stop_pos)) :
% last one in chain
@@ -858,33 +858,33 @@ def prepare_multi_pars (expr fn,fx,fy,fw,fh,fd,
if obey_multi_par_hang and obey_multi_par_more :
- multipar :=
- _pmp_x_left_top_hang_(i,true) --
- _pmp_x_right_top_hang_(i,true) --
- _pmp_x_right_bottom_hang_(i,true) --
- _pmp_snapped_multi_pos_(ulxy[tpos]) --
- llxy[tpos] --
- _pmp_x_left_bottom_hang_(i,true) --
- cycle ;
+ multipar :=
+ _pmp_x_left_top_hang_(i,true) --
+ _pmp_x_right_top_hang_(i,true) --
+ _pmp_x_right_bottom_hang_(i,true) --
+ _pmp_snapped_multi_pos_(ulxy[tpos]) --
+ llxy[tpos] --
+ _pmp_x_left_bottom_hang_(i,true) --
+ cycle ;
- else :
+ else :
- multipar :=
- ulcorner multipar --
- urcorner multipar --
- (xpart lrcorner multipar, ypart urxy[tpos]) --
- _pmp_snapped_multi_pos_(ulxy[tpos]) --
- llxy[tpos] --
- (xpart llcorner multipar, ypart llxy[tpos]) --
- cycle ;
+ multipar :=
+ ulcorner multipar --
+ urcorner multipar --
+ (xpart lrcorner multipar, ypart urxy[tpos]) --
+ _pmp_snapped_multi_pos_(ulxy[tpos]) --
+ llxy[tpos] --
+ (xpart llcorner multipar, ypart llxy[tpos]) --
+ cycle ;
- fi ;
+ fi ;
- save_multipar (i,3,multipar) ;
+ save_multipar (i,3,multipar) ;
elseif multi_column_first_page_hack and ((nxy[fpos]=RealPageNumber) and (nxy[tpos]>=RealPageNumber) and (NOfTextColumns>1)) :
- save_multipar (i,2,multipar) ;
+ save_multipar (i,2,multipar) ;
else :
% handled later
@@ -892,6 +892,7 @@ def prepare_multi_pars (expr fn,fx,fy,fw,fh,fd,
endfor ;
+
% second loop
if force_multi_par_chain or (ii > 1) :
diff --git a/metapost/context/base/mp-idea.mpiv b/metapost/context/base/mp-idea.mpiv
new file mode 100644
index 000000000..462d97553
--- /dev/null
+++ b/metapost/context/base/mp-idea.mpiv
@@ -0,0 +1,30 @@
+% redpart (1,1,0,0) crashes
+
+% let normalredpart = redpart ;
+% let normalgreenpart = greenpart ;
+% let normalbluepart = bluepart ;
+% let normalcyanpart = cyanpart ;
+% let normalmagentapart = magentapart ;
+% let normalyellowpart = yellowpart ;
+% let normalblackpart = blackpart ;
+
+% vardef redpart expr p = if cmykcolor p : 1 - normalcyanpart p elseif rgbcolor p : normalredpart p else : p fi enddef ;
+% vardef greenpart expr p = if cmykcolor p : 1 - normalmagentapart p elseif rgbcolor p : normalgreenpart p else : p fi enddef ;
+% vardef bluepart expr p = if cmykcolor p : 1 - normalyellowpart p elseif rgbcolor p : normalbluepart p else : p fi enddef ;
+% vardef cyanpart expr p = if cmykcolor p : normalcyanpart p elseif rgbcolor p : 1 - normalredpart p else : p fi enddef ;
+% vardef magentapart expr p = if cmykcolor p : normalmagentapart p elseif rgbcolor p : 1 - normalgreenpart p else : p fi enddef ;
+% vardef yellowpart expr p = if cmykcolor p : normalyellowpart p elseif rgbcolor p : 1 - normalbluepart p else : p fi enddef ;
+% vardef blackpart expr p = if cmykcolor p : normalblackpart p elseif rgbcolor p : 0 else : p fi enddef ;
+
+vardef rcomponent expr p = if rgbcolor p : redpart p elseif cmykcolor p : 1 - cyanpart p else : p fi enddef ;
+vardef gcomponent expr p = if rgbcolor p : greenpart p elseif cmykcolor p : 1 - magentapart p else : p fi enddef ;
+vardef bcomponent expr p = if rgbcolor p : bluepart p elseif cmykcolor p : 1 - yellowpart p else : p fi enddef ;
+vardef ccomponent expr p = if cmykcolor p : cyanpart p elseif rgbcolor p : 1 - redpart p else : p fi enddef ;
+vardef mcomponent expr p = if cmykcolor p : magentapart p elseif rgbcolor p : 1 - greenpart p else : p fi enddef ;
+vardef ycomponent expr p = if cmykcolor p : yellowpart p elseif rgbcolor p : 1 - bluepart p else : p fi enddef ;
+vardef bcomponent expr p = if cmykcolor p : blackpart p elseif rgbcolor p : 0 else : p fi enddef ;
+
+vardef somecolor = (1,1,0,0) enddef ;
+
+fill OverlayBox withcolor (rcomponent somecolor,gcomponent somecolor,bcomponent somecolor) ;
+fill OverlayBox withcolor (ccomponent somecolor,mcomponent somecolor,ycomponent somecolor,bcomponent somecolor) ;
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index 33c5b7d9a..30c8f1cd6 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -2154,3 +2154,19 @@ primarydef p snapped s =
)
p
enddef ;
+
+% vardef somecolor = (1,1,0,0) enddef ;
+
+% fill OverlayBox withcolor (rcomponent somecolor,gcomponent somecolor,bcomponent somecolor) ;
+% fill OverlayBox withcolor (ccomponent somecolor,mcomponent somecolor,ycomponent somecolor,bcomponent somecolor) ;
+
+% This could be standard mplib 2 behaviour:
+
+vardef rcomponent expr p = if rgbcolor p : redpart p elseif cmykcolor p : 1 - cyanpart p else : p fi enddef ;
+vardef gcomponent expr p = if rgbcolor p : greenpart p elseif cmykcolor p : 1 - magentapart p else : p fi enddef ;
+vardef bcomponent expr p = if rgbcolor p : bluepart p elseif cmykcolor p : 1 - yellowpart p else : p fi enddef ;
+vardef ccomponent expr p = if cmykcolor p : cyanpart p elseif rgbcolor p : 1 - redpart p else : p fi enddef ;
+vardef mcomponent expr p = if cmykcolor p : magentapart p elseif rgbcolor p : 1 - greenpart p else : p fi enddef ;
+vardef ycomponent expr p = if cmykcolor p : yellowpart p elseif rgbcolor p : 1 - bluepart p else : p fi enddef ;
+vardef bcomponent expr p = if cmykcolor p : blackpart p elseif rgbcolor p : 0 else : p fi enddef ;
+