[cairo-commit] cairo-java/test/snippets CairoSnippetsPDF.java, 1.10, 1.11 CairoSnippetsPNG.java, 1.7, 1.8 Snippets.java, 1.7, 1.8

Andrew Frederick Cowie commit at pdx.freedesktop.org
Sun Feb 12 01:05:47 PST 2006


Committed by: afcowie

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

Modified Files:
	CairoSnippetsPDF.java CairoSnippetsPNG.java Snippets.java 
Log Message:
Update format setting from Eclipse default to Java default; format test cases.


Index: CairoSnippetsPDF.java
===================================================================
RCS file: /cvs/cairo/cairo-java/test/snippets/CairoSnippetsPDF.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- CairoSnippetsPDF.java	17 Aug 2005 00:34:31 -0000	1.10
+++ CairoSnippetsPDF.java	12 Feb 2006 09:05:44 -0000	1.11
@@ -16,29 +16,33 @@
  */
 public class CairoSnippetsPDF {
 
-	public static int X_INCHES = 2;
-	public static int Y_INCHES = 2;
-	public static double X_PPI = 300.0;
-	public static double Y_PPI = 300.0;
+    public static int X_INCHES = 2;
 
-	public static double WIDTH  = X_INCHES * 72.0;
-	public static double HEIGHT = Y_INCHES * 72.0;
-	
+    public static int Y_INCHES = 2;
 
-	public static void main(String[] args) throws Exception {
-		// initialize
-		PDFSurface surface = new PDFSurface("./snippets.pdf", X_INCHES, Y_INCHES);
-		surface.setDPI( X_PPI, Y_PPI);
-		Context cr = new Context(surface);
-		
-		// call the snippets
-		Snippets snip = new Snippets();
-		for (int i = 0; i < Snippets.snippets.length; i++) {
-			cr.save();
-			Snippets.invokeSnippet(snip, i, cr, WIDTH, HEIGHT);
-			cr.showPage();
-			cr.restore();
-		}
-		
-	}
+    public static double X_PPI = 300.0;
+
+    public static double Y_PPI = 300.0;
+
+    public static double WIDTH = X_INCHES * 72.0;
+
+    public static double HEIGHT = Y_INCHES * 72.0;
+
+    public static void main(String[] args) throws Exception {
+        // initialize
+        PDFSurface surface = new PDFSurface("./snippets.pdf", X_INCHES,
+                Y_INCHES);
+        surface.setDPI(X_PPI, Y_PPI);
+        Context cr = new Context(surface);
+
+        // call the snippets
+        Snippets snip = new Snippets();
+        for (int i = 0; i < Snippets.snippets.length; i++) {
+            cr.save();
+            Snippets.invokeSnippet(snip, i, cr, WIDTH, HEIGHT);
+            cr.showPage();
+            cr.restore();
+        }
+
+    }
 }

Index: CairoSnippetsPNG.java
===================================================================
RCS file: /cvs/cairo/cairo-java/test/snippets/CairoSnippetsPNG.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CairoSnippetsPNG.java	17 Aug 2005 00:23:44 -0000	1.7
+++ CairoSnippetsPNG.java	12 Feb 2006 09:05:44 -0000	1.8
@@ -18,23 +18,25 @@
  */
 public class CairoSnippetsPNG {
 
-	public static int IMAGE_WIDTH = 256;
-	public static int IMAGE_HEIGHT = 256;
+    public static int IMAGE_WIDTH = 256;
 
-	public static double LINE_WIDTH = 0.04;
+    public static int IMAGE_HEIGHT = 256;
 
-	public static void main(String[] args) throws Exception {
-		// call the snippets
-		Snippets snip = new Snippets();
-		for (int i = 0; i < Snippets.snippets.length; i++) {
-			String filename = "./" + Snippets.snippets[i] + ".png";
-			Surface surface = new ImageSurface(Format.ARGB32, IMAGE_WIDTH, IMAGE_WIDTH);
-			Context cr = new Context(surface);
-			
-			cr.save();
-			Snippets.invokeSnippet(snip, i, cr, IMAGE_WIDTH, IMAGE_HEIGHT);
+    public static double LINE_WIDTH = 0.04;
+
+    public static void main(String[] args) throws Exception {
+        // call the snippets
+        Snippets snip = new Snippets();
+        for (int i = 0; i < Snippets.snippets.length; i++) {
+            String filename = "./" + Snippets.snippets[i] + ".png";
+            Surface surface = new ImageSurface(Format.ARGB32, IMAGE_WIDTH,
+                    IMAGE_WIDTH);
+            Context cr = new Context(surface);
+
+            cr.save();
+            Snippets.invokeSnippet(snip, i, cr, IMAGE_WIDTH, IMAGE_HEIGHT);
             surface.writeToPNG(filename);
-			cr.restore();
-		}
-	}
+            cr.restore();
+        }
+    }
 }

