My class is using a software sketchbook called processing. We are learning about
ID: 670608 • Letter: M
Question
My class is using a software sketchbook called processing. We are learning about loadin images using it. I'm having a hard time loading multiple images. I am able to load the background image at the size I wanted as shown below:
// Declaring a variable of type PImage
PImage img;
void setup()
{
size(1200,800);
// Make a new instance of a PImage by loading an image file
img = loadImage("beach.jpg");
}
void draw() {
background(0);
// Draw the image to the screen at coordinate (0,0)
image(img,0,0);
}
I'm not sure how to load the three images that I need. This is the assignment I have to do:
In processing load at least 5 images and compose a nice scene.
Example: you could use a beach background image, a cloud image, a boat image, a surfer image etc. and show in every frame the background and animate the cloud to move to the right, and the boat to move to the left, and the surfer to move to the right maybe faster than the boat.
Example 2: you could use a country scene background and have a bird fly to the left, an airplane fly to the right, a car move in the road to the left etc.
REQUIREMENTS:
Use at least 5 images.
The size of each image should be no higher than 800x800.
The size of the window should be no more than 1200x800 (in the class I use 800x600).
At least 3 images should move in different directions/speed (for example: -1, +1, +3).
I don't need the images, I have those. I just need to know what to write to get my smaller images to show on the background I have loaded.
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<style>
img {
width:100%;
}
</style>
</head>
<body>
<img src="html5.gif" alt="HTML5 Icon">
<img src="html5.gif" alt="HTML5 Icon" width="128" height="800">
<img src="html5.gif" alt="HTML5 Icon">
<img src="html5.gif" alt="HTML5 Icon" width="1200" height="800">
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.