示例#1
0
 def _loadNoteHead(cls, headname):
     imageName = headname.title()
     imageName = headname[0] + imageName[1:]
     imageName = imageName.replace(" ", "")
     image = QPixmap(":/heads/GUI/Notation/%sHead.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._heads[headname] = image
示例#2
0
    def paintEvent(self, *args):
        #TODO OPTIMISE FOR MULTIPLE REPETITIVE CALL
        super().paintEvent(*args)
        if self.current_silhouette is not None:
            # Génération du QPainter
            print("update started")
            painter = QPainter(self)
            # Effacer la pose précédente
            painter.eraseRect(self.rect())

            # get x axis coordonate of the center of the player 1st on the left
            left_center = self.player_rect.left(
            ) + 0.5 * self.player_rect.width() - self.player_pixel_spacing * (
                len(self.current_silhouette) - 1) * 0.5

            n = len(self.current_silhouette)
            for k in random.sample(range(n), n):
                vertical_random = self.vertical_random_ratio * self.pose_hauteur * random.random(
                )
                new_pixmap = QPixmap(self.pose_largeur, self.pose_hauteur)
                new_pixmap.fill(self.colors[k])
                new_pixmap.setMask(self.current_silhouette[k].pixmap.scaled(
                    self.pose_largeur, self.pose_hauteur).mask())
                painter.drawPixmap(
                    int(left_center + k * self.player_pixel_spacing -
                        (self.pose_largeur * 0.5)),
                    self.player_rect.top() + vertical_random,
                    self.pose_largeur, self.pose_hauteur, new_pixmap)
示例#3
0
 def _loadNoteHead(cls, headname):
     imageName = headname.title()
     imageName = headname[0] + imageName[1:]
     imageName = imageName.replace(" ", "")
     image = QPixmap(":/heads/GUI/Notation/%sHead.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._heads[headname] = image
示例#4
0
def bmp_to_pixmap(path):
    absolute_path = os.path.join(ProgramPath.program_path(), path)
    pixmap = QPixmap(absolute_path)
    mask1 = pixmap.createMaskFromColor(QColor(0xFF, 0x00, 0XF0), Qt.MaskInColor)
    pixmap.setMask(mask1)

    return pixmap
示例#5
0
文件: __init__.py 项目: geckoblu/kang
def getPixmap(fileStr):
    """Return a QPixmap instance for the file fileStr relative
    to the binary location and residing in it's 'images' subdirectory"""

    imagepath = os.path.join(os.path.dirname(__file__), fileStr)

    pixmap = QPixmap(imagepath)
    pixmap.setMask(pixmap.createHeuristicMask(1))

    return pixmap
示例#6
0
 def adjust_widget(self):
     self.setAttribute(Qt.WA_KeyCompression,False)
     self.setMouseTracking(True)
     self.setFocus()
     
     px = QPixmap(32,32)
     px.fill()
     px.setMask(px.createHeuristicMask())
     
     self.setCursor(QCursor(px))
示例#7
0
 def _loadFlam(cls, headname):
     if STEM_UP not in cls._flams:
         cls._flams[STEM_UP] = {}
     if STEM_DOWN not in cls._flams:
         cls._flams[STEM_DOWN] = {}
     imageName = headname.capitalize()
     imageName = imageName.replace(" ", "")
     image = QPixmap(":/heads/GUI/Notation/Flam_Up_%s.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._flams[STEM_UP][headname] = image
     image = QPixmap(":/heads/GUI/Notation/Flam_Down_%s.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._flams[STEM_DOWN][headname] = image
示例#8
0
def bmp_to_pixmap(path):
    if image_data is not None:
        data = QByteArray.fromBase64(image_data[path][1])
        pixmap = QPixmap()
        pixmap.loadFromData(data, image_data[path][0])
    else:
        absolute_path = os.path.join(get_program_path(), path)
        pixmap = QPixmap(absolute_path)

    mask1 = pixmap.createMaskFromColor(QColor(0xFF, 0x00, 0xF0), Qt.MaskInColor)
    pixmap.setMask(mask1)

    return pixmap
示例#9
0
 def _loadFlam(cls, headname):
     if STEM_UP not in cls._flams:
         cls._flams[STEM_UP] = {}
     if STEM_DOWN not in cls._flams:
         cls._flams[STEM_DOWN] = {}
     imageName = headname.capitalize()
     imageName = imageName.replace(" ", "")
     image = QPixmap(":/heads/GUI/Notation/Flam_Up_%s.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._flams[STEM_UP][headname] = image
     image = QPixmap(":/heads/GUI/Notation/Flam_Down_%s.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._flams[STEM_DOWN][headname] = image
示例#10
0
    def repaint_poses(self, toggle_index):
        painter = QPainter(self.toggle_cache_pixmap[toggle_index])
        #painter.eraseRect(self.rect())
        painter.fillRect(self.rect(), QColor(self.alpha_color))

        if self.current_silhouette is not None:

            left_center = self.player_rect.left(
            ) + 0.5 * self.player_rect.width() - self.player_pixel_spacing * (
                len(self.current_silhouette) - 1) * 0.5

            for k in self.order:
                new_pixmap = QPixmap(self.pose_largeur, self.pose_hauteur)
                new_pixmap.fill(self.toggle_colors[toggle_index][k])
                new_pixmap.setMask(self.current_silhouette[k].pixmap.scaled(
                    self.pose_largeur, self.pose_hauteur).mask())
                painter.drawPixmap(
                    int(left_center + k * self.player_pixel_spacing -
                        (self.pose_largeur * 0.5)),
                    self.player_rect.top() + self.vertical_random[k],
                    self.pose_largeur, self.pose_hauteur, new_pixmap)
        painter.end()
示例#11
0
    def mouseMoveEvent(self, event):
        drag = QDrag(event.widget())
        data = QMimeData()
        data.setText(self.commit.name())

        drag.setMimeData(data)

        #data.setColorData(GREEN)
        pixmap = QPixmap(COMMIT_WIDTH, COMMIT_HEIGHT)
        pixmap.fill(WHITE)
        painter = QPainter(pixmap)
        painter.translate(0, 0)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setPen(Qt.NoPen)
        painter.setBrush(QBrush(self.color))
        painter.drawPath(self.setup_display(0, 0))
        painter.end()

        pixmap.setMask(pixmap.createHeuristicMask())
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(0, 0))
        drag.start()
示例#12
0
 def _loadEffect(cls, effectname):
     imageName = effectname.capitalize()
     image = QPixmap(":/heads/GUI/Notation/Effect_%s.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._effects[effectname] = image
示例#13
0
 def _loadEffect(cls, effectname):
     imageName = effectname.capitalize()
     image = QPixmap(":/heads/GUI/Notation/Effect_%s.png" % imageName)
     image.setMask(image.createHeuristicMask())
     cls._effects[effectname] = image