Esempio n. 1
0
void printShape(FILE *f, int length, SWFBlocktype type)
{
  int start = fileOffset;
  int fillBits, lineBits;

  println("ShapeID: %i", readUInt16(f));

  print("Bounds: ");
  printRect(f);

  putchar('\n');
  putchar('\n');

  printFillStyleArray(f, type);
  printLineStyleArray(f, type);

  putchar('\n');

  byteAlign();

  fillBits = readBits(f,4);
  lineBits = readBits(f,4);

  while(fileOffset < length+start &&
	printShapeRec(f, &lineBits, &fillBits, type)) ;

  /* go for end tag..
  if(fileOffset == length+start && bufbits > 5)
    printShapeRec(f, &lineBits, &fillBits, type);
  */

  putchar('\n');
}
Esempio n. 2
0
void printMorphShape(FILE *f, int length)
{
  int offset, start = fileOffset;
  int fillBits, lineBits, here;

  println("ShapeID: %i", readUInt16(f));

  print("Bounds1: ");
  printRect(f);
  putchar('\n');
  print("Bounds2: ");
  printRect(f);
  putchar('\n');

  offset = readUInt32(f);
  println("(%i)\toffset = %i", fileOffset, offset);

  here = fileOffset;

  printFillStyleArray(f, SWF_DEFINEMORPHSHAPE);
  printLineStyleArray(f, SWF_DEFINEMORPHSHAPE);

  fillBits = readBits(f, 4);
  lineBits = readBits(f, 4);

  putchar('\n');
  println("Shape1:");
  while(fileOffset < here+offset)
    printShapeRec(f, &lineBits, &fillBits, SWF_DEFINESHAPE3);

  byteAlign();

  /* ??? */
  fillBits = readBits(f, 4);
  lineBits = readBits(f, 4);

  putchar('\n');
  println("Shape2:");
  while(fileOffset < start+length)
    printShapeRec(f, &lineBits, &fillBits, SWF_DEFINESHAPE3);
}
Esempio n. 3
0
int main (int argc, char const *argv[])
{
	int i;
	struct rectangle rects[] = {
		{{1, 2}, {3, 4}},
		{{5, 6}, {7, 8}},
	};
	for (i=0; i<2; i++) {
		printRect(rects[i]);
	}
	
	return 0;
}
Esempio n. 4
0
File: main.c Progetto: f2008700/BITS
int main()
{
	Rect Re1, Re2, Re3;
	Rect RA[100];
	int i,N;
	/* Create Re1 and Re2 */
	Re1=createRect();
	Re2=createRect();
	printf("\nRe1 after creation\n");
	printRect(Re1);
	printf("\nRe2 after creation\n");
	printRect(Re2);

	/* get data from user */
	Re1=getData(Re1);
	Re2=getData(Re2);
	printf("\nRe1 after getData\n");
	printRect(Re1);
	printf("\nRe2 after getData\n");
	printRect(Re2);

	/* isSquare */
	if(isSquare(Re1))
		printf("\nThe Rectangle R1 is SQUARE\n");
	else
		printf("\nThe Rectangle R1 is NOT SQUARE\n");

	/* isEqual */
	if(isEqual(Re1,Re2))
		printf("\nThe Rectangle R1 is EQUAL to R2\n");
	else
		printf("\nThe Rectangle R1 is NOT EQUAL to R2\n");

	/* compute Area */
	printf("\nThe Area of Rectangle R1 is %d\n",computeArea(Re1));

	/* Copy Re1 to Re3 */
	Re3=Re1;
	printf("\nRe1 details\n");
	printRect(Re1);
	printf("\nRe3 details after copying Re1\n");
	printRect(Re3);

/* Create RA */
	printf("Enter the Number of Elements in Rect Array\n");
	scanf("%d",&N);
	for(i=0;i<N;i++)
		RA[i]=createRect();
	
/* get data */
	for(i=0;i<N;i++)
		RA[i]=getData(RA[i]);
/* Find the Rectangle with Max Area */
	i=findMaxArea(RA,N);
	printf("\nMax Area Rect is in %d position, its length is %d and its width is %d\n",i,RA[i].length,RA[i].width);
	return 0;
}
Esempio n. 5
0
void printDefineText(FILE *f, int length, int type) /* type 2 allows transparency */
{
  int glyphBits, advanceBits, end = fileOffset+length;

  println("character id: %i", readUInt16(f));
  print("bounds: ");
  printRect(f);
  putchar('\n');
  byteAlign();
  println("matrix:");
  printMatrix(f);
  glyphBits = readUInt8(f);
  advanceBits = readUInt8(f);

  while(fileOffset < end &&
	printTextRecord(f, glyphBits, advanceBits, type)) ;
}
Esempio n. 6
0
int main() {	
	//function overloading
	std::cout << add(1, 2) << std::endl;
	std::cout << add(1, 2, 3) << std::endl;	

	std::cout << "Class" << std::endl;

	Rect a(5, 3, "black");         //객체 object 생성: 생성자가 호출됨
	Rect b(2, 6, "white");         //또 다른 객체 생성: a와는 별개의 instance가 생성됨
	Rect c = Rect(4, 7, "green");  //생성자가 호출되는 다른 방식
	
	Rect d;
	d = c;

	std::cout << "get/set 함수 이용" << std::endl;
	a.setX(10);  //set 함수를 이용해서 객체 a의 x_변수의 값을 변경함
	std::cout << "x=" << a.getX() << std::endl;
	std::cout << "y=" << a.getY() << std::endl;
	std::cout << "color=" << a.getColor() << std::endl;
	for (int i = 0; i < 10; ++i) {
		a.setX(i + 1);
		std::cout << "area=" << a.area() << std::endl;
	}
	
	std::cout << "\n함수를 이용한 출력" << std::endl;
	printRect(b);
	printRect(c);
	printRect(d);
	
	//default constructor
	Rect n;
	printRect(n);

	//copy constructor
	Rect e(a);
	printRect(e);
	
	//copy assignment
	n = a;
	printRect(n);

	//struct


	return 0;

	//함수가 종료되면서 객체의 소멸자 호출
	//생성된 역순으로 소멸됨: stack 메모리의 특성
}
void main(){

int i,n;
scanf("%d",&n);
Rect r[n];
for (i=0; i<n; i++){

r[i]=createRect();
r[i]=getData(r[i]);
printRect(r[i]);
printf("\n");
printf("Is this rectange a Square?\n(1 for YES, 0 for NO): %d",isSquare(r[i]));
printf("\narea is %d",computeArea(r[i]));
}

int maxarea;
maxarea=findMaxArea(r,n);
printf("\n the max area is %d\n",maxarea);

}
Esempio n. 8
0
nsresult
nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
                                gfxMatrix* patternMatrix,
                                nsSVGGeometryFrame *aSource,
                                float aGraphicOpacity)
{
  /*
   * General approach:
   *    Set the content geometry stuff
   *    Calculate our bbox (using x,y,width,height & patternUnits & 
   *                        patternTransform)
   *    Create the surface
   *    Calculate the content transformation matrix
   *    Get our children (we may need to get them from another Pattern)
   *    Call SVGPaint on all of our children
   *    Return
   */
  *surface = nsnull;

  // Get our child
  nsIFrame *firstKid;
  if (NS_FAILED(GetPatternFirstChild(&firstKid)))
    return NS_ERROR_FAILURE; // Either no kids or a bad reference

  /*
   * Get the content geometry information.  This is a little tricky --
   * our parent is probably a <defs>, but we are rendering in the context
   * of some geometry source.  Our content geometry information needs to
   * come from our rendering parent as opposed to our content parent.  We
   * get that information from aSource, which is passed to us from the
   * backend renderer.
   *
   * There are three "geometries" that we need:
   *   1) The bounding box for the pattern.  We use this to get the
   *      width and height for the surface, and as the return to
   *      GetBBox.
   *   2) The transformation matrix for the pattern.  This is not *quite*
   *      the same as the canvas transformation matrix that we will
   *      provide to our rendering children since we "fudge" it a little
   *      to get the renderer to handle the translations correctly for us.
   *   3) The CTM that we return to our children who make up the pattern.
   */

  // Get all of the information we need from our "caller" -- i.e.
  // the geometry that is being rendered with a pattern
  nsSVGElement *callerContent;
  nsCOMPtr<nsIDOMSVGRect> callerBBox;
  nsCOMPtr<nsIDOMSVGMatrix> callerCTM;
  if (NS_FAILED(GetCallerGeometry(getter_AddRefs(callerCTM),
                                  getter_AddRefs(callerBBox),
                                  &callerContent, aSource)))
    return NS_ERROR_FAILURE;

  // Construct the CTM that we will provide to our children when we
  // render them into the tile.
  if (NS_FAILED(ConstructCTM(getter_AddRefs(mCTM), callerBBox, callerCTM)))
    return NS_ERROR_FAILURE;

  // Get the bounding box of the pattern.  This will be used to determine
  // the size of the surface, and will also be used to define the bounding
  // box for the pattern tile.
  nsCOMPtr<nsIDOMSVGRect> bbox;
  if (NS_FAILED(GetPatternRect(getter_AddRefs(bbox),
                               callerBBox, callerCTM,
                               callerContent)))
    return NS_ERROR_FAILURE;

  // Get the transformation matrix that we will hand to the renderer's pattern
  // routine.
  *patternMatrix = GetPatternMatrix(bbox, callerBBox, callerCTM);

#ifdef DEBUG_scooter
  printRect("Geometry Rect: ", callerBBox);
  printRect("Pattern Rect: ", bbox);
  printCTM("Pattern TM ", *patternMatrix);
  printCTM("Child TM ", mCTM);
#endif

  // Now that we have all of the necessary geometries, we can
  // create our surface.
  float patternWidth, patternHeight;
  bbox->GetWidth(&patternWidth);
  bbox->GetHeight(&patternHeight);

  PRBool resultOverflows;
  gfxIntSize surfaceSize =
    nsSVGUtils::ConvertToSurfaceSize(gfxSize(patternWidth, patternHeight),
                                     &resultOverflows);

  // 0 disables rendering, < 0 is an error
  if (surfaceSize.width <= 0 || surfaceSize.height <= 0)
    return NS_ERROR_FAILURE;

  if (resultOverflows) {
    // scale down drawing to new pattern surface size
    nsCOMPtr<nsIDOMSVGMatrix> tempTM, aCTM;
    NS_NewSVGMatrix(getter_AddRefs(tempTM),
                    surfaceSize.width / patternWidth, 0.0f,
                    0.0f, surfaceSize.height / patternHeight,
                    0.0f, 0.0f);
    mCTM->Multiply(tempTM, getter_AddRefs(aCTM));
    aCTM.swap(mCTM);

    // and magnify pattern to compensate
    patternMatrix->Scale(patternWidth / surfaceSize.width,
                         patternHeight / surfaceSize.height);
  }

#ifdef DEBUG_scooter
  printf("Creating %dX%d surface\n", int(surfaceSize.width), int(surfaceSize.height));
#endif

  nsRefPtr<gfxASurface> tmpSurface =
    gfxPlatform::GetPlatform()->CreateOffscreenSurface(surfaceSize,
                                                       gfxASurface::ImageFormatARGB32);
  if (!tmpSurface || tmpSurface->CairoStatus())
    return NS_ERROR_FAILURE;

  gfxContext tmpContext(tmpSurface);
  nsSVGRenderState tmpState(&tmpContext);

  // Fill with transparent black
  tmpContext.SetOperator(gfxContext::OPERATOR_CLEAR);
  tmpContext.Paint();
  tmpContext.SetOperator(gfxContext::OPERATOR_OVER);

  if (aGraphicOpacity != 1.0f) {
    tmpContext.Save();
    tmpContext.PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
  }

  // OK, now render -- note that we use "firstKid", which
  // we got at the beginning because it takes care of the
  // referenced pattern situation for us

  // Set our geometrical parent
  mSource = aSource;

  for (nsIFrame* kid = firstKid; kid;
       kid = kid->GetNextSibling()) {
    nsSVGUtils::PaintChildWithEffects(&tmpState, nsnull, kid);
  }
  mSource = nsnull;

  if (aGraphicOpacity != 1.0f) {
    tmpContext.PopGroupToSource();
    tmpContext.Paint(aGraphicOpacity);
    tmpContext.Restore();
  }

  // caller now owns the surface
  tmpSurface.swap(*surface);
  return NS_OK;
}
Esempio n. 9
0
void printDefineFont2(FILE *f, int length)
{
  int flags, nGlyphs, namelen, i, fillBits, lineBits;
  int here = fileOffset;
  int *offset;

  println("fontID: %i", readUInt16(f));

  flags = readUInt8(f);

  readUInt8(f); /* "reserved" */

  namelen = readUInt8(f);

  print("Font Name: ");

  for(; namelen>0; --namelen)
    putchar((unsigned char)readUInt8(f));

  putchar('\n');

  nGlyphs = readUInt16(f);
  println("number of glyphs: %i\n", nGlyphs);

  offset = (unsigned int *)malloc(nGlyphs*sizeof(int));

  /* offset table */

  here = fileOffset;

  for(i=0; i<=nGlyphs; ++i)
  {
    if(flags & FONTINFO2_WIDEOFFSETS)
      offset[i] = readUInt32(f)-4*nGlyphs-2;
    else
      offset[i] = readUInt16(f)-2*nGlyphs-2;

    println("Offset%i: %i", i, offset[i]);
  }

  here = fileOffset;

  /* shape table */
  for(i=0; i<nGlyphs; ++i)
  {
    byteAlign();
    println("Glyph %i:", i);

    fillBits = readBits(f, 4);
    lineBits = readBits(f, 4);

    byteAlign();
    while(printShapeRec(f, &fillBits, &lineBits, 2)) ;

    putchar('\n');
  }

  /* code table */
  for(i=0; i<nGlyphs; ++i)
  {
    if(flags & FONTINFO2_WIDECODES)
      println("glyph code %i: %i", i, readUInt16(f));
    else
      println("glyph code %i: %i", i, readUInt8(f));
  }

  if(flags & FONTINFO2_HASLAYOUT)
  {
    int kernCount, code1, code2;

    println("ascender height: %i", readSInt16(f));
    println("descender height: %i", readSInt16(f));
    println("leading height: %i", readSInt16(f));

    for(i=0; i<nGlyphs; ++i)
      printf("\tadvance %i: %i\n", i, readSInt16(f));

    for(i=0; i<nGlyphs; ++i)
    {
      print("bounds %i: ", i);
      printRect(f);
      putchar('\n');
    }

    kernCount = readUInt16(f);

    for(i=0; i<kernCount; ++i)
    {
      code1 = (flags & FONTINFO2_WIDECODES) ? readUInt16(f) : readUInt8(f);
      code2 = (flags & FONTINFO2_WIDECODES) ? readUInt16(f) : readUInt8(f);
      println("(%i,%i): adjustment = %i", code1, code2, readSInt16(f));
    }
  }
}