mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix drawTiledPixmap() to use the correct origin
This commit is contained in:
parent
ed89e9b465
commit
88a13dc8ee
@ -153,12 +153,12 @@ class PdfEngine(QPaintEngine):
|
|||||||
def drawTiledPixmap(self, rect, pixmap, point):
|
def drawTiledPixmap(self, rect, pixmap, point):
|
||||||
self.apply_graphics_state()
|
self.apply_graphics_state()
|
||||||
brush = QBrush(pixmap)
|
brush = QBrush(pixmap)
|
||||||
|
bl = rect.topLeft()
|
||||||
color, opacity, pattern, do_fill = self.graphics.convert_brush(
|
color, opacity, pattern, do_fill = self.graphics.convert_brush(
|
||||||
brush, -point, 1.0, self.pdf, self.pdf_system,
|
brush, bl-point, 1.0, self.pdf, self.pdf_system,
|
||||||
self.painter().transform())
|
self.painter().transform())
|
||||||
self.pdf.save_stack()
|
self.pdf.save_stack()
|
||||||
self.pdf.apply_fill(color, pattern)
|
self.pdf.apply_fill(color, pattern)
|
||||||
bl = rect.topLeft()
|
|
||||||
self.pdf.draw_rect(bl.x(), bl.y(), rect.width(), rect.height(),
|
self.pdf.draw_rect(bl.x(), bl.y(), rect.width(), rect.height(),
|
||||||
stroke=False, fill=True)
|
stroke=False, fill=True)
|
||||||
self.pdf.restore_stack()
|
self.pdf.restore_stack()
|
||||||
|
@ -11,8 +11,9 @@ import os
|
|||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
|
|
||||||
from PyQt4.Qt import (QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF,
|
from PyQt4.Qt import (QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF,
|
||||||
QApplication, QPainter, Qt, QImage)
|
QApplication, QPainter, Qt, QImage, QLinearGradient,
|
||||||
QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF, Qt
|
QPointF)
|
||||||
|
QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF, Qt, QPointF
|
||||||
|
|
||||||
from calibre.ebooks.pdf.render.engine import PdfDevice
|
from calibre.ebooks.pdf.render.engine import PdfDevice
|
||||||
|
|
||||||
@ -66,7 +67,14 @@ def full(dev):
|
|||||||
w = xmax/4
|
w = xmax/4
|
||||||
p.fillRect(0, ymax/3, w, w, b)
|
p.fillRect(0, ymax/3, w, w, b)
|
||||||
p.fillRect(xmax/3, ymax/3, w, w, QBrush(pix))
|
p.fillRect(xmax/3, ymax/3, w, w, QBrush(pix))
|
||||||
p.drawTiledPixmap(QRectF(2*xmax/3, ymax/3, w, w), pix)
|
x, y = 2*xmax/3, ymax/3
|
||||||
|
p.drawTiledPixmap(QRectF(x, y, w, w), pix, QPointF(10, 10))
|
||||||
|
|
||||||
|
x, y = 1, ymax/1.9
|
||||||
|
g = QLinearGradient(QPointF(x, y), QPointF(x+w, y+w))
|
||||||
|
g.setColorAt(0, QColor('#00f'))
|
||||||
|
g.setColorAt(1, QColor('#006'))
|
||||||
|
p.fillRect(x, y, w, w, QBrush(g))
|
||||||
finally:
|
finally:
|
||||||
p.end()
|
p.end()
|
||||||
if isinstance(dev, PdfDevice):
|
if isinstance(dev, PdfDevice):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user