Skip to main content

repeat image in background

2 replies [Last post]
riepi
Offline
Joined: 2008-03-27
Points: 0

Hi,
is there a way to repeat an image/texture? I don't want to scale it but to repeat as my Frame grows.
Any ideas or just a piece of function and some kind of math?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
copaccabana
Offline
Joined: 2007-09-24
Points: 0

Hi,
The best to do this is to extends TexturePaint as mentioned in this article
http://blog.javadojo.net/roller/javadriven/entry/javafx_texture_paint
code ex:
public class Texture extends Paint {

public attribute image : Image;

public attribute anchorRect : Rectangle;

public function getAWTPaint() : java.awt.Paint {
var rect: java.awt.Rectangle = new java.awt.Rectangle();
rect.x = anchorRect.x as Integer;
rect.y = anchorRect.y as Integer;
rect.width = anchorRect.width as Integer;
rect.height = anchorRect.height as Integer;
return new java.awt.TexturePaint(image.getBufferedImage(), rect);
}
}
Enjoy!!!

alexsch
Offline
Joined: 2007-07-12
Points: 0

For example:

[code]
import javafx.application.*;
import javafx.scene.image.*;

Frame {
title: "MyApplication"
width: 800
height: 800

stage: Stage {
content: for (i in [0..2])
for(j in [0..2])
ImageView {
x: i * 200
y: j * 200
image: Image {
url: "{__DIR__}/image.png"
}
}

}
visible: true
}
[/code]