예제 #1
0
GraphicsContextState::GraphicsContextState()
    : m_strokeColor(Color::black)
    , m_fillColor(Color::black)
    , m_fillRule(RULE_NONZERO)
    , m_textDrawingMode(TextModeFill)
    , m_alpha(256)
    , m_compositeOperator(CompositeSourceOver)
    , m_blendMode(WebBlendModeNormal)
    , m_interpolationQuality(InterpolationDefault)
    , m_saveCount(0)
    , m_shouldAntialias(true)
    , m_shouldClampToSourceRect(true)
{
    m_strokePaint.setStyle(SkPaint::kStroke_Style);
    m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness()));
    m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
    m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap);
    m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join);
    m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit()));
    m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_interpolationQuality));
    m_strokePaint.setAntiAlias(m_shouldAntialias);
    m_fillPaint.setColor(applyAlpha(m_fillColor.rgb()));
    m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_interpolationQuality));
    m_fillPaint.setAntiAlias(m_shouldAntialias);
}
예제 #2
0
void GraphicsContextState::setAlphaAsFloat(float alpha)
{
    if (alpha < 0) {
        m_alpha = 0;
    } else {
        m_alpha = roundf(alpha * 256);
        if (m_alpha > 256)
            m_alpha = 256;
    }
    m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
    m_fillPaint.setColor(applyAlpha(m_fillColor.rgb()));
}
예제 #3
0
void ImageDrawing::fillGlyph(Image* image, int x, int y, TrueTypeFont::Glyph* glyph, int size, const RGBA& color, bool aa, ImageDrawing::AlphaCombineMode am) {
    for(uint32_t j = 0; j < glyph->contours.contours.size(); j++) {
        for(float cy = (glyph->yMin-0.5)*size; cy <= (glyph->yMax+0.5)*size; cy += 1.0) {
            vector<double> raster = glyph->contours.rasterize((glyph->xMin-1)*size, (glyph->xMax+1)*size, cy, size);
            if (raster.size() % 2 == 0) {
                bool inside = false;
                uint32_t i = 0;
                double alpha;
                for(int cx = (glyph->xMin-1)*size; cx <= (glyph->xMax+1)*size && i < raster.size(); cx++) {
                    if (raster[i] <= cx) {
                        alpha = fabs(raster[i]-double(cx));
                        if (inside) alpha = 1 - alpha;
                        inside = !inside;
                        i++;
                    } else {
                        alpha = 1;    
                    }
                    if (!aa) 
                        alpha = 1;
                    if (inside) {
                         pixel(image, cx+x, y-cy, applyAlpha(alpha,color), am);
                    }
                }
            } else {
                cout << "Skipping scanline" << endl;    
            }
        }
    }        
}
예제 #4
0
void GraphicsContextState::setStrokeColor(const Color& color)
{
    m_strokeGradient.clear();
    m_strokePattern.clear();
    m_strokeColor = color;
    m_strokePaint.setColor(applyAlpha(color.rgb()));
    m_strokePaint.setShader(0);
}
예제 #5
0
void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern)
{
    m_fillColor = Color::black;
    m_fillGradient.clear();
    m_fillPattern = pattern;
    m_fillPaint.setColor(applyAlpha(SK_ColorBLACK));
    m_fillPaint.setShader(m_fillPattern->shader());
}
예제 #6
0
void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient)
{
    m_fillColor = Color::black;
    m_fillPattern.clear();
    m_fillGradient = gradient;
    m_fillPaint.setColor(applyAlpha(SK_ColorBLACK));
    m_fillPaint.setShader(m_fillGradient->shader());
}
예제 #7
0
    void ScreenFader::notifyAlphaChanged(float alpha)
    {
        if (mCurrentAlpha == alpha)
            return;

        mCurrentAlpha = alpha;

        if (1.f-((1.f-mCurrentAlpha) * mFactor) == 0.f)
            mMainWidget->setVisible(false);
        else
            applyAlpha();
    }
예제 #8
0
    void ScreenFader::queue(float time, float targetAlpha, float delay)
    {
        if (time < 0.f)
            return;

        if (time == 0.f)
        {
            mCurrentAlpha = targetAlpha;
            applyAlpha();
            return;
        }

        mQueue.push_back(FadeOp::Ptr(new FadeOp(this, time, targetAlpha, delay)));
    }
예제 #9
0
파일: DrawAni.cpp 프로젝트: korman/Temp
bool DrawAni::doDraw(const int frameIndex, const AniModify* mod_lev2,
					 const AniModify* mod_lev3)
{
	if (!m_pkAni || !m_pkInstance || !m_pkInstance->getOwnerNode())
		return false;

	// get picture to draw
	NDPicture* pkPicture = getPicture(m_pkAni, frameIndex);
	if (!pkPicture)
		return false;

	// get node screen rect
	CCRect kNodeRect;
	NDNode* pkOwnerNode = m_pkInstance->getOwnerNode();

	if (pkOwnerNode->IsA(RTCLS(NDTileObj)))
	{
		NDTileObj* pkTileObj = (NDTileObj*) pkOwnerNode;
		if (pkTileObj->isPlayer() || pkTileObj->isPath())
			kNodeRect = pkOwnerNode->GetScreenRect();
		else
			kNodeRect = pkOwnerNode->GetPushScreenRect();
	}
	else
	{
		kNodeRect = pkOwnerNode->GetScreenRect();
	}

	// node center pos (caution: world map tile obj!)
	CCPoint centerPos = CCPointMake(
		kNodeRect.origin.x + kNodeRect.size.width * 0.5f,
		kNodeRect.origin.y + kNodeRect.size.height * 0.5f);

	// get node scale (recursive)
	float nodeScaleX = pkOwnerNode->GetScaleX_R();
	float nodeScaleY = pkOwnerNode->GetScaleY_R();

	// add offset
	int sign = pkOwnerNode->isReverse() ? -1 : 1;
	centerPos.x += m_pkAni->m_kAniModifyEx.getOffsetX() * COORD_SCALE_X_960 * nodeScaleX
		* sign;
	centerPos.y += m_pkAni->m_kAniModifyEx.getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY;

	// apply mod: offset
	if (mod_lev2)
	{
		centerPos.x += mod_lev2->getOffsetX() * COORD_SCALE_X_960 * nodeScaleX
			* sign;
		centerPos.y += mod_lev2->getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY;
	}
	if (mod_lev3)
	{
		centerPos.x += mod_lev3->getOffsetX() * COORD_SCALE_X_960 * nodeScaleX
			* sign;
		centerPos.y += mod_lev3->getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY;
	}

	// calculate pic size
	CCSize picSize = pkPicture->GetSize();
	if (m_pkAni->m_kAniModifyEx.getStretch())
	{
		picSize.width *= COORD_SCALE_X_960;
		picSize.height *= COORD_SCALE_Y_960;
	}
	else
	{
		picSize.width *= RESOURCE_SCALE_960;
		picSize.height *= RESOURCE_SCALE_960;
	}

	if (m_pkAni->m_kAniModifyEx.getFullScreen())
	{
		// apply fullscreen 
		picSize = CCDirector::sharedDirector()->getWinSizeInPixels();
	}
	else
	{
		// size override
		if (m_pkAni->m_kAniModifyEx.sizeOverride())
		{
			picSize = CCSizeMake(m_pkAni->m_kAniModifyEx.getWidth(), m_pkAni->m_kAniModifyEx.getHeight());
		}

		// apply node scale
		picSize.width *= nodeScaleX;
		picSize.height *= nodeScaleY;

		// apply scale
		picSize.width *= m_pkAni->m_kAniModifyEx.getScale();
		picSize.height *= m_pkAni->m_kAniModifyEx.getScale();

		// apply mod: scale
		if (mod_lev2)
		{
			picSize.width *= mod_lev2->getScale();
			picSize.height *= mod_lev2->getScale();
		}
		if (mod_lev3)
		{
			picSize.width *= mod_lev3->getScale();
			picSize.height *= mod_lev3->getScale();
		}
	}

	// apply alpha
	applyAlpha(pkPicture, mod_lev2);

	// apply HSL
	applyHSL(pkPicture, mod_lev2);

	// target rect to draw in
	CCRect picRect = CCRectMake(centerPos.x - picSize.width * 0.5f,
		centerPos.y - picSize.height * 0.5f, picSize.width, picSize.height);

	// check to disable scissor
	if (!isAllowScissor())
	{
		NDDirector::DefaultDirector()->DisableScissor();
	}

	// draw
	if (m_pkInstance && m_pkInstance->getOwnerNode())
	{
		// apply from action: opacity/rotation/gaussianBlur
		NDNode* pkOwnerNode = m_pkInstance->getOwnerNode();
		pkPicture->SetOpacity(pkOwnerNode->getRGBA()->getOpacity());
		pkPicture->SetRotation(pkOwnerNode->getCCNode()->getRotation());
		pkPicture->SetRotationX(pkOwnerNode->getCCNode()->getRotationX());
		pkPicture->SetRotationY(pkOwnerNode->getCCNode()->getRotationY());
		pkPicture->setGaussianBlur(pkOwnerNode->getCCNode()->getGaussianBlur());

		// toggle reverse
		bool bReverse = m_pkAni->m_kAniModifyEx.getReverse();
		if (pkOwnerNode->isReverse())
			bReverse = !bReverse;
		pkPicture->SetReverse(bReverse);
	}
	pkPicture->DrawInRect(picRect);
}
예제 #10
0
void GraphicsContextState::clearFillPattern()
{
    m_fillPattern.clear();
    ASSERT(!m_fillGradient);
    m_fillPaint.setColor(applyAlpha(m_fillColor.rgb()));
}
예제 #11
0
void GraphicsContextState::clearStrokePattern()
{
    m_strokePattern.clear();
    ASSERT(!m_strokeGradient);
    m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
}
예제 #12
0
 void ScreenFader::setFactor(float factor)
 {
     mFactor = factor;
     applyAlpha();
 }