layer implementation.
974554
function (map) {
            this._parts = [];
            var startAngle = 0;
            var stopAngle = 0;

            this.addTo(map);

            for (var i = 0; i < this.count(); i++) {
                var normalized = this._normalize(this._data[i].num);

                stopAngle = normalized * 360 + startAngle;

                // set start/stop Angle and color for semicircle
                var options = L.extend({
                    startAngle: startAngle,
                    stopAngle: stopAngle,

                    radius: this.options.radius,
                    fillColor: this._color(i),
                    color: this._color(i)
                }, this.options.sliceOptions);

                this._data[i].slice = L.semiCircle(
                    this._latlng,
                    L.Util.extend({}, options, this.options.pathOptions)
                ).addTo(this);

                if (this.options.labels) {
                    this._createLabel(normalized, this._data[i].label, this._data[i].slice);
                }
                startAngle = stopAngle;
            }
            return this;
        }
1141039
function(layers, options) {
        OpenLayers.Control.prototype.initialize.apply(this, [options]);
        
        if(this.scope === null) {
            this.scope = this;
        }
        this.initLayer(layers);
        var callbacks = {
            click: this.clickFeature,
            clickout: this.clickoutFeature
        };
        if (this.hover) {
            callbacks.over = this.overFeature;
            callbacks.out = this.outFeature;
        }
             
        this.callbacks = OpenLayers.Util.extend(callbacks, this.callbacks);
        this.handlers = {
            feature: new OpenLayers.Handler.Feature(
                this, this.layer, this.callbacks,
                {geometryTypes: this.geometryTypes}
            )
        };

        if (this.box) {
            this.handlers.box = new OpenLayers.Handler.Box(
                this, {done: this.selectBox},
                {boxDivClassName: "olHandlerBoxSelectFeature"}
            ); 
        }
    }
626066
function createLayer(layerOrSource) {
  // @type {import("../layer/Layer.js").default}
  let layer;
  if (layerOrSource instanceof Source) {
    if (layerOrSource instanceof TileSource) {
      layer = new TileLayer({source: layerOrSource});
    } else if (layerOrSource instanceof ImageSource) {
      layer = new ImageLayer({source: layerOrSource});
    }
  } else {
    layer = layerOrSource;
  }
  return layer;
}
1097523
def multi_output_layer(op):
    ''''''

    def layer_decorated(self, *args, **kwargs):
        # Automatically set a name if not provided.
        name = kwargs.setdefault('name', self.get_unique_name(op.__name__))
        output_names = kwargs.setdefault('output_names', self.get_unique_name(op.__name__))
        # Figure out the layer inputs.
        if len(self.terminals) == 0:
            raise RuntimeError('No input variables found for layer %s.' % name)
        elif len(self.terminals) == 1:
            layer_input = self.terminals[0]
        else:
            layer_input = list(self.terminals)
        # Perform the operation and get the output.
        layer_output = op(self, layer_input, *args, **kwargs)
        # Add to layer LUT.
        for i in range(len(output_names)):
            self.layers[output_names[i]] = layer_output[i]
        # This output is now the input for the next layer.
        self.feed(layer_output)
        # Return self for chained calls.
        return self

    return layer_decorated
640527
def duplicateActiveLayer(self):
		
		activeLayer = self.layers[self.activeLayer]
		newLayer = Layer(data=activeLayer.data, effect=activeLayer.effect)
		self.layers.append(newLayer)
		self.activeLayer = len(self.layers)-1
1165908
function() {

        // set the newly selected base layer
        for(var i=0, len=this.baseLayers.length; i<len; i++) {
            var layerEntry = this.baseLayers[i];
            if (layerEntry.inputElem.checked) {
                this.map.setBaseLayer(layerEntry.layer, false);
            }
        }

        // set the correct visibilities for the overlays
        for(var i=0, len=this.dataLayers.length; i<len; i++) {
            var layerEntry = this.dataLayers[i];
            layerEntry.layer.setVisibility(layerEntry.inputElem.checked);
        }

    }
1209707
def make_output_layers(self):
        
        # TODO
        # use successors == 0 as the criteria for output layer
        # will fail when some intermediate layers also generate output.
        # However, because the possibility of having inserted layers,
        # it's more difficult to tell which layer is the output layer.
        # Once possible way is to keep track of newly added layers...
        self.output_layers = []
        for layer in self.layer_list:
            if len(self.get_successors(layer)) == 0:
                self.output_layers.append(layer)
1003814
def layer_with(self, sample: np.ndarray, value: int) -> np.ndarray:
        """"""
        b = np.full((2, len(sample)), value, dtype=float)
        b[0] = sample
        return b
733850
function (layer) {
		var $canvas, handle, h;
		if (layer._handles) {
			$canvas = $(this);
			// Remove handles from layer
			for (h = 0; h < layer._handles.length; h += 1) {
				handle = layer._handles[h];
				$canvas.removeLayer(handle);
			}
			layer._handles.length = 0;
		}
	}
