How to use the wand.color.Color function in Wand

To help you get started, we’ve selected a few Wand examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emcconville / wand / wandtests / color.py View on Github external
def equals():
    """Equality test."""
    assert Color('#fff') == Color('#ffffff') == Color('white')
    assert Color('#000') == Color('#000000') == Color('black')
    assert Color('rgba(0, 0, 0, 0)') == Color('rgba(0, 0, 0, 0)')
    assert Color('rgba(0, 0, 0, 0)') == Color('rgba(1, 1, 1, 0)')
github emcconville / wand / wandtests / drawing.py View on Github external
def set_get_text_under_color(wand):
    with Color('#333333') as black:
        wand.text_under_color = black
    assert wand.text_under_color == Color('#333333')
github emcconville / wand / wandtests / color.py View on Github external
def not_equals():
    """Equality test."""
    assert Color('#000') != Color('#fff')
    assert Color('rgba(0, 0, 0, 0)') != Color('rgba(0, 0, 0, 1)')
    assert Color('rgba(0, 0, 0, 1)') != Color('rgba(1, 1, 1, 1)')
github emcconville / wand / wandtests / color.py View on Github external
def equals():
    """Equality test."""
    assert Color('#fff') == Color('#ffffff') == Color('white')
    assert Color('#000') == Color('#000000') == Color('black')
    assert Color('rgba(0, 0, 0, 0)') == Color('rgba(0, 0, 0, 0)')
    assert Color('rgba(0, 0, 0, 0)') == Color('rgba(1, 1, 1, 0)')
github cubaneorg / cubane / cubane / lib / image.py View on Github external
# try image width
    w = img_w
    h = int(w / ar)
    x = 0
    y = int( (float(h) - float(img_h)) / 2.0 )

    # if the height is too short, then the other way around must fit...
    if h < img_h:
        h = img_h
        w = int(h * ar)
        x = int( (float(w) - float(img_w)) / 2.0 )
        y = 0

    # create a new image of the resolved target size in the given
    # background color
    result_img = WandImage(width=w, height=h, background=WandColor(bg_color))
    result_img.composite(img, x, y)
    img.destroy()

    return result_img
github HazyResearch / pdftotree / pdftotree / ml / TableExtractML.py View on Github external
def display_bounding_boxes(self, page_num, bboxes, alternate_colors=True):
        elems = self.elems[page_num]
        page_width, page_height = int(elems.layout.width), int(elems.layout.height)
        img = pdf_to_img(self.pdf_file, page_num, page_width, page_height)
        draw = Drawing()
        draw.fill_color = Color("rgba(0, 0, 0, 0)")
        color = Color("blue")
        draw.stroke_color = color
        for block in bboxes:
            top, left, bottom, right = block[-4:]
            draw.stroke_color = Color(
                "rgba({},{},{}, 1)".format(
                    str(np.random.randint(255)),
                    str(np.random.randint(255)),
                    str(np.random.randint(255)),
                )
            )
            draw.rectangle(
                left=float(left),
                top=float(top),
                right=float(right),
                bottom=float(bottom),
            )
        draw(img)
        return img
github HazyResearch / pdftotree / pdftotree / TreeVisualizer.py View on Github external
def display_boxes(self, tree, html_path, filename_prefix, alternate_colors=False):
        """
        Displays each of the bounding boxes passed in 'boxes' on images of the pdf
        pointed to by pdf_file
        boxes is a list of 5-tuples (page, top, left, bottom, right)
        """
        imgs = []
        colors = {
            "section_header": Color("blue"),
            "figure": Color("green"),
            "figure_caption": Color("green"),
            "table_caption": Color("red"),
            "list": Color("yellow"),
            "paragraph": Color("gray"),
            "table": Color("red"),
            "header": Color("brown"),
        }
        for i, page_num in enumerate(tree.keys()):
            img = self.pdf_to_img(page_num)
            draw = Drawing()
            draw.fill_color = Color("rgba(0, 0, 0, 0.0)")
            for clust in tree[page_num]:
                for (pnum, pwidth, pheight, top, left, bottom, right) in tree[page_num][
                    clust
                ]:
                    draw.stroke_color = colors[clust]
                    draw.rectangle(left=left, top=top, right=right, bottom=bottom)
                    draw.push()
github richardbuckle / EDRefCard / www / scripts / bindings.py View on Github external
'Fighter': {'Color': Color('DarkSlateBlue'), 'Font': getFontPath('Regular', 'Normal')},
    'Camera': {'Color': Color('OliveDrab'), 'Font': getFontPath('Regular', 'Normal')},
    'Head look': {'Color': Color('IndianRed'), 'Font': getFontPath('Regular', 'Normal')},
    'Ship': {'Color': Color('Crimson'), 'Font': getFontPath('Regular', 'Normal')},
    'SRV': {'Color': Color('MediumPurple'), 'Font': getFontPath('Regular', 'Normal')},
    'Scanners': {'Color': Color('DarkOrchid'), 'Font': getFontPath('Regular', 'Normal')},
    'UI': {'Color': Color('DarkOrange'), 'Font': getFontPath('Regular', 'Normal')},
}