Index: Snippets.java
===================================================================
RCS file: /cvs/cairo/cairo-java/test/snippets/Snippets.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Snippets.java	9 May 2005 15:38:24 -0000	1.7
+++ Snippets.java	12 Feb 2006 09:05:44 -0000	1.8
@@ -27,528 +27,518 @@
  */
 public class Snippets {
 
-	public static double M_PI = 3.14159265358979323846;
-	
-	public static String[] snippets = {
-		"arc",
-		"arc_negative",
-		"clip",
-		"curve_to",
-		"curve_rectangle",
-		"fill_and_stroke",
-		"fill_and_stroke2",
-		"gradient",
-		"path",
-		"set_line_cap",
-		"set_line_join",
-		"text",
-		"text_align_center",
-		"text_extents",
-		"xxx_clip_rectangle",
-		"xxx_dash",
-		"xxx_long_lines",
-		"xxx_multi_segment_caps",
-		"xxx_self_intersect"
-	};
-	
-	public static void invokeSnippet(Snippets snip, int num, Context cr, double width, double height) 
-			throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
-		Method m = Snippets.class.getMethod(snippets[num], new Class[] {Context.class, double.class, double.class});
-		m.invoke(snip, new Object[] {cr, new Double(width), new Double(height)});
-	}
+    public static double M_PI = 3.14159265358979323846;
 
-	public void normalize(Context cr, double width, double height) {
-		cr.scale(width, height);
-		cr.setLineWidth(0.04);
-	}
-	
-	/**
-	 * arc snippet
-	 */
-	public void arc(Context cr, double width, double height) {
+    public static String[] snippets = { "arc", "arc_negative", "clip",
+            "curve_to", "curve_rectangle", "fill_and_stroke",
+            "fill_and_stroke2", "gradient", "path", "set_line_cap",
+            "set_line_join", "text", "text_align_center", "text_extents",
+            "xxx_clip_rectangle", "xxx_dash", "xxx_long_lines",
+            "xxx_multi_segment_caps", "xxx_self_intersect" };
+
+    public static void invokeSnippet(Snippets snip, int num, Context cr,
+            double width, double height) throws NoSuchMethodException,
+            InvocationTargetException, IllegalAccessException {
+        Method m = Snippets.class.getMethod(snippets[num], new Class[] {
+                Context.class, double.class, double.class });
+        m.invoke(snip,
+                new Object[] { cr, new Double(width), new Double(height) });
+    }
+
+    public void normalize(Context cr, double width, double height) {
+        cr.scale(width, height);
+        cr.setLineWidth(0.04);
+    }
+
+    /**
+     * arc snippet
+     */
+    public void arc(Context cr, double width, double height) {
         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           */
+        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);
+        normalize(cr, width, height);
 
-		cr.arc(c, radius, angle1, angle2);
-		cr.stroke();
+        cr.arc(c, radius, angle1, angle2);
+        cr.stroke();
 
-		/* draw helping lines */
-		cr.setSourceRGBA(1,0.2,0.2, 0.6);
-		cr.arc(c, 0.05, 0, 2*M_PI);
-		cr.fill();
-		cr.setLineWidth(0.03);
-		cr.arc(c, radius, angle1, angle1);
-		cr.lineTo(c);
-		cr.arc(c, radius, angle2, angle2);
-		cr.lineTo(c);
-		cr.stroke();
-	}
-	
-	/**
-	 * arc_negative snippet
-	 */
-	public void arc_negative(Context cr, double width, double height) {
+        /* draw helping lines */
+        cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
+        cr.arc(c, 0.05, 0, 2 * M_PI);
+        cr.fill();
+        cr.setLineWidth(0.03);
+        cr.arc(c, radius, angle1, angle1);
+        cr.lineTo(c);
+        cr.arc(c, radius, angle2, angle2);
+        cr.lineTo(c);
+        cr.stroke();
+    }
+
+    /**
+     * arc_negative snippet
+     */
+    public void arc_negative(Context cr, double width, double height) {
         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           */
+        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);
+        normalize(cr, width, height);
 
-		cr.arcNegative(c, radius, angle1, angle2);
-		cr.stroke();
+        cr.arcNegative(c, radius, angle1, angle2);
+        cr.stroke();
 
-		/* draw helping lines */
-		cr.setSourceRGBA(1,0.2,0.2, 0.6);
-		cr.arc(c, 0.05, 0, 2*M_PI);
-		cr.fill();
-		cr.setLineWidth(0.03);
-		cr.arc(c, radius, angle1, angle1);
-		cr.lineTo(c);
-		cr.arc(c, radius, angle2, angle2);
-		cr.lineTo(c);
-		cr.stroke();
-	}
-	
-	/**
-	 * clip snippet
-	 */
-	public void clip(Context cr, double width, double height) {
-		normalize (cr, width, height);
+        /* draw helping lines */
+        cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
+        cr.arc(c, 0.05, 0, 2 * M_PI);
+        cr.fill();
+        cr.setLineWidth(0.03);
+        cr.arc(c, radius, angle1, angle1);
+        cr.lineTo(c);
+        cr.arc(c, radius, angle2, angle2);
+        cr.lineTo(c);
+        cr.stroke();
+    }
 
