import buildModuleUrl from './buildModuleUrl.js';
import Color from './Color.js';
import defined from './defined.js';
import DeveloperError from './DeveloperError.js';
import Resource from './Resource.js';
import writeTextToCanvas from './writeTextToCanvas.js';
/**
* A utility class for generating custom map pins as canvas elements.
*
*
*

* Example pins generated using both the maki icon set, which ships with Cesium, and single character text.
*
*
* @alias PinBuilder
* @constructor
*
* @demo {@link https://sandcastle.cesium.com/index.html?src=Map%20Pins.html|Cesium Sandcastle PinBuilder Demo}
*/
function PinBuilder() {
this._cache = {};
}
/**
* Creates an empty pin of the specified color and size.
*
* @param {Color} color The color of the pin.
* @param {Number} size The size of the pin, in pixels.
* @returns {Canvas} The canvas element that represents the generated pin.
*/
PinBuilder.prototype.fromColor = function(color, size) {
//>>includeStart('debug', pragmas.debug);
if (!defined(color)) {
throw new DeveloperError('color is required');
}
if (!defined(size)) {
throw new DeveloperError('size is required');
}
//>>includeEnd('debug');
return createPin(undefined, undefined, color, size, this._cache);
};
/**
* Creates a pin with the specified icon, color, and size.
*
* @param {Resource|String} url The url of the image to be stamped onto the pin.
* @param {Color} color The color of the pin.
* @param {Number} size The size of the pin, in pixels.
* @returns {Canvas|Promise.