View Code? Open in Web Editor
NEW
A method to color triangles based on multiple computer graphics algorithms
License: MIT License
computer-graphics's Introduction
- Hi, I’m Sourland
- I’m interested in a lot of engineering fields
- I’m currently studying Electrical and Computer Engineering in Aristotle University of Thessaloniki
- I’m looking to collaborate on anything...really
- How to reach me [email protected]
- Currently busy with AcubeSAT Project by SpaceDot
- Lead Software Engineer of PeakSAT project by SpaceDot
computer-graphics's People
Contributors
Stargazers
Watchers
computer-graphics's Issues
Name: value = interpolate_color(x1, x2, x, C1, C2)
Input:
x1, x2
-> 2D triangle vertices coordinates
x
->the point that interpolation is applied to
C1, C2
-> 3D components of x1, x2
color values
Returns:
value
->The interpolation of C1, C2.
A function that fills triangles with colors
Name: Y = shade_triangle(img, verts2d, vcolors, shade_t = "flat")
Input:
img
-> an NxMx3 array with existing triangles
verts2d
-> a 3x2 array containing triangle vertices coordinates
vcolors
-> a 3x3 array containing the rgb value of each vertice ([0,1] range)
shade_t
-> the algorithm alternations ("Flat" or "Gouraud")
Returns:
-
Y
-> a NxMx3 array containing (Ri, Gi, Bi) color components for every i point of a triangle, with the pre-existing triangles
-
Flat
variation: Every Triangle gets one color: the vertices color mean
-
Gouraud
variation: Every pixel of the triangle is colored using linear interpolation from the triangle's vertices
- Interpolation between vertices
V1
,V2
(Point A
)
- Interpolation between vertices
V1
,V3
(Point B
)
- Interpolation between points
A
,B
(Point P
- Final)
- Use scanline