Пример #1
0
 def _caption_akari(self):
     caption = 'わぁい{0} あかり{0}大好き'.format(self.text)
     drawing = Drawing()
     drawing.font = 'assets/fonts/rounded-mgenplus-1c-bold.ttf'
     drawing.font_size = self.width / 15
     text = fill(caption, 23)
     drawing.gravity = 'south'
     drawing.text_interline_spacing = drawing.font_size / -5
     offset = max(self.width / 400, 2)
     # first the shadow
     drawing.translate(offset, -offset)
     drawing.fill_color = Color('#000')
     drawing.fill_opacity = 0.5
     drawing.text(0, 0, text)
     # then the text
     drawing.translate(-offset, offset)
     drawing.fill_color = Color('#fff')
     drawing.fill_opacity = 1.0
     drawing.stroke_color = Color('#000')
     drawing.stroke_width = max(self.width / 600, 1)
     drawing.text(0, 0, text)
     return caption, drawing
Пример #2
0
 def _caption_sanandreas(self):
     caption = self.text
     drawing = Drawing()
     drawing.font = 'assets/fonts/TwCenMTStd-ExtraBold.otf'
     drawing.font_size = self.width / 20
     drawing.text_interline_spacing = drawing.font_size / 5
     drawing.fill_opacity = 0.8
     drawing.gravity = 'south'
     text = fill(caption, 30)
     drawing.fill_color = Color('#000')
     offset = drawing.font_size / 12
     drawing.translate(offset, self.height / 15)
     drawing.text(0, 0, text)
     drawing.translate(-offset, offset)
     drawing.fill_color = Color('#eee')
     drawing.text(0, 0, text)
     return caption, drawing
Пример #3
0
img.type = 'truecolor'
img.alpha_channel = 'activate'

# Determine the range of binsource lines we need to use.  We're guaranteed
# they're all in the binsource lines[] array.
if bankNumber < 4:
    bankNumber = bankNumber ^ 2
startIndex = bankNumber * 4 * 8 * 4 + pageInBank * 4 * 8
endIndex = startIndex + 4 * 8

draw = Drawing()
evilColor = Color("#FF00FF")
extraColor = Color("#FF8000")
draw.stroke_color = evilColor
draw.stroke_width = 4
draw.fill_opacity = 0

# Draw empty frames around all of the rejected boxes.
for i in range(0, len(rejectedBoxes)):
    boxFields = rejectedBoxes[i].split()
    boxLeft = int(boxFields[1])
    boxBottom = backgroundHeight - 1 - int(boxFields[2])
    boxRight = int(boxFields[3])
    boxTop = backgroundHeight - 1 - int(boxFields[4])
    draw.line((boxLeft, boxTop), (boxRight, boxTop))
    draw.line((boxLeft, boxBottom), (boxRight, boxBottom))
    draw.line((boxRight, boxTop), (boxRight, boxBottom))
    draw.line((boxLeft, boxTop), (boxLeft, boxBottom))

# Loop on lines on the selected page.  We're going to assume that the boxes are
# in 1-to-1 correspondence with the binsource digit, in the order read from
Пример #4
0
		else:
#			syslog.syslog(syslog.LOG_INFO, 'Setting Night Parameters')
			F.SetCamera(cam,NightSettings)
#		syslog.syslog(syslog.LOG_INFO, 'Taking Photo')
		cam.capture(Settings['FTPFile'])

		img = Image(filename=Settings['FTPFile'])
		OverImg = Image(filename='/boot/TMLogo.png')

		draw = Drawing()
		draw.composite(operator='over',left=img.width - OverImg.width - 5,top=5,width=OverImg.width,height=OverImg.height,image=OverImg)
		draw(img)

                draw = Drawing()
                draw.fill_color = Color('blue')
		draw.fill_opacity = 0.5
		draw.rectangle(0,img.height - 30,img.width,img.height)
                draw(img)

		draw = Drawing()
		draw.font = 'wandtests/assets/League_Gothic.otf'
		draw.font_size = 20
		draw.fill_color = Color('white')
		draw.text_alignment = 'left'
		draw.text(5, img.height - 5, Settings['Description'])
		draw(img)

		draw = Drawing()
		draw.font = 'wandtests/assets/League_Gothic.otf'
		draw.font_size = 20
		draw.fill_color = Color('white')
