Now modify the program one more time to replace the two functions pixelOnVerticalEdge and pixelOnHorizontalEdge with one function to do the same thing called pixelOnEdgeDifferentThicknesses( ). The parameters are not shown. You should decide on the parameters. Write the function and test it to make sure it works the same as the two functions it replaces, so you can generate pictures with borders that have different thicknesses for the vertical borders vs. the horizontal borders. Here is an example: Here is an island picture:
Get link
Facebook
X
Pinterest
Email
Other Apps
By
Urban Picasso
-
// write your code here
function setBlack(pixel){
pixel.setBlue(0);
pixel.setGreen(0);
pixel.setRed(0);
return pixel;
}
function pixelOnEdgeDifferentThicknesses(pixel, image, borderWidth){
var x = pixel.getX();
var y = pixel.getY();
if (x < borderWidth) return true;
if (y < (borderWidth+40)) return true;
if (x >= image.getWidth() - borderWidth) return true;
if (y >= image.getHeight() - (borderWidth+40)) return true;
return false;
}
var image = new SimpleImage ("lion.jpg");
print (image);
for ( var pixel of image.values()){
if (pixelOnEdgeDifferentThicknesses(pixel, image, 25) ){
pixel = setBlack(pixel);
}
}
print (image);
Here is the island picture with a border around it: Here is a picture of the island with different thicknesses for the vertical versus horizontal borders:
Choose Your Social Media Channels Week 5 Quiz You’re looking to reach the largest possible audience with the most precise targeted advertising tools. Your go-to social media platform should be: Facebook You’re looking to build a community online. Your go-to social media platform should be: Facebook Which of the following are good general guidelines for a corporate blog? Select all that apply : Blog posts must respect copyright, privacy, fair use, financial disclosure, and other applicable laws Blog posts should not disclose any information that is confidential or proprietary to the company Determine whether the following statement is true or false: Consumers today expect brands to be present on their favorite social media platforms. True Of the three core values that a social media policy should achieve, which category does the following statement fit in? “Nordstrom referred to company guidelines that can help employees to represent the company in a way that doesn’t harm the b...
Comments
Post a Comment