Question: using this code, answer the question in the image render _ hw 0 1 ( pFrame _ Buffer& fb , HW 0 1 _ Data&

using this code, answer the question in the image
render_hw01(pFrame_Buffer& fb, HW01_Data& hw01_data)
{
// Window Size, in Pixels
//
const int win_width = fb.width_get();
const int win_height = fb.height_get();
const auto& tryout1[[maybe_unused]]= hw01_data.tryout1;
const auto& tryout2[[maybe_unused]]= hw01_data.tryout2;
kbd_input_handle(fb,hw01_data);
image_box_drag(fb,hw01_data); // Update image box corners.
/// Coordinates Used for Placement of Other Objects
//
const int sq_slen = min(win_width,win_height)*.45;
const int sq_x0= sq_slen *0.1, sq_y0= win_height -150;
const int sq_x1= sq_x0+ sq_slen, sq_y1= sq_y0- sq_slen;
//
// One vertex of the square is at (sq_x0,sq_y0) and the opposite
// vertex is at (sq_x1,sq_y1).
// RRGGBB
const uint32_t color_red =0xff0000;
const uint32_t color_blue =0xff;
const uint32_t color_green =0xff00;
/// Demo Code: Draw Sine Waves -- No need to modify this.
//
int num_waves =4;
float plot_ht = sq_slen/float(num_waves);
for ( float
yb = sq_y0- plot_ht/2, freq =4* M_PI /( win_width -40- sq_x1);
yb > sq_y1;
yb -= plot_ht, freq *=2)
for ( int x =20; x win_width -20; x++)
{
int y = yb + sin( x * freq )* plot_ht *.45;
fb[ y * win_width + x ]=0xff00;
}
/// Demo Code: Draw Lines Radiating From a Point -- No need to modify.
//
// This code calls the line_draw routine.
//
int n_rects =24;
int n_pts = n_rects *3;
float c_r1= sq_slen/6; // Inner radius
float c_r2= sq_slen/2; // Outer radius.
pCoor c_ctr( c_r2+20, c_r2+20); // Center of "circle"
float delta_theta =2* M_PI / n_pts;
vector vecs;
for ( int i=0; i= img_pixels.size();
//
//.. and read pixel if they are valid, otherwise use color red.
//
uint32_t img_pixel = out_of_range ? color_red : img_pixels[ img_idx ];
//
// Finally, write image pixel into frame buffer.
//
fb[ fb_y * win_width + fb_x ]= img_pixel;
}Modify the code in render_hw01 so that the aspect ratio is preserved. When zoom is 1(the
default) one image should be across with width of the box, regardless of how the image box is
resized. For this problem don't worry about unfilled parts of the image box (shown in red in the
screenshot).
Hint: This is easy, just one line needs to be changed.
 using this code, answer the question in the image render_hw01(pFrame_Buffer& fb,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!