代写Assignment 2: Pixel Graphics代写R编程

Assignment 2: Pixel Graphics

Overview

In this assignment, you will implement functions which perform. drawing operations into an in-memory image representation, in both C and x86-64 assembly language.

Warning: Assembly language programming is challenging! Make sure you start each milestone as soon as possible, work steadily, and ask questions early. Also, writing unit tests and using gdb to examine the detailed behavior. of code under test will be critical to successful implementation of the assembly language functions.

Non-functional requirements

In Milestones 2 and 3, you will be writing assembly language functions. You must write these "by hand", and your assembly code must have very detailed code comments explaining the purpose of each assembly language instruction.

It is not allowed to generate assembly code using a C compiler and submit this as your own code. We will assign a grade of 0 to any submissions containing compiler-generated code where hand-written assembly language is expected.

Your submission for each milestone should include a README. txt file describing how you and your partner divided the work, and letting us know about any interesting implementation details. If there is functionality you weren't able to get working completely, this is a good place to mention that.

We expect you to follow the style. guidelines. However, the expectations for function length will be relaxed considerably for your assembly language code. It is not unusual for an assembly language function to have 100 or more lines of code. In the reference solution, the longest function was 170 lines, although there was extensive use of comments and whitespace to improve readability.

Of course, you should strive to make your assembly language functions as simple and readable as possible.

We expect your code to be free of memory errors. You should use valgrind to test your code to make sure there are no uses of uninitialized variables, out of bounds memory reads or writes, etc. This applies to both your C code and your assembly code.

Getting started

To get started, download csf_assign02.zip and unzip it.

Grading breakdown

Your grade for the assignment will be determined as follows:

Milestone 1: 30%

o Implementation of C drawing functions: 12.5%

o Unit testing of helper functions: 12.5%

o Design/coding style. of C functions: 5%

Milestone 2: 35%

o Functional correctness of draw_pixel: 15%

Unit testing of helper functions (existence of tests, evidence that they pass): 15%

o Design/coding style. of assembly functions: 5%

Milestone 3: 35%

o Functional correctness of draw_rect: 13.5%

o Functional correctness of draw_circle : 13.5%

o Functional correctness of draw_tile: 1.5%

o Functional correctness of draw_sprite:1.5%

o Design/coding style. of assembly functions: 5%

Note that in each milestone, we expect all of the tests executed by your unit test program to pass. For MS2 in particular, you can comment out calls to test functions that aren't related to draw_pixel. For example, your main function might have code similar to the following:

The tests for in_bounds,blend_colors,blend_components, and draw_pixel are enabled because they are all test functions involved in the implementation of draw pixel The test for draw_rect is commented out because it is not part of the functionality expected for MS2.

Drawing functions

Here are the prototypes of the drawing functions you will implement:

Briefly:

draw_pixel draws a single pixel, blending the specified color value with the current background color

draw_rect draws a filled rectangle with the specified upper-left corner, width and height, blending the specified color with the colors of the existing pixels

draw_circle draws a filled circle of specified radius centered at the specified x /y coordinates, blending the specified color with the colors of the existing pixels

draw_tile copies pixels from the specified rectangular region of a tilemap image to the specified location (x /y) of a destination image, without blending any of the copied colors with the existing colors

draw_sprite is similar to draw_tile, but the pixels of the copied "sprite" are blended with the existing pixel colors

struct Image and struct Rect data types

To understand the functionality of the drawing functions, it is necessary to understand the struct Image and struct Rect data types, as well as how colors are represented.

The struct Image type is defined as follows:

The width and height fields define the width and height of an image, in pixels. The data field is a pointer to a dynamically-allocated array of uint32_t values, each one representing one pixel. The pixels are stored in row-major order, starting with the top row of pixels.

A color is represented by a uint32_t value as follows:

Bits 24-31 are the 8 bit red component value, ranging from 0-255

Bits 16-23 are the 8 bit green component value, ranging from 0-255

Bits 8-15 are the 8 bit blue component value, ranging from 0-255

Bits 0-7 are the 8 bit alpha value, ranging from 0-255

The alpha value of a color represents its opacity, with 255 meaning "fully opaque" and O meaning "fully transparent". (See the Color blending section for details on how an alpha value allows two colors to be "blended".)

The struct Rect data type is defined as follows:

An instance of struct Rect describes a rectangle where the upper-left corner is specified by x and the width of the rectangle (in pixels) is specified by width, and the height of the rectangle (in pixels) is specified by height

Color blending

The color values of the destination image are always fully opaque, with an alpha value of 255.

When a pixel is drawn to a destination image by any operation other than draw_tile, the pixel's color, which we'll call the "foreground" color, is blended with the existing color at the location where the pixel is being drawn, which we'l call the "background" color. To find the correct color value for the new pixel, the following computation is performed for each color component, where f is the foreground color component value, b is the background color component value, and o is the alpha value of the foreground color:

Note that the result of the division is truncated rather than being rounded, so if you use integer division, it will behave in the expected way.

A blended color should have each color component value (red, green, and blue) computed using the formula above, and the alpha value of the blended color should be set to 255.

The draw_pixel, draw_rect, draw_circle, and draw_sprite functions all should use color blending. The exception is the draw_tile function, which does not blend the copied tile colors with the existing pixel colors.

Drawing a circle

The drawing functions should be implemented entirely using integer arithmetic. When drawing a filled circle, all of the pixels within r units of distance from the circle's center should be drawn with the specified color. Ordinarily, if the pixel's center is at x, y and the point being considered is at j, i , determining if j, i is in the circle would be determined by the inequality

The square root operation would require floating point math. However, we could square both sides of the inequality to give us

This computation only requires integer arithmetic.




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图