IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » corbanb's snipts » point The latest point snipts from corbanb.

showing 1-2 of 2 snipts for point
  • Flash quick distance, angle demo
    var a:Point = new Point(stage.stageWidth/2, stage.stageHeight/2);
    var lineDrawing:Shape = new Shape();
    addChild(lineDrawing);
    
    this.addEventListener(Event.ENTER_FRAME, loop);
    
    function loop(e:Event):void{
    	
    	lineDrawing.graphics.clear();
    	
    	var b:Point = new Point(mouseX, mouseY);
    	var distance = Point.distance(a, b);
    	
    	lineDrawing.graphics.lineStyle(1);
    	lineDrawing.graphics.moveTo(a.x,a.y); ///This is where we start drawing
    	lineDrawing.graphics.lineTo(b.x, b.y);
    	
    	
    	var angle:Number = Math.atan2(b.y - a.y, b.x - a.x) * 180 / Math.PI;
    	if(angle < 0) angle += 360;
    	
    }
    

    copy | embed

    1 comment - tagged in  posted by corbanb on Oct 14, 2009 at 4:59 p.m. EDT
  • simple circle conversion
    var hldr:MovieClip = new MovieClip();
    simpleCircle(150, stage.stageWidth/2, stage.stageHeight/2);
    
    
    function simpleCircle(r:Number, centerX:Number, centerY:Number):void{
    	
    	var totalPoints:Number = 100;
    	var rad_inc:Number = (Math.PI * 2) / totalPoints;
    	var this_rad_inc:Number = 0;
    	var deg:Number = 0;
    	var RADIUS:Number = r;
    	
    	for(var i=0; i<totalPoints; i++)
    	{
    		
    		//get next radian
    		this_rad_inc += rad_inc;
    		
    		//find x,y cords of the current point
    		var coord:Point = new Point();
    		coord = Point.polar(RADIUS, this_rad_inc);
    		
    		//convert radian to degrees
    		deg = this_rad_inc * 180 / Math.PI ;
    		
    		//draw square to represent each point.
    		var point:Shape = new Shape();
    		point.graphics.beginFill(0x000000);
    		point.graphics.drawRect(-2.5, -2.5, 5, 5);
    		point.graphics.endFill();
    		
    		//give point its properties.
    		point.x = coord.x;
    		point.y = coord.y;
    		point.rotation = deg;
    		
    		//add point to display list
    		hldr.addChild(point);
    	
    		
    	}
    	
    	//place circle on stage and enjoy.
    	hldr.x = centerX;
    	hldr.y = centerY;
    	addChild(hldr);
    }
    

    copy | embed

    0 comments - tagged in  posted by corbanb on Jun 16, 2009 at 3:32 p.m. EDT
Sign up to create your own snipts, or login.