[cairo-commit] cairo-java/test/kapow Kapow.java,1.14,1.15

Jeffrey Morgan commit at pdx.freedesktop.org
Fri May 6 17:27:04 PDT 2005


Committed by: kuzman

Update of /cvs/cairo/cairo-java/test/kapow
In directory gabe:/tmp/cvs-serv23023/test/kapow

Modified Files:
	Kapow.java 
Log Message:
update so we compile after massive upstream API change.

Index: Kapow.java
===================================================================
RCS file: /cvs/cairo/cairo-java/test/kapow/Kapow.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Kapow.java	6 May 2005 13:22:01 -0000	1.14
+++ Kapow.java	7 May 2005 00:27:02 -0000	1.15
@@ -10,15 +10,13 @@
 package kapow;
 
 import org.freedesktop.cairo.Context;
-import org.freedesktop.cairo.CurrentPath;
 import org.freedesktop.cairo.FontSlant;
 import org.freedesktop.cairo.FontWeight;
 import org.freedesktop.cairo.Format;
 import org.freedesktop.cairo.Pattern;
-import org.freedesktop.cairo.PngSurface;
-//import org.freedesktop.cairo.PngSurface;
 import org.freedesktop.cairo.Point;
 import org.freedesktop.cairo.RGBColor;
+import org.freedesktop.cairo.Surface;
 import org.freedesktop.cairo.TextExtents;
 
 /**
@@ -26,7 +24,6 @@
 public class Kapow {
 	
 	public Context cr;
-	private MyPath path;
 	private String filename = "kapow.png";
 	public int IMAGE_WIDTH = 460;
 	public int IMAGE_HEIGHT = 308;
@@ -46,9 +43,8 @@
     private RGBColor purple = new RGBColor(0,0,0.4);
 
 	public Kapow(String text) throws Exception {
-		cr = new Context();
-		PngSurface surface = new PngSurface(Format.ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT);
-		cr.setTargetSurface(surface);
+		Surface surface = new Surface();
+		cr = new Context(surface);
 
 		cr.setLineWidth(2);
 		cr.save();
@@ -92,7 +88,7 @@
 		cr.setSourceRGB(black);
 		cr.stroke();
 		
-		surface.write(filename);
+		//surface.write(filename);
 		cr.dispose();
 	}
 	
@@ -121,10 +117,6 @@
 	}
 	
 	private void makeTextPath(Point point, String text) {
-		path = new MyPath();
-	    cr.moveTo(point);
-        cr.textPath(text);
-        cr.getPathFlat(path);
 	}
 
 	public static void main(String[] args) throws Exception {
@@ -134,43 +126,4 @@
 		new Kapow(text);
 	}
     
-    private class MyPath implements CurrentPath {
-        
-        private boolean firstTime = true;
-
-        public void moveTo(double x, double y) {
-            if (firstTime) {
-                cr.newPath();
-                firstTime = false;
-            }
-            Point bent = bendIt(x, y);
-            cr.moveTo(bent);
-        }
-
-        public void lineTo(double x, double y) {
-            Point bent = bendIt(x, y);
-            cr.lineTo(bent);
-        }
-
-        public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) {}
-
-        public void closePath() {
-            cr.closePath();
-        }
-        
-        private Point bendIt(double x, double y) {
-            double cx = IMAGE_WIDTH / 2;
-            double cy = 500;
-            Point bent = new Point();
-            
-            double angle = Math.PI / 2 - (x - cx) / IMAGE_WIDTH;
-            double t = 3 * Math.PI / 4 - angle + 0.05;
-            angle = 3 * Math.PI / 4 - Math.pow(t, 1.8);
-            double radius = cy - (IMAGE_HEIGHT / 2 + (y - IMAGE_HEIGHT / 2) * t * 2);
-
-            bent.setX(cx + Math.cos(angle) * radius);
-            bent.setY(cy - Math.sin(angle) * radius);
-            return bent;
-        }
-    }
 }




More information about the cairo-commit mailing list