Esempio n. 1
0
static void
writeSWFTextToMethod(SWFBlock block, SWFByteOutputMethod method, void *data)
{
	SWFText text = (SWFText)block;
	int length = 0;
	SWFOutput out;

	if ( text->matrix == NULL )
		text->matrix = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0);

	length += (SWFMatrix_numBits(text->matrix)+7)/8;
	length += (SWFRect_numBits(CHARACTER(text)->bounds)+7)/8;
	length += 4;

	out = newSizedSWFOutput(length);

	SWFOutput_writeUInt16(out, CHARACTERID(text));
	SWFOutput_writeRect(out, CHARACTER(text)->bounds);
	SWFOutput_writeMatrix(out, text->matrix);
	SWFOutput_writeUInt8(out, text->nGlyphBits);
	SWFOutput_writeUInt8(out, text->nAdvanceBits);

	SWFOutput_writeToMethod(out, method, data);
	SWFOutput_writeToMethod(text->out, method, data);

	destroySWFOutput(out);
}
Esempio n. 2
0
SWFMatrix
newSWFRotateMatrix(double degrees)
{
	double r = degrees * M_PI/180;

	return newSWFMatrix(cos(r), sin(r), -sin(r), cos(r), 0, 0);
}
Esempio n. 3
0
File: button.c Progetto: cran/R2SWF
/* adds a character 
 * Add a character to a button for given states
 * possible states:
 * SWFBUTTON_HIT
 * SWFBUTTON_DOWN
 * SWFBUTTON_OVER
 * SWFBUTTON_UP
 * states can be combined using the binary or operator
 * returns a SWFButtonRecord object which can be further modified.
 */
SWFButtonRecord
SWFButton_addCharacter(SWFButton button /* button object */, 
                       SWFCharacter character /* character to be added */, 
                       byte state /* state description */)
{
	SWFMatrix m;
	SWFButtonRecord record;
	SWFCharacter **depsPtr = &CHARACTER(button)->dependencies;
	int *depCount = &CHARACTER(button)->nDependencies;
	
	if ( SWFCharacter_isFinished((SWFCharacter)button) )
	{
		SWF_warn("Can't alter a button after it's been added to another character");
		return NULL;
	}

	SWFCharacter_getDependencies(character, depsPtr, depCount);
	SWFCharacter_addDependency((SWFCharacter)button, character);
	SWFCharacter_setFinished(character);
	
	m = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0);
	record = newSWFButtonRecord(state, character, 0, m);
	SWFButton_addRecord(button, record);
	return record;
}
Esempio n. 4
0
void 
SWFGradientMatrix_update(SWFMatrix matrix, SWFRect bounds)
{
	int w, h;
	float scaleX, scaleY;
	SWFMatrix tmp;
	if(bounds == NULL)
		return;

	w = SWFRect_getWidth(bounds);
	h = SWFRect_getHeight(bounds);
	scaleX = w / GRADIENT_SIZE;
	scaleY = h / GRADIENT_SIZE;

	/* update matrix translation first, to be realtive to the gradient's 
	 * coordinate system. */
	SWFMatrix_moveTo(matrix, SWFMatrix_getTranslateX(matrix) / scaleX, 
		SWFMatrix_getTranslateY(matrix) / scaleY);
	
	tmp = newSWFMatrix(scaleX, 0, 0, scaleY, bounds->minX + w/2,  bounds->minY + h/2);
	/* temporary matrix scales gradient to given bounds and centers it. */
	/* all transformations done by the user are "applied" on the tmp matrix */
	/* matrix = matrix * tmp -> "matrix is followed by tmp" */
	SWFMatrix_multiply(matrix, tmp);
	destroySWFMatrix(tmp);	
}
Esempio n. 5
0
File: button.c Progetto: cran/R2SWF
/* adds a shape character 
 * Add a shape character to a button for given states
 * possible states:
 * SWFBUTTON_HIT  
 * SWFBUTTON_DOWN  
 * SWFBUTTON_OVER
 * SWFBUTTON_UP
 * states can be combined using the binary or operator    
 * deprecated! use SWFButton_addCharacter instead
 */
void SWFButton_addShape(SWFButton button, SWFCharacter character, byte flags)
{
	SWFMatrix m;
	SWF_warnOnce("SWFButton_addShape is deprecated\nUse SWFButton_addCharacter instead\n");
	if ( SWFCharacter_isFinished((SWFCharacter)button) )
		SWF_error("Can't alter a button after it's been added to another character");

	m = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0);

	SWFCharacter_getDependencies((SWFCharacter)character,
									 &CHARACTER(button)->dependencies,
									 &CHARACTER(button)->nDependencies);

	SWFCharacter_addDependency((SWFCharacter)button, (SWFCharacter)character);

	SWFCharacter_setFinished(character);
	SWFButton_addRecord(button, newSWFButtonRecord(flags, character, 0, m));
}