if scribus.newDoc(scribus.PAPER_LETTER, (0,0,0,0),scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT): while r < 256: while g < 256: newcolor = str(r) + '_' + str(g) + '_' + str(b) if newcolor == '0_0_0': newcolor = 'Black' scribus.defineColorRGB(newcolor,r, g, b) rect = scribus.createRect(x + g, y, 5, 5) scribus.setFillColor(newcolor, rect) scribus.setLineColor(newcolor, rect) g = g + 5 g = 0 r = r + 5 y = y – 5
这个脚本在 300,300 位置开始绘制图形,这个位置大约是一个美国信件大小的纸张的水平中心,大概是垂直方向从顶部到底的三分之一位置;这是图像的原点,然后它沿着 X 轴(绿色值)水平构建图形,然后返回到 Y 轴,向上移动 5 个点,然后绘制下一条矩形线。
这看起来很简单;我只需要调整一下数字就可以把立方体的另一面画出来。但这不仅仅是再画两个图,一个是蓝 - 绿色,另一个是红 - 蓝色的问题。我想创建一个展开的立方体,这样我就可以打印、剪开然后折叠它,创建一个 RGB 的 3D 视图。因此,下一部分(向下的页面)的原点(黑色的角落)需要在左上角,其水平方向是绿色,垂直方向是蓝色。
#!/usr/bin/env python # black2rgb.py """ Creates one-half of RGB cube with Black at origin """
import scribus
x = 300 y = 300 r = 0 g = 0 b = 0
if scribus.newDoc(scribus.PAPER_LETTER, (0,0,0,0),scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT): while r < 256: while g < 256: newcolor = str(r) + '_' + str(g) + '_' + str(b) if newcolor == '0_0_0': newcolor = 'Black' scribus.defineColorRGB(newcolor,r, g, b) rect = scribus.createRect(x + g, y, 5, 5) scribus.setFillColor(newcolor, rect) scribus.setLineColor(newcolor, rect) g = g + 5 g = 0 r = r + 5 y = y - 5
r = 0 g = 0 y = 305
while b < 256: while g < 256: newcolor = str(r) + '_' + str(g) + '_' + str(b) if newcolor == '0_0_0': newcolor = 'Black' scribus.defineColorRGB(newcolor,r, g, b) rect = scribus.createRect(x + g, y, 5, 5) scribus.setFillColor(newcolor, rect) scribus.setLineColor(newcolor, rect) g = g + 5 g = 0 b = b + 5 y = y + 5
r = 255 g = 0 y = 305 x = 39 b = 0
while b < 256: while r >= 0: newcolor = str(r) + '_' + str(g) + '_' + str(b) if newcolor == '0_0_0': newcolor = 'Black' scribus.defineColorRGB(newcolor,r, g, b) rect = scribus.createRect(x, y, 5, 5) scribus.setFillColor(newcolor, rect) scribus.setLineColor(newcolor, rect) r = r - 5 x = x+5 b = b + 5 x = 39.5 r = 255 y = y + 5
#!/usr/bin/env python # white2rgb.py """ Creates one-half of RGB cube with White at origin """
import scribus
x = 300 y = 300 r = 255 g = 255 b = 255
if scribus.newDoc(scribus.PAPER_LETTER, (0,0,0,0),scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT): while g >= 0: while r >= 0: newcolor = str(r) + '_' + str(g) + '_' + str(b) if newcolor == '255_255_255': newcolor = 'White' scribus.defineColorRGB(newcolor,r, g, b) rect = scribus.createRect(x + 255 - r, y, 5, 5) scribus.setFillColor(newcolor, rect) scribus.setLineColor(newcolor, rect) r = r - 5 r = 255 g = g - 5 y = y - 5
r = 255 g = 255 y = 305
while b >= 0: while r >= 0: newcolor = str(r) + '_' + str(g) + '_' + str(b) if newcolor == '255_255_255': newcolor = 'White' scribus.defineColorRGB(newcolor,r, g, b) rect = scribus.createRect(x + 255 - r, y, 5, 5) scribus.setFillColor(newcolor, rect) scribus.setLineColor(newcolor, rect) r = r - 5 r = 255 b = b - 5 y = y + 5
r = 255 g = 0 y = 305 x = 39 b = 255
while b >= 0: while g < 256: newcolor = str(r) + '_' + str(g) + '_' + str(b) if newcolor == '255_255_255': newcolor = 'White' scribus.defineColorRGB(newcolor,r, g, b) rect = scribus.createRect(x + g, y, 5, 5) scribus.setFillColor(newcolor, rect) scribus.setLineColor(newcolor, rect) g = g + 5 g = 0 b = b - 5 y = y + 5
scribus.setRedraw(True) scribus.redrawAll()
由于我创建了大量的颜色,所以当看到 Scribus 文件比我用它创建的 PDF 文件大得多的时候,我并不感到惊讶。例如,我的 Scribus SLA 文件是 3.0MB,而从中生成的 PDF 只有 70KB。