-		cr.arc(0.5, 0.5, 0.3, 0, 2 * M_PI);
-		cr.clip();
+    /**
+     * clip snippet
+     */
+    public void clip(Context cr, double width, double height) {
+        normalize(cr, width, height);
 
-		cr.newPath();  /* current path is not
-		                         consumed by cairo_clip() */
-		cr.rectangle(new Rectangle(0, 0, 1, 1));
-		cr.fill();
-		cr.setSourceRGB(0, 1, 0);
-		cr.moveTo(0, 0);
-		cr.lineTo(1, 1);
-		cr.moveTo(1, 0);
-		cr.lineTo(0, 1);
-		cr.stroke();
-	}
+        cr.arc(0.5, 0.5, 0.3, 0, 2 * M_PI);
+        cr.clip();
 
-	/**
-	 * curve_to snippet
-	 */
-	public void curve_to(Context cr, double width, double height) {
-		double x=0.1,  y=0.5;
-		double x1=0.4, y1=0.9,
-		       x2=0.6, y2=0.1,
-		       x3=0.9, y3=0.5;
+        cr.newPath(); /*
+                         * current path is not consumed by cairo_clip()
+                         */
+        cr.rectangle(new Rectangle(0, 0, 1, 1));
+        cr.fill();
+        cr.setSourceRGB(0, 1, 0);
+        cr.moveTo(0, 0);
+        cr.lineTo(1, 1);
+        cr.moveTo(1, 0);
+        cr.lineTo(0, 1);
+        cr.stroke();
+    }
 
-		normalize (cr, width, height);
+    /**
+     * curve_to snippet
+     */
+    public void curve_to(Context cr, double width, double height) {
+        double x = 0.1, y = 0.5;
+        double x1 = 0.4, y1 = 0.9, x2 = 0.6, y2 = 0.1, x3 = 0.9, y3 = 0.5;
 
-		cr.moveTo(x, y);
-		cr.curveTo(x1, y1, x2, y2, x3, y3);
+        normalize(cr, width, height);
 
-		cr.stroke();
+        cr.moveTo(x, y);
+        cr.curveTo(x1, y1, x2, y2, x3, y3);
 
-		cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
-		cr.setLineWidth(0.03);
-		cr.moveTo(x,y);   cr.lineTo(x1,y1);
-		cr.moveTo(x2,y2); cr.lineTo(x3,y3);
-		cr.stroke();
-	}
+        cr.stroke();
 
-	/**
-	 * curve_rectangle snippet
-	 */
-	public void curve_rectangle(Context cr, double width, double height) {
-		/* a custom shape, that could be wrapped in a function */
-		double x0	   = 0.1,   /*< parameters like cairo_rectangle */
-		       y0	   = 0.1,
-		       rect_width  = 0.8,
-		       rect_height = 0.8,
-		       radius = 0.4;   /*< and an approximate curvature radius */
+        cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
+        cr.setLineWidth(0.03);
+        cr.moveTo(x, y);
+        cr.lineTo(x1, y1);
+        cr.moveTo(x2, y2);
+        cr.lineTo(x3, y3);
+        cr.stroke();
+    }
 