# Command category styling
categoryStyles = {
    'General': {'Color': Color('DarkSlateBlue'), 'Font': getFontPath('Regular', 'Normal')},
    'Combat': {'Color': Color('Crimson'), 'Font': getFontPath('Regular', 'Normal')},
    'Social': {'Color': Color('ForestGreen'), 'Font': getFontPath('Regular', 'Normal')},
    'Navigation': {'Color': Color('Black'), 'Font': getFontPath('Regular', 'Normal')},
    'UI': {'Color': Color('DarkOrange'), 'Font': getFontPath('Regular', 'Normal')},
}

# Modifier styling - note a list not a dictionary as modifiers are numeric
class ModifierStyles:
    styles = [
        {'Color': Color('Black'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('Crimson'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('ForestGreen'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('DarkSlateBlue'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('DarkOrange'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('DarkOrchid'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('SteelBlue'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('Sienna'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('IndianRed'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('CornflowerBlue'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('OliveDrab'), 'Font': getFontPath('Regular', 'Normal')},
github richardbuckle / EDRefCard / www / scripts / bindings.py View on Github external
'Holo-Me': {'Color': Color('Sienna'), 'Font': getFontPath('Regular', 'Normal')},
    'Multicrew': {'Color': Color('SteelBlue'), 'Font': getFontPath('Bold', 'Normal')},
    'Fighter': {'Color': Color('DarkSlateBlue'), 'Font': getFontPath('Regular', 'Normal')},
    'Camera': {'Color': Color('OliveDrab'), 'Font': getFontPath('Regular', 'Normal')},
    'Head look': {'Color': Color('IndianRed'), 'Font': getFontPath('Regular', 'Normal')},
    'Ship': {'Color': Color('Crimson'), 'Font': getFontPath('Regular', 'Normal')},
    'SRV': {'Color': Color('MediumPurple'), 'Font': getFontPath('Regular', 'Normal')},
    'Scanners': {'Color': Color('DarkOrchid'), 'Font': getFontPath('Regular', 'Normal')},
    'UI': {'Color': Color('DarkOrange'), 'Font': getFontPath('Regular', 'Normal')},
}

# Command category styling
categoryStyles = {
    'General': {'Color': Color('DarkSlateBlue'), 'Font': getFontPath('Regular', 'Normal')},
    'Combat': {'Color': Color('Crimson'), 'Font': getFontPath('Regular', 'Normal')},
    'Social': {'Color': Color('ForestGreen'), 'Font': getFontPath('Regular', 'Normal')},
    'Navigation': {'Color': Color('Black'), 'Font': getFontPath('Regular', 'Normal')},
    'UI': {'Color': Color('DarkOrange'), 'Font': getFontPath('Regular', 'Normal')},
}

# Modifier styling - note a list not a dictionary as modifiers are numeric
class ModifierStyles:
    styles = [
        {'Color': Color('Black'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('Crimson'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('ForestGreen'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('DarkSlateBlue'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('DarkOrange'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('DarkOrchid'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('SteelBlue'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('Sienna'), 'Font': getFontPath('Regular', 'Normal')},
        {'Color': Color('IndianRed'), 'Font': getFontPath('Regular', 'Normal')},
github HazyResearch / pdftotree / pdftotree / TreeVisualizer.py View on Github external
def display_boxes(self, tree, html_path, filename_prefix, alternate_colors=False):
        """
        Displays each of the bounding boxes passed in 'boxes' on images of the pdf
        pointed to by pdf_file
        boxes is a list of 5-tuples (page, top, left, bottom, right)
        """
        imgs = []
        colors = {
            "section_header": Color("blue"),
            "figure": Color("green"),
            "figure_caption": Color("green"),
            "table_caption": Color("red"),
            "list": Color("yellow"),
            "paragraph": Color("gray"),
            "table": Color("red"),
            "header": Color("brown"),
        }
        for i, page_num in enumerate(tree.keys()):
            img = self.pdf_to_img(page_num)
            draw = Drawing()
            draw.fill_color = Color("rgba(0, 0, 0, 0.0)")
            for clust in tree[page_num]:
                for (pnum, pwidth, pheight, top, left, bottom, right) in tree[page_num][
                    clust
                ]:
                    draw.stroke_color = colors[clust]
                    draw.rectangle(left=left, top=top, right=right, bottom=bottom)
                    draw.push()
                    draw.font_size = 20