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

📄 index.html

📁 processing製作之互動鏈形圖像,圖像隨滑鼠移動
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
	        <!-- charset must remain utf-8 to be handled properly by Processing -->
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		
		<title>Tail_1 : Built with Processing</title>
		
		<style type="text/css">
		/* <![CDATA[ */
	
		body {
  		  margin: 60px 0px 0px 55px;
		  font-family: verdana, geneva, arial, helvetica, sans-serif; 
		  font-size: 11px; 
		  background-color: #ddddcc; 
		  text-decoration: none; 
		  font-weight: normal; 
		  line-height: normal; 
		}
		 
		a          { color: #3399cc; }
		a:link     { color: #3399cc; text-decoration: underline; }
		a:visited  { color: #3399cc; text-decoration: underline; }
		a:active   { color: #3399cc; text-decoration: underline; }
		a:hover    { color: #3399cc; text-decoration: underline; }
	
		/* ]]> */
		</style>
	 
	</head>
	<body>
		<div id="content">
			<div id="Tail_1_container">
			
			<!--[if !IE]> -->
				<object classid="java:Tail_1.class" 
            			type="application/x-java-applet"
            			archive="Tail_1.jar"
            			width="700" height="400"
            			standby="Loading Processing software..." >
            			
					<param name="archive" value="Tail_1.jar" />
				
					<param name="mayscript" value="true" />
					<param name="scriptable" value="true" />
				
					<param name="image" value="loading.gif" />
					<param name="boxmessage" value="Loading Processing software..." />
					<param name="boxbgcolor" value="#FFFFFF" />
				
					<param name="test_string" value="outer" />
			<!--<![endif]-->
				
				<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
						codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab"
						width="700" height="400"
						standby="Loading Processing software..."  >
						
					<param name="code" value="Tail_1" />
					<param name="archive" value="Tail_1.jar" />
					
					<param name="mayscript" value="true" />
					<param name="scriptable" value="true" />
					
					<param name="image" value="loading.gif" />
					<param name="boxmessage" value="Loading Processing software..." />
					<param name="boxbgcolor" value="#FFFFFF" />
					
					<param name="test_string" value="inner" />
					
					<p>
						<strong>
							This browser does not have a Java Plug-in.
							<br />
							<a href="http://java.sun.com/products/plugin/downloads/index.html" title="Download Java Plug-in">
								Get the latest Java Plug-in here.
							</a>
						</strong>
					</p>
				
				</object>
				
			<!--[if !IE]> -->
				</object>
			<!--<![endif]-->
			
			</div>
			
			<p>
			Tail 1: demonstration of how to make things follow each otherusing OO programming. You can add almost anything to this queue if you write it right.@author Myer Nore@version 20081204 void display();}// SECTION 2: CLASSES ////////////////////////////////////////abstract class Thing implements Locatable{float x, y;float getX() { return x;       }float getY() { return y;       }/** this displays the thing at its coordinates.notice how the appearance is totally separate from the display.  this enables us to make any appearancethat we want, even an appearance that consists of many in different places in relationship to its actual location.notice how the appearance is totally separate from the display.  this enables us to make any appearancethat we want, even an appearance that consists of many in different places in relationship to its actual location.abstract void appearance();}class Queue extends Thing implements Controllable{float segmentLength;ArrayList followers;Queue( Thing leader ){segmentLength = 15;followers = new ArrayList();// as wacky as it sounds, this object// is going to be the first object in the collectionfollowers.add( leader );}void addFollower( Controllable follower ){followers.add( follower );}void appearance(){Controllable leader;Controllable follower;for( int i = 0; i < followers.size()-1; i++ ){leader = (Controllable) followers.get( i );follower = (Controllable) followers.get( i+1 );control( leader, follower );}for( int i = followers.size()-1; i > 0; i-- ){leader = (Controllable) followers.get( i );leader.display();}}/**This is the juicy part where the position of each followeris determined by the one directly in front.This is the juicy part where the position of each followeris determined by the one directly in front.void setX( float x ){ Controllable leader = (Controllable) followers.get( 0 );leader.setX( x );    }void setY( float y ){    Controllable leader = (Controllable) followers.get( 0 );leader.setY( y );      }}class Ball extends Thing implements Controllable{float xSpeed, ySpeed;Ball(){x = random(width);y = random(height);xSpeed = random(3)-1.5;ySpeed = random(3)-1.5;}void appearance(){fill( #2827B7, 127 );stroke( #16156A, 127 );ellipse( 0, 0, 20, 20 );}void setX( float x ){ this.x = x;             }void setY( float y ){ this.y = y ;            }}// SECTION 3: PROCESSING CODE //////////////////////////////Ball leader;Queue queue;int numberOfFollowers;void setup(){size( 700, 400 );smooth();leader = new Ball();queue = new Queue( leader );numberOfFollowers = 50;for( int i = 0; i < numberOfFollowers; i++ ){queue.addFollower( new Ball() );}}void draw(){background( 255 );queue.setX( mouseX ); // this sets the position of the leaderqueue.setY( mouseY ); // you could also say leader.setX( mouseX )queue.display();}
			</p>
			
			<p>
			Source code: <a href="Tail_1.pde">Tail_1</a> 
			</p>
			
			<p>
			Built with <a href="http://processing.org" title="Processing.org">Processing</a>
			</p>
		</div>
	</body>
</html>

⌨️ 快捷键说明

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