MATLAB Function Reference | Search  Help Desk |
light | Examples |
light('PropertyName',PropertyValue,...) handle = light(...)
light
creates a Light object in the current Axes. Lights affect only Patch and Surface object.
light('PropertyName',PropertyValue,...)
creates a Light object using the specified values for the named properties. MATLAB parents the Light to the current Axes unless you specify another Axes with the Parent
property.
You cannot see a Light object per se, but you can see the effects of the light source on Patch and Surface objects. You can also specify an Axes-wide ambient light color that illuminates these objects. However, ambient light is visible only when at least one Light object is present and visible in the Axes.
You can specify properties as property name/property value pairs, structure arrays, and cell arrays (see set
and get
for examples of how to specify these data types).
See also the Patch and Surface AmbientStrength
, DiffuseStrength
, SpecularStrength
, SpecularExponent
, SpecularColorReflectance
, and VertexNormals
properties. Also see the lighting
and material
commands.
Light the peaks
surface plot with a light source located at infinity and oriented along the direction defined by the vector [1 0 0]
, that is, along the x-axis.
h = surf(peaks); set(h,'FaceLighting','phong','FaceColor','interp',... 'AmbientStrength',0.5) light('Position',[1 0 0],'Style','infinite');You can set default Light properties on the Axes, Figure, and Root levels:
set(0,'DefaultLightProperty',PropertyValue...) set(gcf,'DefaultLightProperty',PropertyValue...) set(gca,'DefaultLightProperty',PropertyValue...)Where Property is the name of the Light property and
PropertyValue
is the value you are specifying. Use set
and get
to access Light properties.
The following table lists all Light properties and provides a brief description of each. The property name links take you to an expanded description of the properties.Property Name |
Property Description |
Property Value |
Defining the Light | ||
Color |
Color of the light produced by the Light object |
Values: ColorSpec |
Position |
Location of Light in the axes |
Values: x-, y-, z-coordinates in Axes units Default: [1 0 1] |
Style |
Parallel or divergent light source |
Values: infinite , local |
Controlling the Appearance | ||
SelectionHighlight |
This property is not used by Light objects |
Values: on , off Default: on |
Visible |
Make the effects of the Light visible or invisible |
Values: on , off Default: on |
Controlling Access to Objects | ||
HandleVisibility |
Determines if and when the the Line's handle is visible to other functions |
Values: on , callback , off Default: on |
HitTest |
Light objects do use this property |
Values: on , off Default: on |
General Information About the Light | ||
Children |
Light objects have no children |
Values: [] (empty matrix) |
Parent |
The parent of a Light object is always an Axes object |
Value: Axes handle |
Selected |
Light objects do use this property |
Values: on , off Default: on |
Tag |
User-specified label |
Value: any string Default: '' (empty string) |
Type |
The type of graphics object (read only) |
Value: the string 'light' |
|
User-specified data |
Values: any matrix Default: [] (empty matrix) |
Properties Related to Callback Routine Execution | ||
|
Specify how to handle callback routine interruption |
Values: cancel , queue Default: queue |
|
This property is not used by Light objects |
Values: string Default: empty string |
|
Define a callback routine that executes when a Light is created |
Values: string (command or M-file name) Default: empty string |
|
Define a callback routine that executes when the Light is deleted (via close or delete ) |
Values: string (command or M-file name) Default: empty string |
|
Determine if callback routine can be interrupted |
Values: on , off Default: on (can be interrupted) |
|
This property is not used by Light objects |
Values: handle of a Uicontrextmenu |