|
Author |
Topic: image backgrounds (Read 1017 times) |
|
benelek
|
image backgrounds
« on: Jan 15th, 2003, 1:01am » |
|
i don't suppose it's possible to have an image as the background? ie, background(theImage); it's all good and fun drawing images to specific points in a 3d space, but can i draw the image at the size of the applet, and behind everything else (without the bother of resizing and repositioning it whenever i move something backwards)?
|
« Last Edit: Jan 15th, 2003, 1:04am by benelek » |
|
|
|
|
benelek
|
Re: image backgrounds
« Reply #1 on: Jan 15th, 2003, 2:44am » |
|
hehe, oooh i think i found an answer to this one myself (as soon as the color array thing is fixed). check out the following in the meantime: Code: void setup() { size(228,240); background(255); moo=loadImage("moo.gif"); mooPixGreen = new int[pixels.length]; } BImage moo; int[] mooPixGreen; boolean firstTime=true; void loop() { if(firstTime) { image(moo,0,0); for(int i=0; i<pixels.length; i++) { mooPixGreen[i]=int(green(pixels[i])); } firstTime=false; } System.arraycopy(mooPixGreen,0,pixels,0,mooPixGreen.length); // put ur other stuff here. } |
| of course, u have to have the image in the data directory... and, because i'm using an int array to store the image (instead of a color array), u can only use one channel at a time. but it's cool anyway -jacob
|
|
|
|
fry
|
Re: image backgrounds
« Reply #2 on: Jan 15th, 2003, 2:49am » |
|
use noBackground() inside setup.. then at the beginning of your loop(), include this: System.arraycopy(mooPixGreen.pixels, 0, pixels, 0, pixels.length); your image should be the same as what you setup with for size() background(some_image) will be added in the future.
|
|
|
|
benelek
|
Re: image backgrounds
« Reply #3 on: Jan 15th, 2003, 2:51am » |
|
mm, yes a somewhat shorter method
|
|
|
|
benelek
|
Re: image backgrounds
« Reply #4 on: Jan 15th, 2003, 2:56am » |
|
actually, i didn't realise p5 could store whole colours in int format. using "mooPixBlue[i]=pixels[i];" instead of "mooPixBlue[i]=int(blue(pixels[i]));" will store all the colour information for that pixel, not just a certain chanel.
|
|
|
|
REAS
|
Re: image backgrounds
« Reply #5 on: Jan 15th, 2003, 5:23pm » |
|
For clarity: Code: BImage bg; void setup() { size(200,200); noBackground(); bg = loadImage("sky.jpg"); } void loop() { // Loads image into the background very quickly System.arraycopy(bg.pixels, 0, pixels, 0, width*height); } |
|
|
« Last Edit: Jan 15th, 2003, 5:23pm by REAS » |
|
|
|
|
benelek
|
Re: image backgrounds
« Reply #7 on: Jan 16th, 2003, 4:43am » |
|
on Jan 15th, 2003, 5:23pm, REAS wrote: Code: System.arraycopy(bg.pixels, 0, pixels, 0, width*height); |
| |
| hmm... any date set for updating the reference section object properties like "img.pixels" are like invisible gifts being unveiled one by one -jacob
|
« Last Edit: Jan 16th, 2003, 4:43am by benelek » |
|
|
|
|
REAS
|
Re: image backgrounds
« Reply #8 on: Jan 20th, 2003, 10:36am » |
|
I think many invisible gifts will remain invisible, but some like this will be documented. We're trying to keep the docs as small as possible.
|
|
|
|
|