Esempio n. 1
0
Kross::Api::Object::Ptr KritaCoreFactory::newRectBrush(Kross::Api::List::Ptr args)
{
    uint w = QMAX(1, Kross::Api::Variant::toUInt(args->item(0)));
    uint h = QMAX(1, Kross::Api::Variant::toUInt(args->item(1)));
    uint hf = 0;
    uint vf = 0;
    if( args.count() > 2)
    {
        hf = Kross::Api::Variant::toUInt(args->item(2));
        vf = Kross::Api::Variant::toUInt(args->item(3));
    }
    KisAutobrushShape* kas = new KisAutobrushRectShape(w, h, hf, vf);
    QImage* brsh = new QImage();
    kas->createBrush(brsh);
    return new Brush(new KisAutobrushResource(*brsh), false);;
}
Esempio n. 2
0
Kross::Api::Object::Ptr Filter::process(Kross::Api::List::Ptr args)
{
    PaintLayer* src = (PaintLayer*)args->item(0).data();
    if(!m_filter->workWith( src->paintLayer()->paintDevice()->colorSpace()))
    {
        throw Kross::Api::Exception::Ptr( new Kross::Api::Exception( i18n("An error has occured in %1").arg("process") ) );
    }
    QRect rect;
    if( args->count() >1)
    {
        uint x = Kross::Api::Variant::toVariant(args->item(1)).toUInt();
        uint y = Kross::Api::Variant::toVariant(args->item(2)).toUInt();
        uint w = Kross::Api::Variant::toVariant(args->item(3)).toUInt();
        uint h = Kross::Api::Variant::toVariant(args->item(4)).toUInt();
        rect = QRect(x, y, w, h);
    } else {
        QRect r1 = src->paintLayer()->paintDevice()->extent();
        QRect r2 = src->paintLayer()->image()->bounds();
        rect = r1.intersect(r2);
    }
    m_filter->process( src->paintLayer()->paintDevice(), src->paintLayer()->paintDevice(), m_config->filterConfiguration(), rect );
    return 0;
}