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:
3 Google Cloud Tools That Put the Power of Generative AI in Your Hands Generative AI is changing everything, but how do you move from simply using it to actually building with it? Having access to powerful models is one thing, but having the right tools to harness them is the real game-changer. This is where a robust cloud ecosystem becomes essential, providing pathways for every skill level to innovate. In this post, we’ll break down three core Google Cloud services— Vertex AI Studio , Vertex AI Agent Builder , and Gemini —that provide a clear path for everyone from seasoned developers to complete beginners to build the next generation of AI applications. For the Pro-Developer: Vertex AI Studio Think of Vertex AI Studio as the ultimate developer's workbench for generative AI. It’s a comprehensive platform designed for those who want to get their hands dirty, customize models, and deploy them seamlessly into their applications on Google Cloud. Key Features Vertex AI Studio equi...
Comments
Post a Comment