-		double x1,y1;
+    /**
+     * curve_rectangle snippet
+     */
+    public void curve_rectangle(Context cr, double width, double height) {
+        /* a custom shape, that could be wrapped in a function */
+        double x0 = 0.1, /* < parameters like cairo_rectangle */
+        y0 = 0.1, rect_width = 0.8, rect_height = 0.8, radius = 0.4; /*
+                                                                         * < and
+                                                                         * an
+                                                                         * approximate
+                                                                         * curvature
+                                                                         * radius
+                                                                         */
 
-		normalize(cr, width, height);
+        double x1, y1;
 
-		x1=x0+rect_width;
-		y1=y0+rect_height;
+        normalize(cr, width, height);
 
-		if (rect_width/2<radius) {
-		    if (rect_height/2<radius) {
-		        cr.moveTo(x0, (y0 + y1)/2);
-		        cr.curveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
-		        cr.curveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
-		        cr.curveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
-		        cr.curveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
-		    } else {
-		        cr.moveTo(x0, y0 + radius);
-		        cr.curveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
-		        cr.curveTo(x1, y0, x1, y0, x1, y0 + radius);
-		        cr.lineTo(x1 , y1 - radius);
-		        cr.curveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
-		        cr.curveTo(x0, y1, x0, y1, x0, y1- radius);
-		    }
-		} else {
-		    if (rect_height/2<radius) {
-		        cr.moveTo(x0, (y0 + y1)/2);
-		        cr.curveTo(x0 , y0, x0 , y0, x0 + radius, y0);
-		        cr.lineTo(x1 - radius, y0);
-		        cr.curveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
-		        cr.curveTo(x1, y1, x1, y1, x1 - radius, y1);
-		        cr.lineTo(x0 + radius, y1);
-		        cr.curveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
-		    } else {
-		        cr.moveTo(x0, y0 + radius);
-		        cr.curveTo(x0 , y0, x0 , y0, x0 + radius, y0);
-		        cr.lineTo(x1 - radius, y0);
-		        cr.curveTo(x1, y0, x1, y0, x1, y0 + radius);
-		        cr.lineTo(x1 , y1 - radius);
-		        cr.curveTo(x1, y1, x1, y1, x1 - radius, y1);
-		        cr.lineTo(x0 + radius, y1);
-		        cr.curveTo(x0, y1, x0, y1, x0, y1- radius);
-		    }
-		}
-		cr.closePath();
+        x1 = x0 + rect_width;
+        y1 = y0 + rect_height;
 
-		/* and fill/stroke it */
-		cr.save();
-	    cr.setSourceRGB(0.5, 0.5, 1);
-	    cr.fill();
-		cr.restore();
-		cr.setSourceRGBA(0.5, 0, 0, 0.5);
-		cr.stroke();
-	}
+        if (rect_width / 2 < radius) {
+            if (rect_height / 2 < radius) {
+                cr.moveTo(x0, (y0 + y1) / 2);
+                cr.curveTo(x0, y0, x0, y0, (x0 + x1) / 2, y0);
+                cr.curveTo(x1, y0, x1, y0, x1, (y0 + y1) / 2);
+                cr.curveTo(x1, y1, x1, y1, (x1 + x0) / 2, y1);
+                cr.curveTo(x0, y1, x0, y1, x0, (y0 + y1) / 2);
+            } else {
+                cr.moveTo(x0, y0 + radius);
+                cr.curveTo(x0, y0, x0, y0, (x0 + x1) / 2, y0);
+                cr.curveTo(x1, y0, x1, y0, x1, y0 + radius);
+                cr.lineTo(x1, y1 - radius);
+                cr.curveTo(x1, y1, x1, y1, (x1 + x0) / 2, y1);
+                cr.curveTo(x0, y1, x0, y1, x0, y1 - radius);
+            }
+        } else {
+            if (rect_height / 2 < radius) {
+                cr.moveTo(x0, (y0 + y1) / 2);
+                cr.curveTo(x0, y0, x0, y0, x0 + radius, y0);
+                cr.lineTo(x1 - radius, y0);
+                cr.curveTo(x1, y0, x1, y0, x1, (y0 + y1) / 2);
+                cr.curveTo(x1, y1, x1, y1, x1 - radius, y1);
+                cr.lineTo(x0 + radius, y1);
+                cr.curveTo(x0, y1, x0, y1, x0, (y0 + y1) / 2);
+            } else {
+                cr.moveTo(x0, y0 + radius);
+                cr.curveTo(x0, y0, x0, y0, x0 + radius, y0);
+                cr.lineTo(x1 - radius, y0);
+                cr.curveTo(x1, y0, x1, y0, x1, y0 + radius);
+                cr.lineTo(x1, y1 - radius);
+                cr.curveTo(x1, y1, x1, y1, x1 - radius, y1);
+                cr.lineTo(x0 + radius, y1);
+                cr.curveTo(x0, y1, x0, y1, x0, y1 - radius);
+            }
+        }
+        cr.closePath();
 
-	/**
-	 * fill_and_stroke snippet
-	 */
-	public void fill_and_stroke(Context cr, double width, double height) {
-		normalize(cr, width, height);
+        /* and fill/stroke it */
+        cr.save();
+        cr.setSourceRGB(0.5, 0.5, 1);
+        cr.fill();
+        cr.restore();
+        cr.setSourceRGBA(0.5, 0, 0, 0.5);
+        cr.stroke();
+    }
 
-		cr.moveTo(0.5, 0.1);
-		cr.lineTo(0.9, 0.9);
-		cr.relLineTo(-0.4, 0.0);
-		cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
+    /**
+     * fill_and_stroke snippet
+     */
+    public void fill_and_stroke(Context cr, double width, double height) {
+        normalize(cr, width, height);
 
-		cr.save();
-		cr.setSourceRGB(0, 0, 1);
-		cr.fill();
-		cr.restore();
+        cr.moveTo(0.5, 0.1);
+        cr.lineTo(0.9, 0.9);
+        cr.relLineTo(-0.4, 0.0);
+        cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
 
-		cr.closePath();
-		cr.stroke();
-	}
+        cr.save();
+        cr.setSourceRGB(0, 0, 1);
+        cr.fill();
+        cr.restore();
 
-	/**
-	 * fill_and_stroke2 snippet
-	 */
-	public void fill_and_stroke2(Context cr, double width, double height) {
-		normalize (cr, width, height);
+        cr.closePath();
+        cr.stroke();
+    }
 
