Example #1
0
// RotateBy
void
ChannelTransform::RotateBy(double degrees)
{
	if (degrees == 0.0)
		return;

	fRotation += degrees;

	_UpdateMatrix();
}
Example #2
0
// SetPivot
void
ChannelTransform::SetPivot(BPoint pivot)
{
	if (pivot == fPivot)
		return;

	fPivot = pivot;

	_UpdateMatrix();
}
Example #3
0
// TranslateBy
void
ChannelTransform::TranslateBy(BPoint offset)
{
	if (offset.x == 0.0 && offset.y == 0.0)
		return;

	fTranslation += offset;

	_UpdateMatrix();
}
Example #4
0
// SetPivot
void
AdvancedTransform::SetPivot(BPoint pivot)
{
	if (pivot == fPivot)
		return;

	fPivot = pivot;

	_UpdateMatrix();
}
Example #5
0
// ScaleBy
void
ChannelTransform::ScaleBy(double xScale, double yScale)
{
	if (xScale == 1.0 && yScale == 1.0)
		return;

	fXScale *= xScale;
	fYScale *= yScale;

	_UpdateMatrix();
}
Example #6
0
// TranslateBy
void
AdvancedTransform::TranslateBy(double x, double y)
{
	if (x == 0.0 && y == 0.0)
		return;

	fTranslation.x += x;
	fTranslation.y += y;

	_UpdateMatrix();
}
Example #7
0
// SetTranslationAndScale
void
ChannelTransform::SetTranslationAndScale(BPoint offset, double xScale,
	double yScale)
{
	if (fTranslation == offset && fXScale == xScale && fYScale == yScale)
		return;

	fTranslation = offset;

	fXScale = xScale;
	fYScale = yScale;

	_UpdateMatrix();
}
Example #8
0
// ScaleBy
//
// converts a scalation in world coordinates into
// a combined local scalation and a translation
void
ChannelTransform::ScaleBy(BPoint origin, double xScale, double yScale)
{
	// TODO: Untested?
	if (xScale == 1.0 && yScale == 1.0)
		return;

	fXScale *= xScale;
	fYScale *= yScale;

	// scale fTranslation
	double xOffset = fTranslation.x - origin.x;
	double yOffset = fTranslation.y - origin.y;

	fTranslation.x = origin.x + (xOffset * xScale);
	fTranslation.y = origin.y + (yOffset * yScale);

	_UpdateMatrix();
}
Example #9
0
/*!	Converts a rotation in world coordinates into
	a combined local rotation and a translation.
*/
void
ChannelTransform::RotateBy(BPoint origin, double degrees)
{
	if (degrees == 0.0)
		return;

	origin -= fPivot;

	fRotation += degrees;

	// rotate fTranslation
	double xOffset = fTranslation.x - origin.x;
	double yOffset = fTranslation.y - origin.y;

	agg::trans_affine_rotation m(degrees * M_PI / 180.0);
	m.transform(&xOffset, &yOffset);

	fTranslation.x = origin.x + xOffset;
	fTranslation.y = origin.y + yOffset;

	_UpdateMatrix();
}
Example #10
0
// SetTransformation
void
AdvancedTransform::SetTransformation(BPoint pivot,
									 BPoint translation,
									 double rotation,
									 double xScale,
									 double yScale)
{
	if (fTranslation != translation ||
		fPivot != pivot ||
		fRotation != rotation ||
		fXScale != xScale ||
		fYScale != yScale) {

		fPivot = pivot;
		fTranslation = translation;
		fRotation = rotation;
		fXScale = xScale;
		fYScale = yScale;
	
		_UpdateMatrix();
	}
}
Example #11
0
// SetTransformation
void
ChannelTransform::SetTransformation(BPoint pivot, BPoint translation,
	double rotation, double xScale, double yScale)
{
//printf("SetTransformation(BPoint(%.1f, %.1f), BPoint(%.1f, %.1f), "
//"%.2f, %.2f, %.2f)\n", pivot.x, pivot.y, translation.x, translation.y,
//rotation, xScale, yScale);

	if (fTranslation != translation ||
		fPivot != pivot ||
		fRotation != rotation ||
		fXScale != xScale ||
		fYScale != yScale) {

		fPivot = pivot;
		fTranslation = translation;
		fRotation = rotation;
		fXScale = xScale;
		fYScale = yScale;

		_UpdateMatrix();
	}
}