我需要编写一个程序来使用HP PCL 5e / HP / GL2绘制图形

时间:2008-11-26 20:35:58

标签: colors drawing line printer-control-language

我已经阅读了一个例子并尝试复制它的方法,但结果很奇怪。这是一次性交易,所以我不想购买一个包来做这件事。此外,它将在Ba​​sic中的多值数据库上执行,而不再有很多程序员编写。 如果有人可以发布一个小例子,这将是最有帮助的。具体来说,我需要一个以8x11纸为中心的盒子,左边1/3填充绿色,中心1/3填充黄色,最后1/3填充红色。然后在每个颜色的框内画一条直线3点。

感谢。

2 个答案:

答案 0 :(得分:1)

最简单的方法是绘制3个方框。你必须自己定位每个人做自己的数学运算,以确定从哪里开始第一个让它居中等。

首先将光标定位在第一个框的左上角,绘制它,移动到下一个框的左上角,绘制它,并对最后一个框执行相同操作。这是一些代码:

<esc>&u300D<esc>*t300R<esc>*p300x300Y<esc>*r3U<esc>*v2S<esc>*c300a300b5P<esc>*p600x300Y<esc>*r3U<esc>*v3S<esc>*c300a300b5P<esc>*p900x300Y<esc>*r3U<esc>*v1S<esc>*c300a300b5P

以下是解释:

<esc>&u300D<esc>*t300R -- set the Unit of Measure and Resolution (in this case 300 dpi)
<esc>*p300x300Y -- move cursor to 300x 300y (1 inch x 1 inch) 
<esc>*r3U<esc>*v2S -- set the color palette to RGB and use color 2 (green)
<esc>*c300a300b5P -- draw a box that is 300 wide and 300 tall, use current fill pattern
<esc>*p600x300Y -- move cursor to 600x 300y
<esc>*r3U<esc>*v3S -- set the color palette to RGB use color 3 (yellow)
<esc>*c300a300b5P -- draw a box that is 300 wide and 300 tall, use current fill pattern
<esc>*p900x300Y -- move cursor to 900x 300y
<esc>*r3U<esc>*v1S -- set the color palette to RGB use color 1 (red)
<esc>*c300a300b5P -- draw a box that is 300 wide and 300 tall, use current fill pattern

以下是其他颜色和调色板,请记住这是简单的方法,您可以指定自己的RGB等。

RGB Palette
<esc>*r3U<esc>*v1S - Red                
<esc>*r3U<esc>*v2S - Green
<esc>*r3U<esc>*v3S - Yellow
<esc>*r3U<esc>*v4S - Blue
<esc>*r3U<esc>*v5S - Magenta
<esc>*r3U<esc>*v6S - Cyan

CMYK Palette
<esc>*r-3U<esc>*v1S - Cyan
<esc>*r-3U<esc>*v2S - Magenta
<esc>*r-3U<esc>*v3S - Blue
<esc>*r-3U<esc>*v4S - Yellow
<esc>*r-3U<esc>*v5S - Green
<esc>*r-3U<esc>*v6S - Red
<esc>*r-3U<esc>*v7S - Black

答案 1 :(得分:0)

解决问题:我的想法错误是它是300 dpi和600 dpi之间的差异所以我除以2并且答案看起来几乎是正确的。真正的问题是3oo dpi和720 Decipoints之间的差异。真正的因素需要是2.4,现在它可以完美运行。