コード例 #1
0
void GradientPreview::setGradient(const VGradient& gradient)
{
	if ((gradient.colorStops().count() == fill_gradient.colorStops().count()) && (ActStop >= 0))
	{
		int diffStops = 0;
		for (int i = 0; i < fill_gradient.colorStops().count(); ++i)
		{
			VColorStop* stop1 = gradient.colorStops().at(i);
			VColorStop* stop2 = fill_gradient.colorStops().at(i);
			if ((stop1->color != stop2->color) || (stop1->midPoint != stop2->midPoint) ||
				(stop1->name  != stop2->name)  || (stop1->opacity != stop2->opacity)   ||
				(stop1->rampPoint != stop2->rampPoint) || (stop1->shade != stop2->shade))
			{
				++diffStops;
			}
		}
		if (diffStops > 1)
			ActStop = 0;
	}
	if ((ActStop < 0) && (gradient.colorStops().count() > 0))
		ActStop = 0;
	if (ActStop >= gradient.colorStops().count())
		ActStop = 0;
	fill_gradient = gradient;
}
コード例 #2
0
ファイル: vgradient.cpp プロジェクト: HOST-Oman/scribus
bool VGradient::operator==(const VGradient &gradient) const 
{
	if (static_cast<uint>(m_colorStops.count()) != gradient.Stops())
		return false;
	QList<VColorStop*> cs = gradient.colorStops();
	bool retVal = true;
	for (int i = 0; i < m_colorStops.count(); ++i)
	{
		if (m_colorStops.at(i)->rampPoint != cs.at(i)->rampPoint)
		{
			retVal = false;
			break;
		}
		if (m_colorStops.at(i)->opacity != cs.at(i)->opacity)
		{
			retVal = false;
			break;
		}
		if (m_colorStops.at(i)->name != cs.at(i)->name)
		{
			retVal = false;
			break;
		}
		if (m_colorStops.at(i)->shade != cs.at(i)->shade)
		{
			retVal = false;
			break;
		}
	}
	return retVal;
}
コード例 #3
0
ファイル: vgradient.cpp プロジェクト: HOST-Oman/scribus
VGradient::VGradient( const VGradient& gradient )
{
	m_origin		= gradient.m_origin;
	m_focalPoint	= gradient.m_focalPoint;
	m_vector		= gradient.m_vector;
	m_type			= gradient.m_type;
	m_repeatMethod	= gradient.m_repeatMethod;
	clearStops();
	QList<VColorStop*> cs = gradient.colorStops();
	qStableSort(cs.begin(), cs.end(), compareStops);
	for( int i = 0; i < cs.count(); ++i)
		m_colorStops.append( new VColorStop( *cs[i] ) );
} // VGradient::VGradient
コード例 #4
0
VGradientEx::VGradientEx( const VGradient& gradient, ScribusDoc& doc )
{
	m_origin		= gradient.origin();
	m_focalPoint	= gradient.focalPoint();
	m_vector		= gradient.vector();
	m_type			= (VGradientEx::Type) gradient.type();
	m_repeatMethod	= (VGradientEx::RepeatMethod) gradient.repeatMethod();

	while (!m_colorStops.isEmpty())
		delete m_colorStops.takeFirst();
	QList<VColorStop*> stops = gradient.colorStops();
	qStableSort( stops.begin(), stops.end(), compareStops);
	for( int i = 0; i < stops.count(); ++i)
	{
		VColorStop stop( *stops[i] );
		ScColor color = doc.PageColors[stop.name];
		double ramp = stop.rampPoint;
		double mid = stop.midPoint;
		double opacity = stop.opacity;
		int shade = stop.shade;
		QString name = stop.name;
		m_colorStops.append( new VColorStopEx(ramp, mid, color, opacity, name, shade) );
	}
}