Пример #1
0
void AlphaMask::draw(){
    ofApp *app = ((ofApp*)ofGetAppPtr());
    
    ofPushMatrix();
    ofTranslate(960, 0);
    // Circle Mask (Full HD or 1980 x 630)
    
    if (app->screenMode == 0 || app->screenMode == 1) {
        maskCircle();
    }
    if (app->screenMode == 2) {
        maskRect();
    }
    
    // Rect mask in 1980 x 630
    // Top & Bottom mask
    if (app->screenMode == 1 || app->screenMode == 2) {
        ofSetColor(0);
        ofSetRectMode(OF_RECTMODE_CORNER);
        ofPushMatrix();
        ofRect(0, 0, 1920, 224);
        ofTranslate(0, 630 + 224);
        ofRect(0, 0, 1920, 300);
        ofPopMatrix();
    }
    ofPopMatrix();
}
Пример #2
0
BoxReflection boxReflectionForPaintLayer(const PaintLayer& layer,
                                         const ComputedStyle& style) {
  const StyleReflection* reflectStyle = style.boxReflect();

  LayoutRect frameLayoutRect = toLayoutBox(layer.layoutObject())->frameRect();
  FloatRect frameRect(frameLayoutRect);
  BoxReflection::ReflectionDirection direction =
      BoxReflection::VerticalReflection;
  float offset = 0;
  switch (reflectStyle->direction()) {
    case ReflectionAbove:
      direction = BoxReflection::VerticalReflection;
      offset = -floatValueForLength(reflectStyle->offset(), frameRect.height());
      break;
    case ReflectionBelow:
      direction = BoxReflection::VerticalReflection;
      offset = 2 * frameRect.height() +
               floatValueForLength(reflectStyle->offset(), frameRect.height());
      break;
    case ReflectionLeft:
      direction = BoxReflection::HorizontalReflection;
      offset = -floatValueForLength(reflectStyle->offset(), frameRect.width());
      break;
    case ReflectionRight:
      direction = BoxReflection::HorizontalReflection;
      offset = 2 * frameRect.width() +
               floatValueForLength(reflectStyle->offset(), frameRect.width());
      break;
  }

  sk_sp<SkPicture> mask;
  const NinePieceImage& maskNinePiece = reflectStyle->mask();
  if (maskNinePiece.hasImage()) {
    LayoutRect maskRect(LayoutPoint(), frameLayoutRect.size());
    LayoutRect maskBoundingRect(maskRect);
    maskBoundingRect.expand(style.imageOutsets(maskNinePiece));
    FloatRect maskBoundingFloatRect(maskBoundingRect);

    // TODO(jbroman): SkPictureBuilder + DrawingRecorder seems excessive.
    // If NinePieceImagePainter operated on SkCanvas, we'd only need an
    // SkPictureRecorder here.
    SkPictureBuilder recorder(maskBoundingFloatRect);
    {
      GraphicsContext& context = recorder.context();
      DrawingRecorder drawingRecorder(context, *layer.layoutObject(),
                                      DisplayItem::kReflectionMask,
                                      maskBoundingFloatRect);
      NinePieceImagePainter(*layer.layoutObject())
          .paint(recorder.context(), maskRect, style, maskNinePiece,
                 SkXfermode::kSrcOver_Mode);
    }
    mask = recorder.endRecording();
  }

  return BoxReflection(direction, offset, std::move(mask));
}
void MainWindow::roundCorners()
{
#ifndef Q_OS_ANDROID
    QBitmap mask(size());
    if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
        mask.fill(Qt::black);
    } else {
        mask.fill();
        QPainter painter(&mask);
        QPainterPath path;
        QRect windowRect = mask.rect();
        QRect maskRect(windowRect.x(), windowRect.y(), windowRect.width(), windowRect.height());
        path.addRoundedRect(maskRect, S_CORNER_SIZE, S_CORNER_SIZE);
        painter.setRenderHint(QPainter::Antialiasing);

        painter.fillPath(path, Qt::black);
    }
    setMask(mask);
#endif
}
Пример #4
0
inline
KisFixedPaintDeviceSP KisDabCache::fetchDabCommon(const KoColorSpace *cs,
                                                  const KisColorSource *colorSource,
                                                  const KoColor& color,
                                                  double scaleX, double scaleY,
                                                  double angle,
                                                  const KisPaintInformation& info,
                                                  double subPixelX, double subPixelY,
                                                  qreal softnessFactor)
{
    if (!m_d->dab || !(*m_d->dab->colorSpace() == *cs)) {
        m_d->dab = new KisFixedPaintDevice(cs);
    } else {
        KisFixedPaintDeviceSP cachedDab =
            tryFetchFromCache(colorSource, color, scaleX, scaleY, angle,
                              info, subPixelX, subPixelY, softnessFactor);
        if (cachedDab) return cachedDab;
    }

    if (m_d->brush->brushType() == IMAGE || m_d->brush->brushType() == PIPE_IMAGE) {
        m_d->dab = m_d->brush->paintDevice(cs, scaleX, angle, info,
                                     subPixelX, subPixelY);
    }
    else {
        if (!colorSource) {
            KoColor paintColor = color;
            paintColor.convertTo(cs);

            *m_d->cachedDabParameters = getDabParameters(paintColor,
                                                      scaleX, scaleY,
                                                      angle, info,
                                                      subPixelX, subPixelY,
                                                      softnessFactor);

            m_d->brush->mask(m_d->dab, paintColor, scaleX, scaleY, angle,
                          info, subPixelX, subPixelY, softnessFactor);

        } else if (colorSource->isUniformColor()) {
            KoColor paintColor = colorSource->uniformColor();
            paintColor.convertTo(cs);

            *m_d->cachedDabParameters = getDabParameters(paintColor,
                                                      scaleX, scaleY,
                                                      angle, info,
                                                      subPixelX, subPixelY,
                                                      softnessFactor);

            m_d->brush->mask(m_d->dab, paintColor, scaleX, scaleY, angle,
                          info, subPixelX, subPixelY, softnessFactor);
        } else {
            if (!m_d->colorSourceDevice || !(*cs == *m_d->colorSourceDevice->colorSpace())) {
                m_d->colorSourceDevice = new KisPaintDevice(cs);
            } else {
                m_d->colorSourceDevice->clear();
            }

            QRect maskRect(0, 0, m_d->brush->maskWidth(scaleX, angle, info), m_d->brush->maskHeight(scaleY, angle, info));
            colorSource->colorize(m_d->colorSourceDevice, maskRect, info.pos().toPoint());
            delete m_d->colorSourceDevice->convertTo(cs);

            m_d->brush->mask(m_d->dab, m_d->colorSourceDevice, scaleX, scaleY, angle,
                          info, subPixelX, subPixelY, softnessFactor);
        }
    }

    if (needSeparateOriginal()) {
        if (!m_d->dabOriginal || !(*cs == *m_d->dabOriginal->colorSpace())) {
            m_d->dabOriginal = new KisFixedPaintDevice(cs);
        }

        *m_d->dabOriginal = *m_d->dab;
    }

    postProcessDab(m_d->dab, info);

    return m_d->dab;
}