如何以图像顶部的标签生成维恩图图像

如何以图像顶部的标签生成维恩图图像

本文介绍了如何以图像顶部的标签生成维恩图图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用htmldoc生成pdf文件,其中



我们使用google图表api作为其他图片,但是他们的Venn图不支持图表上的文本我可以告诉)。



最简单的路径是使用第三方库在我们的服务器上生成venn的图像,然后将图像链接到文档中,不知道任何支持我们用例的软件包。



任何链接/指针都不胜感激。

解决方案

这里是一些示例代码。这看起来像一个不错的教程:





如果您使用Linux,可以使用 gv 命令查看它。有各种实用程序将其转换为PDF; ps2pdf在Linux上,我想在Windows上的Acrobat Distiller。

 %!PS-Adobe-3.0 EPSF- 3.0 
%% BoundingBox:0 0 144 144

%CenterText - 绘制以x为基准的文本,y为基准
%xys CenterText
/ CenterText
{
<< >> begin
/ s exch def / y exch def / x exch def
newpath xs stringwidth pop 2 div sub y moveto s show
end
} bind def

2 setlinewidth
54 72 36 0 360弧形行程
90 72 36 0 360弧形行程

/ Helvetica 10 selectfont
36 72(A)CenterText
108 72(B)CenterText
72 72(A ^ B)CenterText

三圆一。它工作,但我不保证编码的质量,我没有做过任何严重的PS代码在几年。

 %!PS-Adobe-3.0 EPSF-3.0 
%% BoundingBox:0 0 216 216

%CenterText - 以x为基准绘制文本,y上有基线
%xs CenterText
/ CenterText
{
<< >> begin
/ s exch def / y exch def / x exch def
newpath xs stringwidth pop 2 div sub y moveto s show
end
} bind def

%设置边界框的中心为0,0并旋转90度cw
108 108 translate
gsave
180 rotate

%在120-度间隔
/ ct 3 def
/ offset 36 def
/ radius 60 def
0 1 ct 1 sub%for
{
gsave
360 mul ct div rotate
0 offset translate
0 0 radius 0 360 arc stroke
grestore
} for

grestore

/ Helvetica 10 selectfont
-54 36(A)CenterText
54 36(B)CenterText
0 -72(C)CenterText

0 36 ^ B)CenterText
-36 -24(A ^ C)CenterText
36 -24(B ^ C)CenterText

0 -6(A ^ B ^ C)CenterText


I'm trying to generate Venn diagrams for a pdf report, with text on top of the distinct regions.

We're using htmldoc to generate pdfs, which precludes text on top of background images.

We use the google charts api for other images, but their Venn diagrams don't support text on top of the diagram (from what I can tell).

The easiest path would be some way to generate an image of the venn on our server using a 3rd party library, and then link the image into the document, I just don't know any software packages that would support our use case.

Any links/pointers would be appreciated.

解决方案

Here's some example code. This seems like a decent tutorial:

http://paulbourke.net/dataformats/postscript/

If you're on Linux, you can use the gv command to view it. There are various utilities to convert it to PDF too; ps2pdf on Linux, and I think Acrobat Distiller on Windows.

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 144 144

% CenterText - paint text centered on x with baseline on y
% x y s CenterText
/CenterText
{
   << >> begin
   /s exch def /y exch def /x exch def
   newpath x s stringwidth pop 2 div sub y moveto s show
   end
} bind def

2 setlinewidth
54 72 36 0 360 arc stroke
90 72 36 0 360 arc stroke

/Helvetica 10 selectfont
36 72 (A) CenterText
108 72 (B) CenterText
72 72 (A^B) CenterText

Here's the three-circle one. It works but I don't vouch for the quality of the coding, I haven't done any serious PS code in years.

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 216 216

% CenterText - paint text centered on x with baseline on y
% x y s CenterText
/CenterText
{
   << >> begin
   /s exch def /y exch def /x exch def
   newpath x s stringwidth pop 2 div sub y moveto s show
   end
} bind def

% Set center of bounding box at 0,0 and rotate 90 degrees cw
108 108 translate
gsave
180 rotate

% Draw 3 circles at 120-degree intervals
/ct 3 def
/offset 36 def
/radius 60 def
0 1 ct 1 sub   % for
{
    gsave
    360 mul ct div rotate
    0 offset translate
    0 0 radius 0 360 arc stroke
    grestore
} for

grestore

/Helvetica 10 selectfont
-54 36 (A) CenterText
54 36 (B) CenterText
0 -72 (C) CenterText

0 36 (A^B) CenterText
-36 -24 (A^C) CenterText
36 -24 (B^C) CenterText

0 -6 (A^B^C) CenterText

这篇关于如何以图像顶部的标签生成维恩图图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 09:40