summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/context/third/gnuplot/mp-gnuplot.mp
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/metapost/context/third/gnuplot/mp-gnuplot.mp')
-rw-r--r--Master/texmf-dist/metapost/context/third/gnuplot/mp-gnuplot.mp49
1 files changed, 37 insertions, 12 deletions
diff --git a/Master/texmf-dist/metapost/context/third/gnuplot/mp-gnuplot.mp b/Master/texmf-dist/metapost/context/third/gnuplot/mp-gnuplot.mp
index 46c0137e6cb..e49ce2c9428 100644
--- a/Master/texmf-dist/metapost/context/third/gnuplot/mp-gnuplot.mp
+++ b/Master/texmf-dist/metapost/context/third/gnuplot/mp-gnuplot.mp
@@ -391,15 +391,20 @@ boolean context_gnuplot ; context_gnuplot := true;
%% Scaling factors
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
+
+ % --> fixed
+ % default linewidth in metapost: 0.5bp
+ numeric gp_internal_linewidth; gp_internal_linewidth := 0.5bp;
+
+ % --> set globally by user (usually with TeX code)
% scaling factor for points
- gp_scale_pointsize := 1;
+ numeric gp_scale_pointsize; gp_scale_pointsize := 1;
% scaling factor for line widths (for the whole plot)
- gp_scale_linewidth := 1;
- % current linewidth
- gp_linewidth := 1;
- % base linewidth: 0.4bp
- gp_internal_linewidth := 0.4;
+ numeric gp_scale_linewidth; gp_scale_linewidth := 1;
+
+ % --> calculated based on gnuplot's directives in the middle of plot
+ % the true linewidth; equivalent of gp_set_linewidth(1);
+ numeric gp_linewidth; gp_linewidth := gp_scale_linewidth*gp_internal_linewidth;
numeric gp_linetype; gp_linetype := -3;
@@ -775,9 +780,7 @@ boolean context_gnuplot ; context_gnuplot := true;
% axes should be drawn with only one half of the default linewidth
% TODO: do we need this to be configurable?
if gp_linetype = -1: scaled .5 fi
- if gp_use_dashed: dashed gp_dash_linetype(gp_linetype)
- % TODO: make this definition nicer (combine with the definition above)
- elseif gp_linetype = -1: dashed gp_dash_linetype(gp_linetype) fi;
+ if gp_use_dashed or (gp_linetype = -1): dashed gp_dash_linetype(gp_linetype) fi;
enddef;
def gp_dot(expr x,y) =
@@ -807,6 +810,11 @@ boolean context_gnuplot ; context_gnuplot := true;
vardef fullpolygon(expr n) =
(for i=1 upto n: (up rotated ((i-1)*360/n)) -- endfor cycle)
enddef;
+ % this is used in drawing and filling rectangles (not for points)
+ % arguments are lower left and size (size is usually smaller that coordinates - spares some bytes)
+ vardef gp_rect(expr ll_corner, size) =
+ (ll_corner -- (xpart ll_corner + xpart size,ypart ll_corner) -- (ll_corner shifted size) -- (xpart ll_corner,ypart ll_corner + ypart size) -- cycle)
+ enddef;
%-------------------------%
% point shape definitions %
@@ -845,11 +853,19 @@ boolean context_gnuplot ; context_gnuplot := true;
picture gp_point_pt[];
+ % context.trm defines CONTEXT_HTIC = 3.5bp, so points have to match that size
+ % all the shapes above are two units big, so we need to scale with 0.5*3.5bp
+ %
+ % TODO: I should introduce a new variable instead of hardcoding the value
+ % TODO: when points are scaled, line width should not scale along
+ % TODO: when line widths are scaled, line widths of points should scale as well
for i=0,1,2,3,5,7,9,11,13:
- gp_point_pt[i] := image(draw gp_point_shape[i] scaled 3pt;); % TODO: fix the scale & linewidth
+ gp_point_pt[i] := image(draw gp_point_shape[i]
+ scaled 1.75bp withpen pencircle scaled gp_linewidth;);
endfor;
for i=4,6,8,10,12,14:
- gp_point_pt[i] := image(filldraw gp_point_shape[i] scaled 3pt;); % TODO: fix the scale & linewidth
+ gp_point_pt[i] := image(filldraw gp_point_shape[i]
+ scaled 1.75bp withpen pencircle scaled gp_linewidth;);
endfor;
% we have defined 15 point types so far
@@ -892,6 +908,15 @@ boolean context_gnuplot ; context_gnuplot := true;
draw (gp_the_symbol(n) scaled (gp_scale_pointsize) shifted (x,y)) withcolor gp_color_current;
enddef ;
+% TODO: this needs some more testing and synchronization with gnuplot source code first
+%
+% def gp_image_rgb(expr size, ll, ur) =
+% draw bitmapimage (xpart size,ypart size,img) xyscaled (ur shifted -ll) shifted ll;
+% enddef ;
+% def gp_image_rgb_alpha(expr size, ll, ur) =
+% draw bitmapimage (xpart size,ypart size,img) withmask mask xyscaled (ur shifted -ll) shifted ll;
+% enddef ;
+
endinput
end.