-		cr.moveTo(0.5, 0.1);
-		cr.lineTo(0.9, 0.9);
-		cr.relLineTo(-0.4, 0.0);
-		cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
-		cr.closePath();
+    /**
+     * fill_and_stroke2 snippet
+     */
+    public void fill_and_stroke2(Context cr, double width, double height) {
+        normalize(cr, width, height);
 
-		cr.moveTo(0.25, 0.1);
-		cr.relLineTo(0.2, 0.2);
-		cr.relLineTo(-0.2, 0.2);
-		cr.relLineTo(-0.2, -0.2);
-		cr.closePath();
+        cr.moveTo(0.5, 0.1);
+        cr.lineTo(0.9, 0.9);
+        cr.relLineTo(-0.4, 0.0);
+        cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
+        cr.closePath();
 
+        cr.moveTo(0.25, 0.1);
+        cr.relLineTo(0.2, 0.2);
+        cr.relLineTo(-0.2, 0.2);
+        cr.relLineTo(-0.2, -0.2);
+        cr.closePath();
 
-		cr.save();
-	    cr.setSourceRGB(0, 0, 1);
-	    cr.fill();
-		cr.restore();
+        cr.save();
+        cr.setSourceRGB(0, 0, 1);
+        cr.fill();
+        cr.restore();
 
-		cr.stroke();
-	}
+        cr.stroke();
+    }
 
-	/**
-	 * gradient snippet
-	 */
-	public void gradient(Context cr, double width, double height) {
-		
-		normalize (cr, width, height);
+    /**
+     * gradient snippet
+     */
+    public void gradient(Context cr, double width, double height) {
 
-		LinearGradient lg = new LinearGradient(0.0, 0.0, 0.0, 1.0);
-		lg.addColorStop(1, 0, 0, 0, 1);
-		lg.addColorStop(0, 1, 1, 1, 1);
-		cr.rectangle(new Rectangle(0,0,1,1));
-		cr.setSource(lg);
-		cr.fill();
+        normalize(cr, width, height);
 
-		RadialGradient rg = new RadialGradient(0.45, 0.4, 0.1, 0.4, 0.4, 0.5);
-		rg.addColorStop(0, 1, 1, 1, 1);
-		rg.addColorStop(1, 0, 0, 0, 1);
-		cr.setSource(rg);
-		cr.arc(0.5, 0.5, 0.3, 0, 2 * M_PI);
-		cr.fill();
-	}
+        LinearGradient lg = new LinearGradient(0.0, 0.0, 0.0, 1.0);
+        lg.addColorStop(1, 0, 0, 0, 1);
+        lg.addColorStop(0, 1, 1, 1, 1);
+        cr.rectangle(new Rectangle(0, 0, 1, 1));
+        cr.setSource(lg);
+        cr.fill();
 
-	/**
-	 * path snippet
-	 */
-	public void path(Context cr, double width, double height) {
-		normalize(cr, width, height);
-		cr.moveTo(0.5, 0.1);
-		cr.lineTo(0.9, 0.9);
-		cr.relLineTo(-0.4, 0.0);
-		cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
+        RadialGradient rg = new RadialGradient(0.45, 0.4, 0.1, 0.4, 0.4, 0.5);
+        rg.addColorStop(0, 1, 1, 1, 1);
+        rg.addColorStop(1, 0, 0, 0, 1);
+        cr.setSource(rg);
+        cr.arc(0.5, 0.5, 0.3, 0, 2 * M_PI);
+        cr.fill();
+    }
 
-		cr.stroke();
-	}
+    /**
+     * path snippet
+     */
+    public void path(Context cr, double width, double height) {
+        normalize(cr, width, height);
+        cr.moveTo(0.5, 0.1);
+        cr.lineTo(0.9, 0.9);
+        cr.relLineTo(-0.4, 0.0);
+        cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
 
-	/**
-	 * set_line_cap snippet
-	 */
-	public void set_line_cap(Context cr, double width, double height) {
-		normalize(cr, width, height);
-		cr.setLineWidth(0.12);
-		cr.setLineCap(LineCap.BUTT); /* default */
-		cr.moveTo(0.25, 0.2); 
-		cr.lineTo(0.25, 0.8);
-		cr.stroke();
-		cr.setLineCap(LineCap.ROUND);
-		cr.moveTo(0.5, 0.2); 
-		cr.lineTo(0.5, 0.8);
-		cr.stroke();
-		cr.setLineCap(LineCap.SQUARE);
-		cr.moveTo(0.75, 0.2); 
-		cr.lineTo(0.75, 0.8);
-		cr.stroke();
+        cr.stroke();
+    }
 
-		/* draw helping lines */
-		cr.setSourceRGB(1,0.2,0.2);
-		cr.setLineWidth(0.01);
-		cr.moveTo(0.25, 0.2); 
-		cr.lineTo(0.25, 0.8);
-		cr.moveTo(0.5, 0.2);  
-		cr.lineTo(0.5, 0.8);
-		cr.moveTo(0.75, 0.2); 
-		cr.lineTo(0.75, 0.8);
-		cr.stroke();
-	}
+    /**
+     * set_line_cap snippet
+     */
+    public void set_line_cap(Context cr, double width, double height) {
+        normalize(cr, width, height);
+        cr.setLineWidth(0.12);
+        cr.setLineCap(LineCap.BUTT); /* default */
+        cr.moveTo(0.25, 0.2);
+        cr.lineTo(0.25, 0.8);
+        cr.stroke();
+        cr.setLineCap(LineCap.ROUND);
+        cr.moveTo(0.5, 0.2);
+        cr.lineTo(0.5, 0.8);
+        cr.stroke();
+        cr.setLineCap(LineCap.SQUARE);
+        cr.moveTo(0.75, 0.2);
+        cr.lineTo(0.75, 0.8);
+        cr.stroke();
 
-	/**
-	 * set_line_join snippet
-	 */
-	public void set_line_join(Context cr, double width, double height) {
-		normalize(cr, width, height);
-		cr.setLineWidth(0.16);
-		cr.moveTo(0.3, 0.33);
-		cr.relLineTo(0.2, -0.2);
-		cr.relLineTo(0.2, 0.2);
-		cr.setLineJoin(LineJoin.MITER); /* default */
-		cr.stroke();
+        /* draw helping lines */
+        cr.setSourceRGB(1, 0.2, 0.2);
+        cr.setLineWidth(0.01);
+        cr.moveTo(0.25, 0.2);
+        cr.lineTo(0.25, 0.8);
+        cr.moveTo(0.5, 0.2);
+        cr.lineTo(0.5, 0.8);
+        cr.moveTo(0.75, 0.2);
+        cr.lineTo(0.75, 0.8);
+        cr.stroke();
+    }
 
-		cr.moveTo(0.3, 0.63);
-		cr.relLineTo(0.2, -0.2);
-		cr.relLineTo(0.2, 0.2);
-		cr.setLineJoin(LineJoin.BEVEL);
-		cr.stroke();
+    /**
+     * set_line_join snippet
+     */
+    public void set_line_join(Context cr, double width, double height) {
+        normalize(cr, width, height);
+        cr.setLineWidth(0.16);
+        cr.moveTo(0.3, 0.33);
+        cr.relLineTo(0.2, -0.2);
+        cr.relLineTo(0.2, 0.2);
+        cr.setLineJoin(LineJoin.MITER); /* default */
+        cr.stroke();
 
-		cr.moveTo(0.3, 0.93);
-		cr.relLineTo(0.2, -0.2);
-		cr.relLineTo(0.2, 0.2);
-		cr.setLineJoin(LineJoin.ROUND);
-		cr.stroke();
+        cr.moveTo(0.3, 0.63);
+        cr.relLineTo(0.2, -0.2);
+        cr.relLineTo(0.2, 0.2);
+        cr.setLineJoin(LineJoin.BEVEL);
+        cr.stroke();
 
+        cr.moveTo(0.3, 0.93);
+        cr.relLineTo(0.2, -0.2);
+        cr.relLineTo(0.2, 0.2);
+        cr.setLineJoin(LineJoin.ROUND);
+        cr.stroke();
 
-	}
+    }
 
