⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drawstar.as

📁 AS3的画图功能一些源码
💻 AS
字号:
/*-------------------------------------------------------------	mc.drawStar is a method for drawing star shaped	polygons. Note that the stars by default 'point' to	the right. This is because the method starts drawing	at 0 degrees by default, putting the first point to	the right of center. Negative values for points	draws the star in reverse direction, allowing for	knock-outs when used as part of a mask.-------------------------------------------------------------*/MovieClip.prototype.drawStar = function(x, y, points, innerRadius, outerRadius, angle) {	// ==============	// mc.drawStar() - by Ric Ewing (ric@formequalsfunction.com) - version 1.4 - 4.7.2002	// 	// x, y = center of star	// points = number of points (Math.abs(points) must be > 2)	// innerRadius = radius of the indent of the points	// outerRadius = radius of the tips of the points	// angle = [optional] starting angle in degrees. (defaults to 0)	// ==============	if(arguments.length < 5) {		return;	}	var count = Math.abs(points);	if (count>2) {		// init vars		var step, halfStep, start, n, dx, dy;		// calculate distance between points		step = (Math.PI*2)/points;		halfStep = step/2;		// calculate starting angle in radians		start = (angle/180)*Math.PI;		this.moveTo(x+(Math.cos(start)*outerRadius), y-(Math.sin(start)*outerRadius));		// draw lines		for (n=1; n<=count; n++) {			dx = x+Math.cos(start+(step*n)-halfStep)*innerRadius;			dy = y-Math.sin(start+(step*n)-halfStep)*innerRadius;			this.lineTo(dx, dy);			dx = x+Math.cos(start+(step*n))*outerRadius;			dy = y-Math.sin(start+(step*n))*outerRadius;			this.lineTo(dx, dy);		}	}};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -