Пример #1
0
    def __init__(self, avatar_file, name, task):
        super(ContributorView, self).__init__()
        layout = QtWidgets.QGridLayout()
        layout.setHorizontalSpacing(12)
        layout.setContentsMargins(0, 0, 0, 0)

        # Make rounded avatar bitmap
        avatar_pixmap = QtGui.QPixmap(avatar_file)
        bitmap = QtGui.QBitmap(avatar_pixmap.width(), avatar_pixmap.height())
        bitmap.fill(QtCore.Qt.color0)
        p = QtGui.QPainter(bitmap)
        p.setBrush(QtCore.Qt.color1)
        p.drawRoundedRect(0, 0, bitmap.width(), bitmap.height(),
                          bitmap.width() / 2,
                          bitmap.height() / 2)
        avatar_pixmap.setMask(bitmap)
        p.end()

        self.avatar_label = QtWidgets.QLabel()
        self.avatar_label.setPixmap(avatar_pixmap)
        self.avatar_label.setScaledContents(True)
        self.avatar_label.setObjectName("roundedAvatar")
        layout.addWidget(self.avatar_label, 0, 0, 2, 1)

        self.name_label = QtWidgets.QLabel(name)
        layout.addWidget(self.name_label, 0, 1)

        self.task_label = QtWidgets.QLabel(task)
        self.task_label.setObjectName("fontFaint")
        layout.addWidget(self.task_label, 1, 1)

        self.setLayout(layout)
Пример #2
0
 def __mergeImages(imagePaths):
     """
     Combines a list of images into one image. Used for combining manacost 
     images.
     """
     
     firstImage = QtGui.QPixmap(imagePaths[0])
     width = firstImage.width()
     height = firstImage.height()
     
     mergedImage = QtGui.QPixmap(width * len(imagePaths), height)
     bitMap = QtGui.QBitmap(mergedImage)
     bitMap.clear()
     mergedImage.setMask(bitMap)
     painter = QtGui.QPainter(mergedImage)
     
     topleft = (0, 0)
     
     for imagePath in imagePaths:
         image = QtGui.QPixmap(imagePath)
         rect = QtCore.QRect(topleft[0], topleft[1], width, height)
         painter.drawPixmap(rect, image, image.rect())
         
         topleft = (topleft[0] + width, topleft[1])
     
     return mergedImage
Пример #3
0
 def pixmap(self, QSize, QIcon_Mode=None, QIcon_State=None):
     pm = QtGui.QIconEngine.pixmap(self, QSize, QIcon_Mode, QIcon_State)
     if self.mask:
         pm.setMask(
             QtGui.QBitmap(
                 self.mask.scaled(QSize, QtCore.Qt.KeepAspectRatio)))
     return pm
Пример #4
0
    def move(self, event):
        """ Mouse is moving """
        if self.figure.canvas.toolbar._active is None:
            vlim = self.axes.viewLim
            dlim = self.axes.dataLim
            tmp0 = self.axes.transData.transform((vlim.x0, vlim.y0))
            tmp1 = self.axes.transData.transform((vlim.x1, vlim.y1))
            width, height = tmp1 - tmp0
            width /= self.mdata.shape[1]
            height /= self.mdata.shape[0]
            width *= dlim.width / vlim.width
            height *= dlim.height / vlim.height
            cwidth = (2 * self.mywidth - 1)
            cb = QtGui.QBitmap(cwidth * width, cwidth * height)
            cb.fill(QtCore.Qt.color1)
            self.setCursor(QtGui.QCursor(cb))

        if event.inaxes == self.axes and self.press is True:
            row = int((event.ydata - self.lmod.zrange[0]) / self.lmod.d_z) + 1
            col = int((event.xdata) / self.lmod.dxy)

            aaa = self.axes.get_xbound()[-1]
            bbb = self.mdata.shape[1]
            ccc = aaa / bbb
            col = int((event.xdata) / ccc)

            xdata = col
            ydata = row

            if self.newline is True:
                self.newline = False
                self.set_mdata(xdata, ydata)
            elif xdata != self.xold:
                mmm = float(ydata - self.yold) / (xdata - self.xold)
                ccc = ydata - mmm * xdata
                x_1 = min([self.xold, xdata])
                x_2 = max([self.xold, xdata])
                for i in range(x_1 + 1, x_2 + 1):
                    jold = int(mmm * (i - 1) + ccc)
                    jnew = int(mmm * i + ccc)
                    if jold > jnew:
                        jold, jnew = jnew, jold
                    for j in range(jold, jnew + 1):
                        self.set_mdata(i, j)

            elif ydata != self.yold:
                y_1 = min([self.yold, ydata])
                y_2 = max([self.yold, ydata])
                for j in range(y_1, y_2 + 1):
                    self.set_mdata(xdata, j)

            self.xold = xdata
            self.yold = ydata

            self.slide_grid(self.mdata)
Пример #5
0
def createBrushes():

    circles = []
    brushes = []

    for i in range(9):
        m, im = createCircle(i)
        circles.append(m)
        pm = QtGui.QBitmap().fromImage(im)
        brushes.append(pm)

    return circles, brushes
Пример #6
0
 def fillImage(self, pixmap, painter, roi, param, source):
     """Draw image in roi.
     """
     x, y, w, h = roi
     fillPixmap = QPixmap(param.fillPath)
     if not fillPixmap.isNull():
         fillPixmap = fillPixmap.scaled(w, h, QtCore.Qt.IgnoreAspectRatio)
         mask = self.getMask(pixmap, x, y, w, h, param.shape, None,
                             QtCore.Qt.white, QtCore.Qt.black)
         painter.setClipRegion(QtGui.QRegion(QtGui.QBitmap(mask)))
         painter.drawPixmap(x, y, fillPixmap)
         painter.setClipping(False)