-	/**
-	 * text snippet
-	 */
-	public void text(Context cr, double width, double height) {
-		normalize (cr, width, height);
-		cr.selectFontFace("Sans", FontSlant.NORMAL, FontWeight.BOLD);
-		cr.setFontSize(0.35);
+    /**
+     * text snippet
+     */
+    public void text(Context cr, double width, double height) {
+        normalize(cr, width, height);
+        cr.selectFontFace("Sans", FontSlant.NORMAL, FontWeight.BOLD);
+        cr.setFontSize(0.35);
 
-		cr.moveTo(0.04, 0.53);
-		cr.showText("Hello");
+        cr.moveTo(0.04, 0.53);
+        cr.showText("Hello");
 
-		cr.moveTo(0.27, 0.65);
-		cr.textPath("void");
-		cr.save();
-		cr.setSourceRGB(0.5,0.5,1);
-		cr.fill();
-		cr.restore();
-		cr.setLineWidth(0.01);
-		cr.stroke();
+        cr.moveTo(0.27, 0.65);
+        cr.textPath("void");
+        cr.save();
+        cr.setSourceRGB(0.5, 0.5, 1);
+        cr.fill();
+        cr.restore();
+        cr.setLineWidth(0.01);
+        cr.stroke();
 
-		/* draw helping lines */
-		cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
-		cr.arc(0.04, 0.53, 0.02, 0, 2*M_PI);
-		cr.arc(0.27, 0.65, 0.02, 0, 2*M_PI);
-		cr.fill();
-	}
+        /* draw helping lines */
+        cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
+        cr.arc(0.04, 0.53, 0.02, 0, 2 * M_PI);
+        cr.arc(0.27, 0.65, 0.02, 0, 2 * M_PI);
+        cr.fill();
+    }
 
