/hg/gfx-test: 2011-11-04 Pavel Tisnovsky <ptisnovs at redhat.com>

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Nov 4 07:43:36 PDT 2011


changeset cecd2cd40c8b in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=cecd2cd40c8b
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Nov 04 15:45:43 2011 +0100

	2011-11-04 Pavel Tisnovsky <ptisnovs at redhat.com>

	 * src/org/gfxtest/framework/CommonRenderingStyles.java:
	Added new methods for rendering shapes using textures composed
	of horizontal and vertical color stripes.
		* src/org/gfxtest/framework/ProceduralTextureFactory.java:
	Added new methods for creating textures which are composed of
	horizontal and vertical color stripes.


diffstat:

 ChangeLog                                               |    9 +
 src/org/gfxtest/framework/CommonRenderingStyles.java    |   36 ++++
 src/org/gfxtest/framework/ProceduralTextureFactory.java |  124 ++++++++++++++++
 3 files changed, 169 insertions(+), 0 deletions(-)

diffs (217 lines):

diff -r f07124ad3c53 -r cecd2cd40c8b ChangeLog
--- a/ChangeLog	Thu Nov 03 14:22:31 2011 +0100
+++ b/ChangeLog	Fri Nov 04 15:45:43 2011 +0100
@@ -1,3 +1,12 @@
+2011-11-04  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/CommonRenderingStyles.java:
+	Added new methods for rendering shapes using textures composed
+	of horizontal and vertical color stripes.
+	* src/org/gfxtest/framework/ProceduralTextureFactory.java:
+	Added new methods for creating textures which are composed of
+	horizontal and vertical color stripes.
+
 2011-11-03  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/framework/CommonShapesRenderer.java:
diff -r f07124ad3c53 -r cecd2cd40c8b src/org/gfxtest/framework/CommonRenderingStyles.java
--- a/src/org/gfxtest/framework/CommonRenderingStyles.java	Thu Nov 03 14:22:31 2011 +0100
+++ b/src/org/gfxtest/framework/CommonRenderingStyles.java	Fri Nov 04 15:45:43 2011 +0100
@@ -1052,6 +1052,42 @@
     }
 
     /**
+     * Set texture paint using texture consisting of horizontal color stripes.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    public static void setTextureFillUsingHorizontalColorStripesTexture(TestImage image, Graphics2D graphics)
+    {
+        // compute anchor for a texture
+        Rectangle2D anchor = createAnchorRectangle(image);
+
+        // create texture and paint object
+        TexturePaint texturePaint = ProceduralTextureFactory.getHorizontalColorStripesPaint(image, anchor);
+        graphics.setPaint(texturePaint);
+    }
+
+    /**
+     * Set texture paint using texture consisting of vertical color stripes.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    public static void setTextureFillUsingVerticalColorStripesTexture(TestImage image, Graphics2D graphics)
+    {
+        // compute anchor for a texture
+        Rectangle2D anchor = createAnchorRectangle(image);
+
+        // create texture and paint object
+        TexturePaint texturePaint = ProceduralTextureFactory.getVerticalColorStripesPaint(image, anchor);
+        graphics.setPaint(texturePaint);
+    }
+
+    /**
      * Set texture paint using texture consisting of diagonal stripes.
      * 
      * @param image
diff -r f07124ad3c53 -r cecd2cd40c8b src/org/gfxtest/framework/ProceduralTextureFactory.java
--- a/src/org/gfxtest/framework/ProceduralTextureFactory.java	Thu Nov 03 14:22:31 2011 +0100
+++ b/src/org/gfxtest/framework/ProceduralTextureFactory.java	Fri Nov 04 15:45:43 2011 +0100
@@ -85,6 +85,16 @@
     private static BufferedImage verticalStripesTexture = null;
 
     /**
+     * Image used for creating texture containing horizontal color stripes.
+     */
+    private static BufferedImage horizontalColorStripesTexture = null;
+
+    /**
+     * Image used for creating texture containing vertical color stripes.
+     */
+    private static BufferedImage verticalColorStripesTexture = null;
+
+    /**
      * Image used for creating texture containing diagonal stripes.
      */
     private static BufferedImage diagonalStripesTexture = null;
@@ -110,6 +120,20 @@
     private static BufferedImage RGBTexture3 = null;
 
     /**
+     * Eight basic colors.
+     */
+    private static final int[] BASIC_COLORS = {
+        0xff000000,
+        0xff0000ff,
+        0xff00ffff,
+        0xff00ff00,
+        0xffffff00,
+        0xffff0000,
+        0xffff00ff,
+        0xffffffff,
+    };
+
+    /**
      * Create checker texture where tile sizes are based on grid size.
      * 
      * @param gridSize
@@ -350,6 +374,74 @@
     }
 
     /**
+     * Create texture containing horizontal color stripes containing 8 basic colors.
+     * 
+     * @param width
+     *            width of a texture
+     * @param height
+     *            height of a texture
+     * @return buffered image containing texture
+     */
+    private static BufferedImage horizontalColorStripesTextureFactory(int width, int height)
+    {
+        // if the texture already exists, return it
+        if (horizontalColorStripesTexture != null)
+        {
+            return horizontalColorStripesTexture;
+        }
+
+        // create new texture instead
+        horizontalColorStripesTexture  = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // compute color for each pixel
+            int color = BASIC_COLORS[y % 8];
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                horizontalColorStripesTexture.setRGB(x, y, color);
+            }
+        }
+        return horizontalColorStripesTexture;
+    }
+
+    /**
+     * Create texture containing vertical stripes containing 8 basic colors.
+     * 
+     * @param width
+     *            width of a texture
+     * @param height
+     *            height of a texture
+     * @return buffered image containing texture
+     */
+    private static BufferedImage verticalColorStripesTextureFactory(int width, int height)
+    {
+        // if the texture already exists, return it
+        if (verticalColorStripesTexture != null)
+        {
+            return verticalColorStripesTexture;
+        }
+
+        // create new texture instead
+        verticalColorStripesTexture  = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                // compute color for each pixel
+                int color = BASIC_COLORS[x % 8];
+                verticalColorStripesTexture.setRGB(x, y, color);
+            }
+        }
+        return verticalColorStripesTexture;
+    }
+
+    /**
      * Create texture containing diagonal stripes.
      * 
      * @param width
@@ -627,6 +719,38 @@
     }
 
     /**
+     * Return {@link TexturePaint} object containing texture with horizontal color stripes.
+     * These stripes contain eight basic colors.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param anchor
+     *            the Rectangle2D in user space used to anchor and replicate the
+     *            texture
+     * @return {@link TexturePaint} object containing horizontal stripes texture
+     */
+    public static TexturePaint getHorizontalColorStripesPaint(TestImage image, Rectangle2D anchor)
+    {
+        return new TexturePaint(horizontalColorStripesTextureFactory(image.getWidth(), image.getHeight()), anchor);
+    }
+
+    /**
+     * Return {@link TexturePaint} object containing texture with vertical color stripes.
+     * These stripes contain eight basic colors.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param anchor
+     *            the Rectangle2D in user space used to anchor and replicate the
+     *            texture
+     * @return {@link TexturePaint} object containing vertical stripes texture
+     */
+    public static TexturePaint getVerticalColorStripesPaint(TestImage image, Rectangle2D anchor)
+    {
+        return new TexturePaint(verticalColorStripesTextureFactory(image.getWidth(), image.getHeight()), anchor);
+    }
+
+    /**
      * Return {@link TexturePaint} object containing texture with diagonal stripes.
      * 
      * @param image



More information about the distro-pkg-dev mailing list