[cairo-commit] cairo-java/test/snippets Snippets.java, 1.5, 1.6 CairoSnippetsPDF.java, 1.6, 1.7 CairoSnippetsPNG.java, 1.5, 1.6

Jeffrey Morgan commit at pdx.freedesktop.org
Mon May 9 07:47:10 PDT 2005


Committed by: kuzman

Update of /cvs/cairo/cairo-java/test/snippets
In directory gabe:/tmp/cvs-serv22049/test/snippets

Modified Files:
	Snippets.java CairoSnippetsPDF.java CairoSnippetsPNG.java 
Log Message:
Continued API restructuring and cleanup

Index: Snippets.java
===================================================================
RCS file: /cvs/cairo/cairo-java/test/snippets/Snippets.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Snippets.java	6 May 2005 13:22:01 -0000	1.5
+++ Snippets.java	9 May 2005 14:47:03 -0000	1.6
@@ -18,7 +18,8 @@
 import org.freedesktop.cairo.LineCap;
 import org.freedesktop.cairo.LineJoin;
 import org.freedesktop.cairo.Pattern;
-import org.freedesktop.cairo.RGBColor;
+import org.freedesktop.cairo.Point;
+import org.freedesktop.cairo.Rectangle;
 import org.freedesktop.cairo.TextExtents;
 
 /**
@@ -64,26 +65,25 @@
 	 * arc snippet
 	 */
 	public void arc(Context cr, double width, double height) {
-		double xc = 0.5;
-		double yc = 0.5;
+        Point c = new Point(0.5, 0.5);
 		double radius = 0.4;
 		double angle1 = 45.0  * (M_PI/180.0);  /* angles are specified */
 		double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */
 
 		normalize(cr, width, height);
 
-		cr.arc(xc, yc, radius, angle1, angle2);
+		cr.arc(c, radius, angle1, angle2);
 		cr.stroke();
 
 		/* draw helping lines */
 		cr.setSourceRGBA(1,0.2,0.2, 0.6);
-		cr.arc(xc, yc, 0.05, 0, 2*M_PI);
+		cr.arc(c, 0.05, 0, 2*M_PI);
 		cr.fill();
 		cr.setLineWidth(0.03);
-		cr.arc(xc, yc, radius, angle1, angle1);
-		cr.lineTo(xc, yc);
-		cr.arc(xc, yc, radius, angle2, angle2);
-		cr.lineTo(xc, yc);
+		cr.arc(c, radius, angle1, angle1);
+		cr.lineTo(c);
+		cr.arc(c, radius, angle2, angle2);
+		cr.lineTo(c);
 		cr.stroke();
 	}
 	
@@ -91,26 +91,25 @@
 	 * arc_negative snippet
 	 */
 	public void arc_negative(Context cr, double width, double height) {
-		double xc = 0.5;
-		double yc = 0.5;
+        Point c = new Point(0.5, 0.5);
 		double radius = 0.4;
 		double angle1 = 45.0  * (M_PI/180.0);  /* angles are specified */
 		double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */
 
 		normalize(cr, width, height);
 
-		cr.arcNegative(xc, yc, radius, angle1, angle2);
+		cr.arcNegative(c, radius, angle1, angle2);
 		cr.stroke();
 
 		/* draw helping lines */
 		cr.setSourceRGBA(1,0.2,0.2, 0.6);
-		cr.arc(xc, yc, 0.05, 0, 2*M_PI);
+		cr.arc(c, 0.05, 0, 2*M_PI);
 		cr.fill();
 		cr.setLineWidth(0.03);
-		cr.arc(xc, yc, radius, angle1, angle1);
-		cr.lineTo(xc, yc);
-		cr.arc(xc, yc, radius, angle2, angle2);
-		cr.lineTo(xc, yc);
+		cr.arc(c, radius, angle1, angle1);
+		cr.lineTo(c);
+		cr.arc(c, radius, angle2, angle2);
+		cr.lineTo(c);
 		cr.stroke();
 	}
 	
@@ -125,7 +124,7 @@
 
 		cr.newPath();  /* current path is not
 		                         consumed by cairo_clip() */
-		cr.rectangle(0, 0, 1, 1);
+		cr.rectangle(new Rectangle(0, 0, 1, 1));
 		cr.fill();
 		cr.setSourceRGB(0, 1, 0);
 		cr.moveTo(0, 0);
@@ -277,16 +276,16 @@
 		normalize (cr, width, height);
 
 		Pattern pat = new Pattern(0.0, 0.0, 0.0, 1.0);
-		pat.addColorStop(1, new RGBColor(0, 0, 0), 1);
-		pat.addColorStop(0, new RGBColor(1, 1, 1), 1);
-		cr.rectangle(0,0,1,1);
+		pat.addColorStop(1, 0, 0, 0, 1);
+		pat.addColorStop(0, 1, 1, 1, 1);
+		cr.rectangle(new Rectangle(0,0,1,1));
 		cr.setSource(pat);
 		cr.fill();
 
 		pat.dispose();
 		pat = new Pattern(0.45, 0.4, 0.1, 0.4, 0.4, 0.5);
-		pat.addColorStop(0, new RGBColor(1, 1, 1), 1);
-		pat.addColorStop(1, new RGBColor(0, 0, 0), 1);
+		pat.addColorStop(0, 1, 1, 1, 1);
+		pat.addColorStop(1, 0, 0, 0, 1);
 		cr.setSource(pat);
 		cr.arc(0.5, 0.5, 0.3, 0, 2 * M_PI);
 		cr.fill();

Index: CairoSnippetsPDF.java
===================================================================
RCS file: /cvs/cairo/cairo-java/test/snippets/CairoSnippetsPDF.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CairoSnippetsPDF.java	7 May 2005 00:27:02 -0000	1.6
+++ CairoSnippetsPDF.java	9 May 2005 14:47:03 -0000	1.7
@@ -40,7 +40,6 @@
 		}
 		
 		// cleanup
-		cr.dispose();
 		surface.close();
 	}
 }

Index: CairoSnippetsPNG.java
===================================================================
RCS file: /cvs/cairo/cairo-java/test/snippets/CairoSnippetsPNG.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CairoSnippetsPNG.java	7 May 2005 00:27:02 -0000	1.5
+++ CairoSnippetsPNG.java	9 May 2005 14:47:03 -0000	1.6
@@ -32,7 +32,6 @@
 			cr.save();
 			Snippets.invokeSnippet(snip, i, cr, IMAGE_WIDTH, IMAGE_HEIGHT);
 			cr.restore();
-			cr.dispose();
 		}
 	}
 }




More information about the cairo-commit mailing list