Create a light source coming from the specified azimuth and elevation. Angles are in degrees, with the azimuth measured clockwise from north and elevation up from the zero plane of the surface. `shade` is used to produce "shaded" RGB values for a data array. `shade_rgb` can be
| 3792 | |
| 3793 | |
| 3794 | class LightSource: |
| 3795 | """ |
| 3796 | Create a light source coming from the specified azimuth and elevation. |
| 3797 | Angles are in degrees, with the azimuth measured |
| 3798 | clockwise from north and elevation up from the zero plane of the surface. |
| 3799 | |
| 3800 | `shade` is used to produce "shaded" RGB values for a data array. |
| 3801 | `shade_rgb` can be used to combine an RGB image with an elevation map. |
| 3802 | `hillshade` produces an illumination map of a surface. |
| 3803 | """ |
| 3804 | |
| 3805 | def __init__(self, azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1, |
| 3806 | hsv_min_sat=1, hsv_max_sat=0): |
| 3807 | """ |
| 3808 | Specify the azimuth (measured clockwise from south) and altitude |
| 3809 | (measured up from the plane of the surface) of the light source |
| 3810 | in degrees. |
| 3811 | |
| 3812 | Parameters |
| 3813 | ---------- |
| 3814 | azdeg : float, default: 315 degrees (from the northwest) |
| 3815 | The azimuth (0-360, degrees clockwise from North) of the light |
| 3816 | source. |
| 3817 | altdeg : float, default: 45 degrees |
| 3818 | The altitude (0-90, degrees up from horizontal) of the light |
| 3819 | source. |
| 3820 | hsv_min_val : number, default: 0 |
| 3821 | The minimum value ("v" in "hsv") that the *intensity* map can shift the |
| 3822 | output image to. |
| 3823 | hsv_max_val : number, default: 1 |
| 3824 | The maximum value ("v" in "hsv") that the *intensity* map can shift the |
| 3825 | output image to. |
| 3826 | hsv_min_sat : number, default: 1 |
| 3827 | The minimum saturation value that the *intensity* map can shift the output |
| 3828 | image to. |
| 3829 | hsv_max_sat : number, default: 0 |
| 3830 | The maximum saturation value that the *intensity* map can shift the output |
| 3831 | image to. |
| 3832 | |
| 3833 | Notes |
| 3834 | ----- |
| 3835 | For backwards compatibility, the parameters *hsv_min_val*, |
| 3836 | *hsv_max_val*, *hsv_min_sat*, and *hsv_max_sat* may be supplied at |
| 3837 | initialization as well. However, these parameters will only be used if |
| 3838 | "blend_mode='hsv'" is passed into `shade` or `shade_rgb`. |
| 3839 | See the documentation for `blend_hsv` for more details. |
| 3840 | """ |
| 3841 | self.azdeg = azdeg |
| 3842 | self.altdeg = altdeg |
| 3843 | self.hsv_min_val = hsv_min_val |
| 3844 | self.hsv_max_val = hsv_max_val |
| 3845 | self.hsv_min_sat = hsv_min_sat |
| 3846 | self.hsv_max_sat = hsv_max_sat |
| 3847 | |
| 3848 | @property |
| 3849 | def direction(self): |
| 3850 | """The unit vector direction towards the light source.""" |
| 3851 | # Azimuth is in degrees clockwise from North. Convert to radians |
no outgoing calls
no test coverage detected
searching dependent graphs…