1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Minchanka [31]
3 years ago
11

Write the method mirrorVerticalRightToLeft that mirrors a picture around a mirror placed vertically from right to left.

Computers and Technology
1 answer:
AURORKA [14]3 years ago
3 0

Answer:

Here is the method mirrorVerticalRightToLeft

public void mirrorVerticalRightToLeft()  {  //method definition

 Pixel[][] pixels = this.getPixels2D();  //uses getPixels2D() method which returns a two-dimensional array of Pixel object and stores this in pixels

 Pixel leftPixel = null;  //Pixel object leftPixel set to null

 Pixel rightPixel = null;  //Pixel object rightPixel set to null

 int width = pixels[0].length;  // returns the length of 0-th element of pixels and assigns it to width

 for (int row = 0; row < pixels.length; row++) {  //iterates through the rows of pixels array

  for (int col = 0; col < width / 2; col++)  {  //iterates through the columns of pixels array

   leftPixel = pixels[row][col];  //sets leftPixel to a certain point of row and column  of pixel array

   rightPixel = pixels[row][width - 1 - col];  //sets rightPixel to a certain point of row and column  of pixel array

   leftPixel.setColor(rightPixel.getColor());  }  }  } //uses object leftPixel to call setColor() method to set color of leftPixel to specified color and rightPixel is used to call getColor method to get the current color

Explanation:

The method mirrorVerticalRightToLeft is used to mirror a picture around a mirror placed vertically from right to left. It uses two loops, the outer loop iterates through each row and inner loop iterates through columns as long as the col variable stays less than width / 2 whereas width is set to pixels[0].length which compute the length of 0-th pixel. At each iteration we have the two position instance variables i.e. leftPixel and rightPixel such that leftPixel is set to pixels[row][col] and rightPixel is set to pixels[row][width - 1 - col]; For example if row = 0 and col = 0 then

leftPixel = pixels[0][0] which means it is positioned at 0th row and 0th column of 2D pixels array so it is positioned at the 1st pixel/element. It works this way at each iteration.

rightPixel = pixels[row][width - 1 - col]; for same example becomes:

rightPixel = pixels[0][width - 1 - 0];

So whaterbe is the value of width, the rightPixel is positioned at 0th row and width-1th column. Now after each of leftPixel and rightPixel  is placed to the desired pixel of pixels array then next the statement: leftPixel.setColor(rightPixel.getColor()); executes in which leftPixels calls setColor which sets the color to the specified color and rightPixel calls getColor method to get the current color. Suppose getColor returns the color blue so this color is set to leftPixel and this is how the picture is mirrored.

You might be interested in
Differentiate between tabular and column form layout​
NeTakaya

In tabular form the data is displayed in a table layout following a continuous series of records. In this almost all the records are displayed in a single layout. While in columnar form the data is displayed one record at a time.

6 0
3 years ago
What is the job of a bootloader?
VladimirAG [237]

Answer:

A bootloader, also known as a boot program or bootstrap loader, is a special operating system software that loads into the working memory of a computer after start-up.

Explanation:

6 0
3 years ago
Read 2 more answers
I need advice, please try to give a full paragraph and include a p r o s and c o n s list, no l i n k s please, it would mean so
Vlad [161]

Answer:

I think you should do what are passionate about. therefore it might gain more followers. Also so it's not boring and it's enjoyable for you. also it will be easier for you to do. the pros are you will put in extra efforts, it will make you happy, it will workout longer, it can help you grow as a person. the cons are you may lose followers, it may be hard to think of content, you might not make money, people may try to bring you down.

i think you should make a different account and try it. either make another account for art or make another for vlogs.

But honestly just try it out and see how it goes.

Explanation:

7 0
3 years ago
Which measure should you take for the periodic maintenance of your computer?
WITCHER [35]
I believe the answer is annual maintenance
Hope this helps :p
6 0
4 years ago
Read 2 more answers
Which is the most common way to install memory in a laptop?
alina1380 [7]

install memory requires you to take off the bottom portion of the laptop.

7 0
3 years ago
Other questions:
  • Background Susan finished work on system architecture issues, and her system design specification was approved. Now she is ready
    15·1 answer
  • Amy has decided to use a dark background and light colored text for her prensentation. Which toolbar option will let her change
    5·1 answer
  • Once I install my secondary hard drive what two tasks need to be done?
    13·1 answer
  • What are some facts about webmasters?
    10·1 answer
  • What do yo need to do for device manager to display nonpresent devices?
    9·1 answer
  • Marissa bought 2 and 1/2 gallons of orange juice to make punch how many quarts of orange juice did Marissa Buy
    15·2 answers
  • Consider the following C code fragment:
    10·1 answer
  • Write a pseudocode thats accept and then find out whether the number is divisible by 5 ​
    6·1 answer
  • Can you predict what changes will come to data storage in the next decade? 
    12·1 answer
  • A machine that converts energy to useful work.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!