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

📄 drawpoly.as

📁 AS3的画图功能一些源码
💻 AS
字号:
/*-------------------------------------------------------------	mc.drawPoly is a method for creating regular	polygons. Negative values for sides will draw the	polygon in the reverse direction, which allows for	creating knock-outs in masks.-------------------------------------------------------------*/MovieClip.prototype.drawPoly = function(x, y, sides, radius, angle) {	// ==============	// mc.drawPoly() - by Ric Ewing (ric@formequalsfunction.com) - version 1.4 - 4.7.2002	// 	// x, y = center of polygon	// sides = number of sides (Math.abs(sides) must be > 2)	// radius = radius of the points of the polygon from the center	// angle = [optional] starting angle in degrees. (defaults to 0)	// ==============	if (arguments.length<4) {		return;	}	// convert sides to positive value	var count = Math.abs(sides);	// check that count is sufficient to build polygon	if (count>2) {		// init vars		var step, start, n, dx, dy;		// calculate span of sides		step = (Math.PI*2)/sides;		// calculate starting angle in radians		start = (angle/180)*Math.PI;		this.moveTo(x+(Math.cos(start)*radius), y-(Math.sin(start)*radius));		// draw the polygon		for (n=1; n<=count; n++) {			dx = x+Math.cos(start+(step*n))*radius;			dy = y-Math.sin(start+(step*n))*radius;			this.lineTo(dx, dy);		}	}};

⌨️ 快捷键说明

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