In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

HueGradient 動くよ

クリックで向きが反転

pbkのソース
<languageVersion : 1.0;>

kernel HueGradient
<   namespace : "zahir1929";
vendor : "zahir";
version : 1;
description :"";
>
{
output pixel3 dst;

parameter float rotate<
maxValue: 360.0;
minValue: -360.0;
defaultValue: 0.0;
>;
parameter float2 center<
maxValue: float2(4000);
minValue: float2(0);
defaultValue: float2(128);
>;
parameter int Reflection<
maxValue: 1;
minValue: 0;
defaultValue: 1;
>; 
void
evaluatePixel(){
float2 d = center - outCoord();
float t = mod(atan(d.x, d.y) / 0.01745 + rotate, 360.0);
if(Reflection == 1) t *= -1.0;
if(t < 0.0) t += 360.0;
t /= 60.0;
float h = floor(t);
float v = ceil( 255.0 * (1.0 - ( 1.0 - t + h))) / 255.0;
float v2 = ceil( 255.0 * (1.0 - t + h)) / 255.0;
if( h  == 0.0 ){
dst = pixel3(1.0, v, 0.0);
}else if( h == 1.0){
dst = pixel3(v2, 1.0, 0.0);
}else if( h == 2.0){
dst = pixel3(0.0, 1.0, v);
}else if( h == 3.0){
dst = pixel3(0.0, v2, 1.0);
}else if( h == 4.0){
dst = pixel3(v, 0.0, 1.0);
}else if( h == 5.0){
dst = pixel3(1.0,
Get Adobe Flash player
by zahir 19 Jun 2009
/**
 * Copyright zahir ( http://wonderfl.net/user/zahir )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/c4No
 */

package{
	// クリックで向きが反転
/*
pbkのソース
<languageVersion : 1.0;>

kernel HueGradient
<   namespace : "zahir1929";
    vendor : "zahir";
    version : 1;
    description :"";
>
{
    output pixel3 dst;
    
    parameter float rotate<
        maxValue: 360.0;
        minValue: -360.0;
        defaultValue: 0.0;
    >;
    parameter float2 center<
        maxValue: float2(4000);
        minValue: float2(0);
        defaultValue: float2(128);
    >;
    parameter int Reflection<
        maxValue: 1;
        minValue: 0;
        defaultValue: 1;
    >; 
    void
    evaluatePixel(){
        float2 d = center - outCoord();
        float t = mod(atan(d.x, d.y) / 0.01745 + rotate, 360.0);
        if(Reflection == 1) t *= -1.0;
        if(t < 0.0) t += 360.0;
        t /= 60.0;
        float h = floor(t);
        float v = ceil( 255.0 * (1.0 - ( 1.0 - t + h))) / 255.0;
        float v2 = ceil( 255.0 * (1.0 - t + h)) / 255.0;
        if( h  == 0.0 ){
            dst = pixel3(1.0, v, 0.0);
        }else if( h == 1.0){
            dst = pixel3(v2, 1.0, 0.0);
        }else if( h == 2.0){
            dst = pixel3(0.0, 1.0, v);
        }else if( h == 3.0){
            dst = pixel3(0.0, v2, 1.0);
        }else if( h == 4.0){
            dst = pixel3(v, 0.0, 1.0);
        }else if( h == 5.0){
            dst = pixel3(1.0, 0.0, v2);
        }
    }
}
*/
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class ConeGradient extends Sprite{
		private var w:int, h:int;
		private var g:Graphics;
		private var s:HueGradient;
		private var ref:int = 1;
		private var mx:int, my:int;

		public function ConeGradient(){
			var rot:int = 0;
			g = this.graphics;
			s = new HueGradient();
			w = this.stage.stageWidth;
			h =this.stage.stageHeight;
			s.center = [w>>1, h>>1];
			
			this.stage.addEventListener(MouseEvent.CLICK,  function(e:MouseEvent):void{
				if(ref) s.Reflection = [ref = 0];
				else s.Reflection = [ref = 1];
			});
			this.addEventListener(Event.ENTER_FRAME , function(e:Event):void{
				s.center = [ mouseX, mouseY];
				s.rotate = [rot++];
				g.clear();
				g.beginShaderFill( s );
				g.drawRect( 0, 0, w, h );
				g.endFill();
			});
		}
	}
}
import flash.display.Shader;
import mx.utils.Base64Decoder;
class HueGradient extends Shader{
	public function HueGradient():void{
		var dec:Base64Decoder = new Base64Decoder();
		dec.decode( "pQEAAACkCwBIdWVHcmFkaWVudKAMbmFtZXNwYWNlAHphaGlyMTkyOQCgDHZlbmRvcgB6YWhpcgCgCHZlcnNpb24A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IDACA/gAAAKAIAIAMAgAAdAYAgAIAAADQAAAABgIAAHQQAgAIAwAAyAwAgP4AAAB0EAEADAIAAMgMAIAAAAAAdBAAgAwCAAB0BAOIEABgANQAAAAAAAAAyAwAgQAAAACgCACADAIAAHQGAEACAAAA0AAAAAYDAADIDACAAAAAAHQQAgAMAgAAyAwAgP4AAAB0EAEADAIAAHQQAIAEAwAAdAQDiBAAYADUAAAAAAAAAMgMAIEBAAAAoAgAgAwCAAB0CgIAAgAAANAAAAAKAAAAyAwAgAAAAAB0EAIADAIAAHQQAQAIAwAAyAwAgP4AAAB0EACADAIAAHQEA4gQAGAA1AAAAAAAAADIDACBAgAAAKAIAIAMAgAAdAoBAAIAAADQAAAACgEAAHQQAgAEAwAAyAwAgAAAAAB0EAEADAIAAMgMAID+AAAAdBAAgAwCAAB0BAOIEABgANQAAAAAAAAAyAwAgQKAAACgCACADAIAAHQKAIACAAAA0AAAAAoCAADIDACA/gAAAHQQAgAMAgAAyAwAgAAAAAB0EAEADAIAAHQQAIAIAwAAdAQDiBAAYADYAAAAAAAAANgAAAAAAAAA2AAAAAAAAADYAAAAAAAAANgAAAAAAAAA2AAAAAAAAAA==" );
		this.byteCode = dec.toByteArray();
		dec = null;
	}
	public function set center( value:Array ):void{
		this.data.center.value = value;
	}
	public function set Reflection( value:Array ):void{
		this.data.Reflection.value = value;
	}
	public function set rotate( value:Array ):void{
		this.data.rotate.value = value;
	}
}