678280
function layerMethod(k, fun) {
    var pos = k.match(position)[0],
        key = k.replace(position, ''),
        prop = this[key];

    if (pos === 'after') {
        this[key] = function () {
            var ret = prop.apply(this, arguments);
            var args = [].slice.call(arguments);
            args.splice(0, 0, ret);
            fun.apply(this, args);
            return ret;
        };
    } else if (pos === 'before') {
        this[key] = function () {
            fun.apply(this, arguments);
            var ret = prop.apply(this, arguments);
            return ret;
        };
    }
}
327976
function (layers) {
		var layersArray = this._toArray(layers),
		    separated = this._checkInGetSeparated(layersArray),
		    groups = separated.groups,
		    i, group, id;

		// Batch add all single layers.
		this._originalAddLayers(separated.singles);

		// Add Layer Groups to the map so that they are registered there and
		// the map fires 'layeradd' events for them as well.
		for (i = 0; i < groups.length; i++) {
			group = groups[i];
			id = L.stamp(group);
			this._proxyLayerGroups[id] = group;
			delete this._proxyLayerGroupsNeedRemoving[id];
			if (this._map) {
				this._map._originalAddLayer(group);
			}
		}
	}
409369
def compose_layer(layer, force=False, **kwargs):
    """"""
    from PIL import Image, ImageChops
    assert layer.bbox != (0, 0, 0, 0), 'Layer bbox is (0, 0, 0, 0)'

    image = layer.topil(**kwargs)
    if image is None or force:
        texture = create_fill(layer)
        if texture is not None:
            image = texture

    if image is None:
        return image

    # TODO: Group should have the following too.

    # Apply mask.
    if layer.has_mask() and not layer.mask.disabled:
        mask_bbox = layer.mask.bbox
        if (
            (mask_bbox[2] - mask_bbox[0]) > 0 and
            (mask_bbox[3] - mask_bbox[1]) > 0
        ):
            color = layer.mask.background_color
            offset = (mask_bbox[0] - layer.left, mask_bbox[1] - layer.top)
            mask = Image.new('L', image.size, color=color)
            mask.paste(layer.mask.topil(), offset)
            if image.mode.endswith('A'):
                # What should we do here? There are two alpha channels.
                pass
            image.putalpha(mask)
    elif layer.has_vector_mask() and (force or not layer.has_pixels()):
        mask = draw_vector_mask(layer)
        # TODO: Stroke drawing.
        texture = image
        image = Image.new(image.mode, image.size, 'white')
        image.paste(texture, mask=mask)

    # Apply layer fill effects.
    apply_effect(layer, image)

    # Clip layers.
    if layer.has_clip_layers():
        clip_box = extract_bbox(layer.clip_layers)
        inter_box = intersect(layer.bbox, clip_box)
        if inter_box != (0, 0, 0, 0):
            clip_image = compose(layer.clip_layers, bbox=layer.bbox)
            mask = image.getchannel('A')
            if clip_image.mode.endswith('A'):
                mask = ImageChops.multiply(clip_image.getchannel('A'), mask)
            clip_image.putalpha(mask)
            image = _blend(image, clip_image, (0, 0))

    # Apply opacity.
    if layer.opacity < 255:
        opacity = layer.opacity
        if image.mode.endswith('A'):
            opacity = opacity / 255.
            channels = list(image.split())
            channels[-1] = channels[-1].point(lambda x: int(x * opacity))
            image = Image.merge(image.mode, channels)
        else:
            image.putalpha(opacity)

    return image
1067372
def setLayer(self, layer):
        
        if layer == self._layer:
            return False

        self._layer = layer
        self.syncLayerData()

        return True
775300
def add(self, layer, verbosity = 0, position = None):
        
        layer._verbosity = verbosity
        layer._maxRandom = self._maxRandom
        layer.minTarget = 0.0
        layer.maxTarget = 1.0
        layer.minActivation = 0.0
        layer.maxActivation = 1.0
        if position == None:
            self.layers.append(layer)
        else:
            self.layers.insert(position, layer)
        self.layersByName[layer.name] = layer
1238630
def add_layers(self, *layers):
		
		for layer in layers:
			if layer.name() in self.__layers.keys():
				raise ValueError('Layer "%s" already exists' % layer.name())
			self.__layers[layer.name()] = layer
1314770
function() {
        var layer;
        for(var i=0; i<this.layers.length; ++i) {
            layer = this.layers[i];
            if(this.renderer && layer.renderer.getRenderLayerId() == this.id) {
                this.renderer.moveRoot(layer.renderer);
            }
        }
    }
994330
function() {
            var layers = this.children,
                len = layers.length,
                n;

            for(n = 0; n < len; n++) {
                layers[n].clear();
            }
            return this;
        }