What I'm trying to reproduce is a set of functions that convert a vector to RGB values so that the hue goes full circle around the origin. After seeing a 3Blue1Brown video about graphically solving 2D-equations which have 2D outputs, like complex functions, I wanted to replicate the algorithm in Matlab.
The brightening of the colors radiating from the origin is somewhat trivial, but it's the colors I'm interested in.
I decided to fiddle around in MS Paint to see what kinds of values fully saturated RGB colors have. For a red color (brightness half the way) the values are obviously $[255,0,0]$. Similarly for green and blue. Yellow, greenblue (sorry not English :D) and pink have values like $[255, 255, 0]$ and so on. The colors in between are faded appropriately. So for example red is only present in colors ranging from blue to green via red.
What function could be used to convert, say an angle with respect to the x-axis to the amount of red in a direction? I don't care so much about the fade curve or the rotation of the plane above. Only that the colors form a full hue.
Here's a crude visualisation of each color channel:
Any pointers would be greatly appreciated, be them purely mathematical or actual Matlab.


One can use color space transforms as mentioned in the comments to convert hue to rgb. Hue can be easily extracted from a 2D-plane as follows (in Matlab):
Let us first construct a function called
hue, which will convert a 2D-vector or a 2xN array of points and give back their magnitudes and hue values from 0 to 1. We'll input a matrix of the desired points around the origin, construct an HSV image and convert it to RGB using Matlab's builtinhsv2rgbfunction. Now we have the final image. For an image of size 21 (range 10) the result is very neat: