Hello, i'm quiet new in javaFX, and would like to put a texture on a shape (Rectangle, Line, etc). I found somewhere that it's not implemented in the version 2.0.. is that true?
Because i found a sample of code in javafx (old version, maybe 1.3). It use a TexturePaint:
package org.jfxtras.cccp;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javafx.scene.paint.Paint;
/**
* @author Jeff Friesen
*/
public class TexturePaint extends Paint
{
public-init var url: String;
public-init var x: Number;
public-init var y: Number;
public-init var width: Number;
public-init var height: Number;
public override function impl_getPlatformPaint ()
{
def image = new ImageIcon (new java.net.URL (url));
def bi = new BufferedImage (image.getIconWidth (),
image.getIconHeight (),
BufferedImage.TYPE_INT_RGB);
def g = bi.createGraphics ();
g.drawImage (image.getImage (), 0, 0, null);
g.dispose ();
def _width = if (width == 0) then image.getIconWidth () else width;
def _height = if (height == 0) then image.getIconHeight () else height;
def anchor = new Rectangle2D.Double (x, y, _width, _height);
new java.awt.TexturePaint (bi, anchor)
}
}
I tried to adapt that code for the version 2.0 but it doesnt work..
Somebody knows how to do? Or is it just no possible at the moment?
Edited by: 934158 on 14 mai 2012 04:38