num_lights

PURPOSE ^

NUM_LIGHTS return the number of light objects in an axes

SYNOPSIS ^

function N = num_lights(ax)

DESCRIPTION ^

NUM_LIGHTS return the number of light objects in an axes

 NUM_LIGHTS() uses the current axes

 NUM_LIGHTS(AX) uses specified axes AX

 See also: LIGHT, CAMLIGHT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function N = num_lights(ax)
0002 %NUM_LIGHTS return the number of light objects in an axes
0003 %
0004 % NUM_LIGHTS() uses the current axes
0005 %
0006 % NUM_LIGHTS(AX) uses specified axes AX
0007 %
0008 % See also: LIGHT, CAMLIGHT
0009 
0010 
0011 
0012 % (C) 2024 Bartek Grychtol.
0013 % License: GPL version 2 or version 3
0014 % $Id: num_lights.m 7124 2024-12-29 15:18:32Z aadler $
0015 
0016 if nargin == 1 && ischar(ax) && strcmp(ax,'UNIT_TEST'), do_unit_test; return,end
0017 
0018 if nargin < 1
0019    ax = gca;
0020 end
0021 ch = get(ax, 'Children');
0022 
0023 
0024 ver= eidors_obj('interpreter_version');
0025 if ver.isoctave
0026    % children are scalar
0027    N = sum(strcmp(get(ch, 'type'), 'light'));
0028 else
0029    N = 0;
0030    for i = 1:numel(ch)
0031       N = N + isa(ch(i),'matlab.graphics.primitive.Light');
0032    end
0033 end
0034 
0035 function do_unit_test
0036   clf
0037   subplot(211)
0038   plot(rand(5));
0039   camlight('left')
0040   camlight('right')
0041   ax = gca;
0042   unit_test_cmp('current axis', num_lights, 2);
0043   subplot(212)
0044   unit_test_cmp('specific axis', num_lights(ax), 2);
0045

Generated on Sun 29-Dec-2024 11:41:59 by m2html © 2005