Пример #7
0
def main():
    """
    Resets Sprites.py to its original settings
    """
    global OutlineColor, OutlinePen, OutlineBrush, TileAlphaColors
    OutlinePen = QtGui.QPen(OutlineColor, 4)
    OutlineBrush = QtGui.QBrush(OutlineColor)

    for g, game in enumerate(['M1', 'M3', 'MW', 'WU']):
        for t, theme in enumerate([
                'overworld', 'underground', 'castle', 'airship', 'underwater',
                'hauntedhouse'
        ]):
            TileAlphaMasks[(g, t)] = QtGui.QBitmap(
                'metamakerdata/masks/%s_%s.png' % (game, theme))
Пример #8
0
    def InitUI(self):
        self.core = EmuCore()
        self.emu_thread = QtCore.QThread()
        self.core.moveToThread(self.emu_thread)

        self.open_act = QtWidgets.QAction('Open ROM', self)
        self.open_act.triggered.connect(Util.Launch)

        exit_act = QtWidgets.QAction('Exit', self)
        exit_act.triggered.connect(self.emu_thread.quit)
        exit_act.triggered.connect(QtWidgets.qApp.quit)
        """ self.save_act = QtWidgets.QAction('Save state', self)
        self.save_act.triggered.connect(self.core.sys8.SaveState)
        self.save_act.setEnabled(False)

        self.load_act = QtWidgets.QAction('Load state', self)
        self.load_act.triggered.connect(self.core.sys8.LoadState)
        self.load_act.setEnabled(False) """

        menubar = self.menuBar()
        filemenu = menubar.addMenu('File')
        filemenu.addAction(self.open_act)
        filemenu.addAction(exit_act)
        """ emumenu = menubar.addMenu('Emulation')
        emumenu.addAction(self.save_act)
        emumenu.addAction(self.load_act) """

        self.native = QtGui.QBitmap(64, 32)
        self.native.fill(QtCore.Qt.color1)
        self.scaled = QtWidgets.QLabel(self)
        self.scaled.setPixmap(
            self.native.scaled(1280, 640, QtCore.Qt.KeepAspectRatio))
        self.setCentralWidget(self.scaled)

        self.painter = QtGui.QPainter(self.native)
        self.painter.setPen(QtCore.Qt.color0)

        self.setGeometry(320, 210, 1280, 660)  # Improve this later
        self.setWindowTitle('PYHC-8')
        self.setWindowIcon(QtGui.QIcon('icon.bmp'))
        self.show()

        self.setFocusPolicy(QtCore.Qt.StrongFocus)
Пример #9
0
    def move(self, event):
        """ Mouse is moving """
        if self.figure.canvas.toolbar._active is None:
            vlim = self.axes.viewLim
            xptp = self.lmod.xrange[1] - self.lmod.xrange[0]
            yptp = self.lmod.yrange[1] - self.lmod.yrange[0]
            if xptp > 10000 or yptp > 10000:
                xptp /= 1000
                yptp /= 1000
            tmp0 = self.axes.transData.transform((vlim.x0, vlim.y0))
            tmp1 = self.axes.transData.transform((vlim.x1, vlim.y1))
            width, height = tmp1 - tmp0
            width /= self.mdata.shape[1]
            height /= self.mdata.shape[0]

            width *= xptp / vlim.width
            height *= yptp / vlim.height

            cwidth = (2 * self.mywidth - 1)
            cb = QtGui.QBitmap(cwidth * width, cwidth * height)
            cb.fill(QtCore.Qt.color1)
            self.setCursor(QtGui.QCursor(cb))

        if self.axes.xaxis.get_label_text().find('km') > -1:
            cdiv = 1000.
        else:
            cdiv = 1.

        dxy = self.lmod.dxy / cdiv
        xmin = self.lmod.xrange[0] / cdiv
        ymin = self.lmod.yrange[0] / cdiv

        if event.inaxes == self.axes and self.press is True:
            col = int((event.xdata - xmin) / dxy) + 1
            row = int((event.ydata - ymin) / dxy) + 1

            xdata = col
            ydata = row

            if self.newline is True:
                self.newline = False
                self.set_mdata(xdata, ydata)
            elif xdata != self.xold:
                mmm = float(ydata - self.yold) / (xdata - self.xold)
                ccc = ydata - mmm * xdata
                x_1 = min([self.xold, xdata])
                x_2 = max([self.xold, xdata])
                for i in range(x_1 + 1, x_2 + 1):
                    jold = int(mmm * (i - 1) + ccc)
                    jnew = int(mmm * i + ccc)
                    if jold > jnew:
                        jold, jnew = jnew, jold
                    for j in range(jold, jnew + 1):
                        self.set_mdata(i, j)

            elif ydata != self.yold:
                y_1 = min([self.yold, ydata])
                y_2 = max([self.yold, ydata])
                for j in range(y_1, y_2 + 1):
                    self.set_mdata(xdata, j)

            self.xold = xdata
            self.yold = ydata

            self.slide_grid(self.mdata)
Пример #10
0
 def resetBitmap(self):
     self.pix = QtGui.QBitmap(self.size())
     self.pix.fill(QtCore.Qt.black)  # 设置黑色背景