Image layers
Fractalshades graphical export is based on the concept of layers. Each layer is linked to a postprocessing field, it can be directly plotted or can be used to modify another layer.
- class fractalshades.colors.layers.Virtual_layer(postname, func, output=True)[source]
- __init__(postname, func, output=True)[source]
Base class for all layer objects.
- Parameters:
- postnamestr
Unique identifier key for this layer. When added to a
fractalshades.Fractal_plotter
plotter (seefractalshades.Fractal_plotter.add_layer
) the layer can then be accessed through this key :layer = plotter[“postname”]
The
postname
must match afractalshades.postproc.Postproc
associated with this plotter.- funcNone | callable
mapping applied during the post-processing initial step
- outputbool
If True : an image will be saved when
fractalshades.Fractal_plotter.add_layer
directive issued.
- set_mask(layer, mask_color=None)[source]
Masks the base-layer
- Parameters:
- layer
Bool_layer
|Grey_layer
The layer mask
- mask_colorNone | 3-uplet or 4_uplet of floats belonging to [0., 1.]
If None, a default value will be provided depending on the masked array subclass If a n-uplet is provided, it shall be with RGB or RGBA values for a colored layer
- layer
- class fractalshades.colors.layers.Color_layer(postname, func, colormap, probes_z=[0, 1], output=True)[source]
- __init__(postname, func, colormap, probes_z=[0, 1], output=True)[source]
A colored layer.
- Parameters:
- postnamestr
passed to
Virtual_layer
constructor- func
passed to
Virtual_layer
constructor- colormapfractalshades.colors.Fractal_colormap
a colormap
- probes_z2-floats list
probes_z = (z_min, zmax) ; the z_min value of the field will be mapped to 0. and zmax to 1.
- outputbool
passed to
Virtual_layer
constructor
- overlay(layer, overlay_mode)[source]
Combine the output of current layer with an overlayed layer after color-mapping.
- Parameters:
- layer
Color_layer
|Grey_layer
The layer to overlay. See
Overlay_mode
documentation for the options and restrictions.- overlay_mode
Overlay_mode
Object describing the kind of overlay used.
- layer
- set_mask(layer, mask_color=None)
Masks the base-layer
- Parameters:
- layer
Bool_layer
|Grey_layer
The layer mask
- mask_colorNone | 3-uplet or 4_uplet of floats belonging to [0., 1.]
If None, a default value will be provided depending on the masked array subclass If a n-uplet is provided, it shall be with RGB or RGBA values for a colored layer
- layer
- set_twin_field(layer, scale)[source]
Combine two postprocessing fields in one layer.
Combine the current layer with another layer before color-mapping. (i.e. add directly the underlying float
fractalshades.postproc.Postproc
arrays), tuning the intensity of the effect with a scaling coefficient.- Parameters:
- layer
Virtual_Layer
instance The combined layer
- scalefloat
A scaling coefficient which will be applied to the twin layer field before adding it to the base field
- layer
Notes
Note
Note : The mask of the current layer will be applied.
- shade(layer, lighting)[source]
Adds scene lighting to the layer through a normal map effect.
- Parameters:
- layer
Normal_map_layer
The layer holding the normal vector field.
- lighting
Blinn_lighting
Object describing the scene lighting.
- layer
- class fractalshades.colors.layers.Normal_map_layer(postname, max_slope=70, output=True)[source]
- __init__(postname, max_slope=70, output=True)[source]
Defines a normal map layer
This layer can be either:
plotted directly (OpenGL normal map format) and used in a post-processing Workflow - e.g. Blender
or used to apply shading to a
Color_layer.shade
- Parameters:
- postnamestr
passed to
Virtual_layer
constructor- max_slopefloat
maximal angle (in degree) of the normal map, will be used for re-normalisation
- outputbool
passed to
Virtual_layer
constructor
- set_mask(layer, mask_color=None)
Masks the base-layer
- Parameters:
- layer
Bool_layer
|Grey_layer
The layer mask
- mask_colorNone | 3-uplet or 4_uplet of floats belonging to [0., 1.]
If None, a default value will be provided depending on the masked array subclass If a n-uplet is provided, it shall be with RGB or RGBA values for a colored layer
- layer
- class fractalshades.colors.layers.Grey_layer(postname, func, curve=None, probes_z=[0.0, 1.0], output=True)[source]
- __init__(postname, func, curve=None, probes_z=[0.0, 1.0], output=True)[source]
A grey layer.
- Parameters:
- postnamestr
passed to
Virtual_layer
constructor- func
passed to
Virtual_layer
constructor- curveNone | callable
A mapping from [0, 1] to [0, 1] applied after rescaling (this is the equivalent of a colormap in greyscale)
- probes_z2-floats list
The preprocessing affine rescaling. If [min, max] the minimum value of the field will be mapped to 0. and the maximum to 1.
- outputbool
passed to
Virtual_layer
constructor
- set_mask(layer, mask_color=None)[source]
Masks the base-layer
- Parameters:
- layerBool_layer | Grey_layer
The layer mask
- mask_colorNone | float belonging to [0., 1.]
If None, a default value will be provided depending on the masked array subclass If a value is provided, it shall be with : a float belonging to [0. (black) ; 1. (white)] interval
- class fractalshades.colors.layers.Disp_layer(postname, func, curve=None, probes_z=[0.0, 1.0], output=True)[source]
Grey layer with 16-bits precision.
Same functionnality as a
Grey_layer
but the image export is with 16-bits precision (useful when used as an height map for 3d processing like Blender)- __init__(postname, func, curve=None, probes_z=[0.0, 1.0], output=True)
A grey layer.
- Parameters:
- postnamestr
passed to
Virtual_layer
constructor- func
passed to
Virtual_layer
constructor- curveNone | callable
A mapping from [0, 1] to [0, 1] applied after rescaling (this is the equivalent of a colormap in greyscale)
- probes_z2-floats list
The preprocessing affine rescaling. If [min, max] the minimum value of the field will be mapped to 0. and the maximum to 1.
- outputbool
passed to
Virtual_layer
constructor
- set_mask(layer, mask_color=None)
Masks the base-layer
- Parameters:
- layerBool_layer | Grey_layer
The layer mask
- mask_colorNone | float belonging to [0., 1.]
If None, a default value will be provided depending on the masked array subclass If a value is provided, it shall be with : a float belonging to [0. (black) ; 1. (white)] interval
- class fractalshades.colors.layers.Blinn_lighting(k_ambient, color_ambient, **light_sources)[source]
- __init__(k_ambient, color_ambient, **light_sources)[source]
This class holds the properties for the scene lightsources. Its instances can be passed as a parameter to
Color_layer.shade
.- Parameters:
- k_Ambient
ambient lighting coefficient. A typical value is 0.2
- color_ambient: 3-uplet float
a RGB 3-tuple, channels values in [0, 1] : the ambient lighting color. Usually white (1., 1., 1.)
- add_light_source(k_diffuse, k_specular, shininess, polar_angle, azimuth_angle, color=array([1., 1., 1.]), material_specular_color=None)[source]
Adds a lightsource to the scene
- Parameters:
- k_diffuse: 3-uplet float
diffuse lighting coefficients, as RGB
- k_specular: 3-uplet float
diffuse lighting pourcentage, as RGB
- shininess: float
Phong exponent for specular model
- polar_angle: float
angle (theta) of light source direction, in degree theta = 0 if incoming light is in xOz plane
- azimuth_angle: float
angle (phi) of light source direction, in degree phi = 0 if incoming light is in xOy plane
- class fractalshades.colors.layers.Overlay_mode(mode, **mode_options)[source]
- __init__(mode, **mode_options)[source]
This class holds the properties for overlaying. Its instances can be passed as a parameter to
Color_layer.overlay
method.- Parameters:
- mode: “alpha_composite” | “tint_or_shade”
the kind of overlay applied
- alpha_composite :
alpha-compositing of 2 color layers (a Bool_layer may be provided as optionnal parameter, otherwise its is the mask of the upper layer which will be considered for compositing)
- tint_or_shade
the color of the lower layer will be adjusted (tinted of shaded) depending of the upper layer value (tinted above 0.5, shaded below 0.5). The upper layer in this case shall be a
Grey_layer
instance.
- Other Parameters:
- ref_white: 3-uplet float, Optionnal
- reference white light RGB coeff for
mode
“tint_or_shade” Default to CIE LAB constants Illuminant D65
- reference white light RGB coeff for
- alpha_mask: `Bool_layer`, Optionnal
Boolean array used for compositing, for alpha_composite mode Defaults to the mask of the upper layer
- inverse_mask: bool, Optionnal
if True, inverse the mask