Exemplo n.º 1
0
def getSpotColors():
    """ Get spot colors from an original document.
        Must be called after getColorsFromDocument().
    """
    ret = {}
    for color in scribus.getColorNames():
        ret[color] = scribus.isSpotColor(color)
    return ret
Exemplo n.º 2
0
def extract_colors():
    """
    Extract and return all colors in the current document.
    """
    colors = []
    names = scribus.getColorNames()
    for name in names:
        cyan, magenta, yellow, black = scribus.getColor(name)
        is_spot = scribus.isSpotColor(name)
        colors.append(color_def("cmyk",
                                (cyan, magenta, yellow, black),
                                name))

    return colors
Exemplo n.º 3
0
def drawColor(colorname, h, v, width, height):  # h horizontal position, v vertical position
    """draws a color chart field with its caption for the given colorname at the h and v position
    """
    # get cmyk values and convert them to 0 - 255 values
    color = scribus.getColor(colorname)
    c = int(round(color[0] / 2.55))
    m = int(round(color[1] / 2.55))
    y = int(round(color[2] / 2.55))
    k = int(round(color[3] / 2.55))
    # get rgb color
    rgbcolor = scribus.getColorAsRGB(colorname)
    r = rgbcolor[0]
    g = rgbcolor[1]
    b = rgbcolor[2]
    # get webcolor
    webcolor = rgbhex(r, g, b)
    # but String for Textbox together
    colorDisplay = colorname
    if scribus.isSpotColor(colorname):
        colorDisplay += " (Spot Color)"
    colorstring = "%s\nC %i, M %i, Y %i, K %i, \nR %i, G %i, B %i \nRGB: %s" % (
        colorDisplay,
        c,
        m,
        y,
        k,
        r,
        g,
        b,
        webcolor,
    )

    # draw rectangle and set colors
    rect = scribus.createRect(h, v, width, height)
    scribus.setFillColor(colorname, rect)
    # if total amount of color is < 20 draw outline in Black for rectangle, else in same color
    if c + m + y + k < 20:
        scribus.setLineColor("Black", rect)
    else:
        scribus.setLineColor(colorname, rect)
    # create textbox and insert text
    textbox = scribus.createText(h + width + 5, v, 50, height)
    # set proper font size
    scribus.setFontSize(11, textbox)
    scribus.setTextAlignment(scribus.ALIGN_LEFT, textbox)
    # load the string into the textbox
    scribus.insertText(colorstring, 0, textbox)
Exemplo n.º 4
0
def drawColor(colorname, h, v, width,
              height):  #h horizontal position, v vertical position
    """draws a color chart field with its caption for the given colorname at the h and v position
    """
    #get cmyk values and convert them to 0 - 255 values
    color = scribus.getColor(colorname)
    c = int(round(color[0] / 2.55))
    m = int(round(color[1] / 2.55))
    y = int(round(color[2] / 2.55))
    k = int(round(color[3] / 2.55))
    #get rgb color
    rgbcolor = scribus.getColorAsRGB(colorname)
    r = rgbcolor[0]
    g = rgbcolor[1]
    b = rgbcolor[2]
    #get webcolor
    webcolor = rgbhex(r, g, b)
    #but String for Textbox together
    colorDisplay = colorname
    if scribus.isSpotColor(colorname):
        colorDisplay += " (Spot Color)"
    colorstring = "%s\nC %i, M %i, Y %i, K %i, \nR %i, G %i, B %i \nRGB: %s" % (
        colorDisplay, c, m, y, k, r, g, b, webcolor)

    #draw rectangle and set colors
    rect = scribus.createRect(h, v, width, height)
    scribus.setFillColor(colorname, rect)
    #if total amount of color is < 20 draw outline in Black for rectangle, else in same color
    if c + m + y + k < 20:
        scribus.setLineColor("Black", rect)
    else:
        scribus.setLineColor(colorname, rect)
    #create textbox and insert text
    textbox = scribus.createText(h + width + 5, v, 50, height)
    #set proper font size
    scribus.setFontSize(11, textbox)
    scribus.setTextAlignment(scribus.ALIGN_LEFT, textbox)
    #load the string into the textbox
    scribus.insertText(colorstring, 0, textbox)
    scribus.setTextColor("Black", textbox)