// o---------------------------------------------------------------------------------o // | This file is part of the RGraph package - you can learn more at: | // | | // | https://www.rgraph.net/license.html | // | | // | RGraph is dual-licensed under the Open Source GPL license. That means that it's | // | free to use and there are no restrictions on what you can use RGraph for! | // | If the GPL license does not suit you however, then there's an inexpensive | // | commercial license option available. See the URL above for more details. | // o---------------------------------------------------------------------------------o // // Initialise the various objects // RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true}; // // The constructor // RGraph.starburst = RGraph.Starburst = RGraph.StarBurst = function (conf) { var id = conf.id, canvas = document.getElementById(id); // Get the canvas and context objects this.id = id; this.canvas = canvas; this.context = this.canvas.getContext('2d'); this.type = 'starburst'; this.imageCache = []; this.frame = 1; this.rotatedAngle = (0 - (Math.PI / 2)); this.isRGraph = true; this.isrgraph = true; this.rgraph = true; this.properties = { colors: ['white','#666'], radius: 500, delay: null, segments: 12, centerx: null, centery: null, callback: null, animationStep: 0.0005, radiusMultiplier: 0, radiusIncrement: 0.01, image: null, imageHalign: 'center', imageValign: 'center', imageScale: 1, imageX: null, imageY: null, imageW: null, imageH: null, imageShadow: false, imageShadowOffsetx: 3, imageShadowOffsety: 3, imageShadowColor: '#666', imageShadowBlur: 3, }; var prop = this.properties; var properties = this.properties; // // A setter // // @param name string The name of the property to set // @param value mixed The value of the property // this.set = function (name) { var value = typeof arguments[1] === 'undefined' ? null : arguments[1]; // the number of arguments is only one and it's an // object - parse it for configuration data and return. if (arguments.length === 1 && typeof arguments[0] === 'object') { for (i in arguments[0]) { if (typeof i === 'string') { this.set(i, arguments[0][i]); } } return this; } properties[name] = value; return this; }; // Returns the requested property this.get = function (name) { return properties[name]; } // // The main draw function that gets everything going // this.draw = function () { // Determine the starting angle var start = (0 - (Math.PI / 2)) + ((properties.frame / (180 / Math.PI) / 10)); if (this.isNull(properties.centerx)) properties.centerx = canvas.width / 2; if (this.isNull(properties.centery)) properties.centery = canvas.height / 2; // Start by clearing the canvas this.context.clearRect(-5,-5, this.canvas.width + 10, this.canvas.height + 10); var grad = this.context.createRadialGradient(properties.centerx, properties.centery, 0, properties.centerx, properties.centery, properties.radius); grad.addColorStop(0,properties.colors[0]); for (var i=1,len=properties.colors.length; i