top of page

Lesson #6: Colored Lines and Vector Functions

chrisbentley349

Updated: Dec 7, 2024




Notes:





Code:




Hints:


Step #1: Adding per-pixel color


The only difference is the additional arguments for red, green, blue:


Now we set color for every pixel we draw:


Now we have to also swap colors and calculate color slopes:


Step #2: Adding class/struct to encapsulate variables:


Add SWAP_POINT() function:


Add class to hold pos[] and color[] data for POINT:


Rewrite draw_line() function to use POINT class:



Step #3: Use "vector" instructions to make code more compact:


Add "vector" functions:


Rewrite draw_line() function using "vector" routines:



Step #4: combining cases to make code shorter:


Exercises:


write draw_quad() function to draw rectangle using POINTs:


Write function to draw one quad:




Write function to draw many quads:




6 views0 comments

Recent Posts

See All

Comments


bottom of page