-	/**
-	 * text_align_center snippet
-	 */
-	public void text_align_center(Context cr, double width, double height) {
+    /**
+     * text_align_center snippet
+     */
+    public void text_align_center(Context cr, double width, double height) {
 
-		normalize (cr, width, height);
+        normalize(cr, width, height);
 
-		cr.selectFontFace("Sans", FontSlant.NORMAL, FontWeight.NORMAL);
-		cr.setFontSize(0.2);
-		TextExtents extents = cr.textExtents("cairo");
-		double x = 0.5 -((extents.getWidth()/2.0) + extents.getXBearing());
-		double y = 0.5 -((extents.getHeight()/2.0) + extents.getYBearing());
+        cr.selectFontFace("Sans", FontSlant.NORMAL, FontWeight.NORMAL);
+        cr.setFontSize(0.2);
+        TextExtents extents = cr.textExtents("cairo");
+        double x = 0.5 - ((extents.getWidth() / 2.0) + extents.getXBearing());
+        double y = 0.5 - ((extents.getHeight() / 2.0) + extents.getYBearing());
 
-		cr.moveTo(x, y);
-		cr.showText("cairo");
+        cr.moveTo(x, y);
+        cr.showText("cairo");
 
-		/* draw helping lines */
-		cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
-		cr.arc(x, y, 0.05, 0, 2*M_PI);
-		cr.fill();
-		cr.moveTo(0.5, 0);
-		cr.relLineTo(0, 1);
-		cr.moveTo(0, 0.5);
-		cr.relLineTo(1, 0);
-		cr.stroke();
-	}
-	
-	/**
-	 * text_extents snippet
-	 */
-	public void text_extents(Context cr, double width, double height) {
-		double x=0.1;
-		double y=0.6;
-		String utf8 = "cairo";
-		normalize (cr, width, height);
+        /* draw helping lines */
+        cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
+        cr.arc(x, y, 0.05, 0, 2 * M_PI);
+        cr.fill();
+        cr.moveTo(0.5, 0);
+        cr.relLineTo(0, 1);
+        cr.moveTo(0, 0.5);
+        cr.relLineTo(1, 0);
+        cr.stroke();
+    }
 
-		cr.selectFontFace("Sans", FontSlant.NORMAL, FontWeight.NORMAL);
+    /**
+     * text_extents snippet
+     */
+    public void text_extents(Context cr, double width, double height) {
+        double x = 0.1;
+        double y = 0.6;
+        String utf8 = "cairo";
+        normalize(cr, width, height);
 
-		cr.setFontSize(0.4);
-		TextExtents extents = cr.textExtents(utf8);
+        cr.selectFontFace("Sans", FontSlant.NORMAL, FontWeight.NORMAL);
 
-		cr.moveTo(x,y);
-		cr.showText(utf8);
+        cr.setFontSize(0.4);
+        TextExtents extents = cr.textExtents(utf8);
 
-		/* draw helping lines */
-		cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
-		cr.arc(x, y, 0.05, 0, 2*M_PI);
-		cr.fill();
-		cr.moveTo(x,y);
-		cr.relLineTo(0, -extents.getHeight());
-		cr.relLineTo(extents.getWidth(), 0);
-		cr.relLineTo(extents.getXBearing(), -extents.getYBearing());
-		cr.stroke();
-	}
+        cr.moveTo(x, y);
+        cr.showText(utf8);
 
-	/**
-	 * xxx_clip_rectangle snippet
-	 */
-	public void xxx_clip_rectangle(Context cr, double width, double height) {
-		normalize (cr, width, height);
+        /* draw helping lines */
+        cr.setSourceRGBA(1, 0.2, 0.2, 0.6);
+        cr.arc(x, y, 0.05, 0, 2 * M_PI);
+        cr.fill();
+        cr.moveTo(x, y);
+        cr.relLineTo(0, -extents.getHeight());
+        cr.relLineTo(extents.getWidth(), 0);
+        cr.relLineTo(extents.getXBearing(), -extents.getYBearing());
+        cr.stroke();
+    }
 
-		cr.newPath();
-		cr.moveTo(.25, .25);
-		cr.lineTo(.25, .75);
-		cr.lineTo(.75, .75);
-		cr.lineTo(.75, .25);
-		cr.lineTo(.25, .25);
-		cr.closePath();
+    /**
+     * xxx_clip_rectangle snippet
+     */
+    public void xxx_clip_rectangle(Context cr, double width, double height) {
+        normalize(cr, width, height);
 
-		cr.clip();
+        cr.newPath();
+        cr.moveTo(.25, .25);
+        cr.lineTo(.25, .75);
+        cr.lineTo(.75, .75);
+        cr.lineTo(.75, .25);
+        cr.lineTo(.25, .25);
+        cr.closePath();
 
-		cr.moveTo(0, 0);
-		cr.lineTo(1, 1);
-		cr.stroke();
-	}
+        cr.clip();
 
-	/**
-	 * xxx_dash snippet
-	 */
-	public void xxx_dash(Context cr, double width, double height) {
-		double dashes[] = {0.20,  /* ink */
-		                   0.05,  /* skip */
-		                   0.05,  /* ink */
-		                   0.05   /* skip*/ 
-		                  };
-		double offset = -0.2; 
+        cr.moveTo(0, 0);
+        cr.lineTo(1, 1);
+        cr.stroke();
+    }
 
-		normalize(cr, width, height);
+    /**
+     * xxx_dash snippet
+     */
+    public void xxx_dash(Context cr, double width, double height) {
+        double dashes[] = { 0.20, /* ink */
+        0.05, /* skip */
+        0.05, /* ink */
+        0.05 /* skip */
+        };
+        double offset = -0.2;
 
-		cr.setDash(dashes, offset);
+        normalize(cr, width, height);
 
-		cr.moveTo(0.5, 0.1);
-		cr.lineTo(0.9, 0.9);
-		cr.relLineTo(-0.4, 0.0);
-		cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
-		cr.stroke();
-	}
+        cr.setDash(dashes, offset);
 
-	/**
-	 * xxx_long_lines snippet
-	 */
-	public void xxx_long_lines(Context cr, double width, double height) {
-		normalize(cr, width, height);
+        cr.moveTo(0.5, 0.1);
+        cr.lineTo(0.9, 0.9);
+        cr.relLineTo(-0.4, 0.0);
+        cr.curveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
+        cr.stroke();
+    }
 
-		cr.moveTo(0.1, -50);
-		cr.lineTo(0.1,  50);
-		cr.setSourceRGB(1, 0 ,0);
-		cr.stroke();
+    /**
+     * xxx_long_lines snippet
+     */
+    public void xxx_long_lines(Context cr, double width, double height) {
+        normalize(cr, width, height);
 
-		cr.moveTo(0.2, -60);
-		cr.lineTo(0.2,  60);
-		cr.setSourceRGB(1, 1 ,0);
-		cr.stroke();
+        cr.moveTo(0.1, -50);
+        cr.lineTo(0.1, 50);
+        cr.setSourceRGB(1, 0, 0);
+        cr.stroke();
 
-		cr.moveTo(0.3, -70);
-		cr.lineTo(0.3,  70);
-		cr.setSourceRGB(0, 1 ,0);
-		cr.stroke();
+        cr.moveTo(0.2, -60);
+        cr.lineTo(0.2, 60);
+        cr.setSourceRGB(1, 1, 0);
+        cr.stroke();
 
-		cr.moveTo(0.4, -80);
-		cr.lineTo(0.4,  80);
-		cr.setSourceRGB(0, 0 ,1);
-		cr.stroke();
-	}
+        cr.moveTo(0.3, -70);
+        cr.lineTo(0.3, 70);
+        cr.setSourceRGB(0, 1, 0);
+        cr.stroke();
 
-	/**
-	 * xxx_multi_segment_caps snippet
-	 */
-	public void xxx_multi_segment_caps(Context cr, double width, double height) {
-		normalize(cr, width, height);
+        cr.moveTo(0.4, -80);
+        cr.lineTo(0.4, 80);
+        cr.setSourceRGB(0, 0, 1);
+        cr.stroke();
+    }
 
-		cr.moveTo(0.2, 0.3);
-		cr.lineTo(0.8, 0.3);
+    /**
+     * xxx_multi_segment_caps snippet
+     */
+    public void xxx_multi_segment_caps(Context cr, double width, double height) {
+        normalize(cr, width, height);
 
-		cr.moveTo(0.2, 0.5);
-		cr.lineTo(0.8, 0.5);
+        cr.moveTo(0.2, 0.3);
+        cr.lineTo(0.8, 0.3);
 
-		cr.moveTo(0.2, 0.7);
-		cr.lineTo(0.8, 0.7);
+        cr.moveTo(0.2, 0.5);
+        cr.lineTo(0.8, 0.5);
 
-		cr.setLineWidth(0.12);
-		cr.setLineCap (LineCap.ROUND);
-		cr.stroke();
-	}
+        cr.moveTo(0.2, 0.7);
+        cr.lineTo(0.8, 0.7);
 
-	/**
-	 * xxx_self_intersect snippet
-	 */
-	public void xxx_self_intersect(Context cr, double width, double height) {
-		normalize(cr, width, height);
+        cr.setLineWidth(0.12);
+        cr.setLineCap(LineCap.ROUND);
+        cr.stroke();
+    }
 
-		cr.moveTo(0.3, 0.3);
-		cr.lineTo(0.7, 0.3);
+    /**
+     * xxx_self_intersect snippet
+     */
+    public void xxx_self_intersect(Context cr, double width, double height) {
+        normalize(cr, width, height);
 
-		cr.lineTo(0.5, 0.3);
-		cr.lineTo(0.5, 0.7);
+        cr.moveTo(0.3, 0.3);
+        cr.lineTo(0.7, 0.3);
 
-		cr.setLineWidth(0.22);
-		cr.setLineCap(LineCap.ROUND);
-		cr.setLineJoin(LineJoin.ROUND);
-		cr.stroke();
-	}
+        cr.lineTo(0.5, 0.3);
+        cr.lineTo(0.5, 0.7);
+
+        cr.setLineWidth(0.22);
+        cr.setLineCap(LineCap.ROUND);
+        cr.setLineJoin(LineJoin.ROUND);
+        cr.stroke();
+    }
 }



More information about the cairo-commit mailing list