Пример #5
0
    def draw_box(self, progress_tracker=None):
        if not self.check_paper_layout():
            return None

        tuckbox_dimensions = ['width', 'height', 'depth']
        paper_dimensions = ['width', 'height']
        if ((not all(dimension in self.tuckbox for dimension in tuckbox_dimensions)) or
            (not all(dimension in self.paper for dimension in paper_dimensions))):
            return None

        # How much white space on the sides
        margin_height = (self.paper['height'] - self.pattern_height()) / 2
        margin_width = (self.paper['width'] - self.pattern_width()) / 2

        # Main box draw
        draw = Drawing()
        draw.scale(POINT_PER_MM, POINT_PER_MM)
        draw.stroke_color = Color('black')
        draw.stroke_width = RESOLUTION / (200 * POINT_PER_MM)
        draw.fill_opacity = 0
        draw.translate(margin_width,
                       margin_height + self.lip_size() + self.tuckbox['depth'])
        draw.push()

        # Finger holds draw
        finger_draw = Drawing(draw)
        finger_draw.fill_opacity = 1
        finger_draw.fill_color = Color('white')
        finger_draw.push()

        # Dashed draw
        dashed_draw = Drawing(draw)
        dash_array = [min(self.tuckbox['depth'], self.tuckbox['width'],
                          self.tuckbox['height'])/13] * 2
        dashed_draw.stroke_color = Color('rgb(100,100,100)')
        dashed_draw.fill_opacity = 0
        dashed_draw.stroke_width = RESOLUTION / (300 * POINT_PER_MM)
        dashed_draw.stroke_dash_array = dash_array
        dashed_draw.stroke_dash_offset = 1

        # Folding guides draw
        folding_guides_draw = Drawing()
        folding_guides_draw.scale(POINT_PER_MM, POINT_PER_MM)
        folding_guides_draw.stroke_color = Color('black')
        folding_guides_draw.stroke_width = RESOLUTION / (200 * POINT_PER_MM)

        back_draw = Drawing(draw)
        back_dashed_draw = Drawing(dashed_draw)
        back_folding_guides_draw = Drawing(folding_guides_draw)

        if progress_tracker is not None:
            progress_tracker(5)

        two_openings = 'two_openings' in self.options and self.options['two_openings']
        two_pages = 'two_pages' in self.options and self.options['two_pages']

        dash_array = [min(self.tuckbox['depth'], self.tuckbox['width'],
                          self.tuckbox['height'])/13] * 2

        #
        # Draw the box (or the first page)
        #
        self.draw_front(draw, dashed_draw, two_openings)

        if two_pages:
            offset_left_to_back = self.tuckbox['depth']
        else:
            offset_left_to_back = self.tuckbox['depth']*2 + self.tuckbox['width']

        self.draw_back(offset_left_to_back, back_draw, back_dashed_draw, finger_draw, two_openings)

        if two_pages:
            back_draw.polyline([(self.tuckbox['depth'], 0),
                           (self.tuckbox['depth'] * 0.2, 0),
                           (self.tuckbox['depth'] * 0.2, self.tuckbox['height']),
                           (self.tuckbox['depth'], self.tuckbox['height'])])
            draw.line((self.tuckbox['depth']*2 + self.tuckbox['width'], 0),
                      (self.tuckbox['depth']*2 + self.tuckbox['width'], self.tuckbox['height']))

        if progress_tracker is not None:
            progress_tracker(10)

        # Create the image
        image = Image(width=math.ceil(self.paper['width'] * POINT_PER_MM),
                      height=math.ceil(self.paper['height'] * POINT_PER_MM),
                      background=Color('white'))
        image.resolution = RESOLUTION
        image.unit = 'pixelsperinch'

        if two_pages:
            image2 = Image(width=math.ceil(self.paper['width'] * POINT_PER_MM),
                        height=math.ceil(self.paper['height'] * POINT_PER_MM),
                        background=Color('white'))
            image2.resolution = RESOLUTION
            image2.unit = 'pixelsperinch'
        else:
            image2 = image

        # Draw the faces
        self.draw_faces(image, progress_tracker, with_back = not two_pages)
        if two_pages:
            self.draw_faces(image2, progress_tracker, only_back=True)

        # Draw the lip(s)
        lip = self.draw_lip(top=True)
        if lip is not None:
            image.composite(lip,
                            math.floor((margin_width + self.tuckbox['depth']) * POINT_PER_MM),
                            math.floor((margin_height) * POINT_PER_MM))

        if two_openings:
            lip = self.draw_lip(bottom=True)
            if lip is not None:
                image.composite(lip,
                                math.floor((margin_width + self.tuckbox['depth']) * POINT_PER_MM),
                                math.floor((margin_height + self.tuckbox['depth']*2 + self.lip_size() + self.tuckbox['height']) * POINT_PER_MM))

        if progress_tracker is not None:
            progress_tracker(80)

        # Draw all the lines over
        draw.draw(image)
        back_draw.draw(image2)

        finger_draw.draw(image2)
        self.draw_watermark(image)
        if two_pages:
            self.draw_watermark(image2)

        if progress_tracker is not None:
            progress_tracker(90)

        if "folds_dashed" in self.options and self.options["folds_dashed"]:
            dashed_draw.draw(image)
            back_dashed_draw.draw(image2)

        if "folding_guides" in self.options and self.options["folding_guides"]:
            front_vertical_folds = [margin_width + self.tuckbox['depth'],
                              margin_width +
                              self.tuckbox['depth'] + self.tuckbox['width']]
            if not two_pages:
                front_vertical_folds.extend([margin_width +
                                       self.tuckbox['depth']*2 + self.tuckbox['width'],
                                       margin_width + self.tuckbox['depth']*2 + self.tuckbox['width']*2])

            back_vertical_folds = [margin_width + self.tuckbox['depth'],
                                  margin_width +
                                  self.tuckbox['depth'] + self.tuckbox['width']]

            front_horizontal_folds = [margin_height + self.lip_size(),
                                margin_height + self.lip_size() +
                                self.tuckbox['depth'],
                                margin_height + self.lip_size() +
                                self.tuckbox['depth'] + self.tuckbox['height']]

            if two_openings:
                front_horizontal_folds.append(margin_height + self.lip_size() +
                                        self.tuckbox['depth'] * 2 + self.tuckbox['height'])
                back_horizontal_folds = []
            else:
                back_horizontal_folds = [margin_height + self.lip_size() +
                                        self.tuckbox['depth'] + self.tuckbox['height']]

            self.draw_folds(folding_guides_draw, front_vertical_folds, front_horizontal_folds, margin_height, margin_width)
            self.draw_folds(back_folding_guides_draw, back_vertical_folds, back_horizontal_folds, margin_height, margin_width)

            folding_guides_draw.draw(image)
            back_folding_guides_draw.draw(image2)

        if progress_tracker is not None:
            progress_tracker(100)

        if not two_pages:
            image2 = None

        return image, image2