控制位图渲染 [英] Controlling bitmap rendering
问题描述
我正在尝试
- 生成图形以通过Graphviz显示在网站中.
- 通过图像映射(或其他一些工具)使每个节点可单击.
为此,我必须渲染图形
- 我应该设置什么属性来获取渲染图形的最大宽度/高度?我浏览了 http://www.graphviz.org/doc/info/attrs页面. html 并尝试操纵诸如
size
之类的属性,但它似乎对我不起作用. - 如何解释节点和边的
pos
属性?
- What attribute should I set to get the max width / height of the rendered graph? I looked into the page http://www.graphviz.org/doc/info/attrs.html and tried to manipulate attributes such as
size
but it didn't seem to work on me. - How should I interpret the
pos
attributes of nodes and edges?
推荐答案
控制尺寸
正如您正确假设的那样,可以通过修改size
来完成.
以下是一些示例:
digraph {1->2;}
图片尺寸: 83 * 155px .这是默认设置下图形的大小.
Image dimensions: 83*155px. This is the size of the graph with default settings.
digraph {size=1; 1->2;}
图片尺寸: 51 * 96px .图像按比例缩小以适合1平方英寸(96 dpi)的尺寸.这是预期的行为,因为文档指出:
Image dimensions: 51*96px. The image got scaled down to fit in a 1 inch square (96 dpi). This is expected behavior because the documentation states:
如果已定义并且图纸较大 比给定的尺寸,图纸是 均匀缩小以适合 在给定的尺寸之内.
If defined and the drawing is larger than the given size, the drawing is uniformly scaled down so that it fits within the given size.
digraph {size=2; 1->2;}
图片尺寸: 83 * 155px .再次符合预期的行为,该图形已经小于2英寸,不需要按比例缩小.
Image dimensions: 83*155px. Again expected behavior, the graph is already smaller than 2 inches and does not need to be scaled down.
digraph {size="2!"; 1->2;}
图片尺寸: 103 * 192px .将该图放大到其中一个尺寸等于2英寸.预期行为,因为文档指出:
Image dimensions: 103*192px. The graph was scaled up to until one of the dimensions equals 2 inches. Expected behavior because the documentation states:
如果尺寸以感叹号结尾 (!),则将其视为 所需的大小.在这种情况下,如果两者 图纸尺寸较小 比尺寸大,图纸按比例放大 均匀地直到至少一维 等于其尺寸.
If size ends in an exclamation point (!), then it is taken to be the desired size. In this case, if both dimensions of the drawing are less than size, the drawing is scaled up uniformly until at least one dimension equals its dimension in size.
解释节点和边的pos属性
我假设您的意思是xdot格式的pos
值.
图形的xdot
digraph {1->2;}
是以下
digraph {
node [label="\N"];
graph [bb="0,0,54,108",
_draw_="c 9 -#ffffffff C 9 -#ffffffff P 4 0 -1 0 108 55 108 55 -1 ",
xdotversion="1.2"];
1 [pos="27,90", width="0.75", height="0.5", _draw_="c 9 -#000000ff e 27 90 27 18 ", _ldraw_="F 14.000000 11 -Times-Roman c 9 -#000000ff T 27 84 0 7 1 -1 "];
2 [pos="27,18", width="0.75", height="0.5", _draw_="c 9 -#000000ff e 27 18 27 18 ", _ldraw_="F 14.000000 11 -Times-Roman c 9 -#000000ff T 27 12 0 7 1 -2 "];
1 -> 2 [pos="e,27,36.413 27,71.831 27,64.131 27,54.974 27,46.417", _draw_="c 9 -#000000ff B 4 27 72 27 64 27 55 27 46 ", _hdraw_="S 5 -solid c 9 -#000000ff C 9 -#000000ff P 3 31 46 27 36 24 46 "];
}
节点的pos值指定节点位置的中心.由于图形的边界框为"0,0,54,108",因此节点位置"27,18"和"27,90"在水平方向上完美居中.
The pos values of the nodes designate the center of the node position. Since the bounding box of the graph is "0,0,54,108", the node positions "27,18" and "27,90" are perfectly centered horizontally.
对于边缘,我想pos
包含边缘线段的点,而_draw_
包含B样条线控制点(但我不太确定).
For edges, I guess the pos
contains the points of the edge segments, whereas _draw_
contains the B-Spline control points (but I'm not really sure about that).
这篇关于控制位图渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!