It is currently Thu Sep 02, 2010 2:32 pm




Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
 Now with syntax highlighting! 
Author Message
Papervision3D Team
User avatar

Joined: Sat Mar 07, 2009 3:02 am
Posts: 15
Post Now with syntax highlighting!
Apply code highlighting with the following tags:
Code:
  1.  [code=actionscript]//a bunch of code here[/code] 


And you can get results such as these!
Code:
  1.  package {
  2.     import flash.events.Event;
  3.     import flash.geom.Point;
  4.  
  5.     import org.casalib.math.geom.Ellipse;
  6.     import org.papervision3d.materials.ColorMaterial;
  7.     import org.papervision3d.objects.primitives.Plane;
  8.     import org.papervision3d.view.BasicView;
  9.  
  10.     [SWF(width="900", height="480", backgroundColor="#ffffff", frameRate="60")]
  11.     public class CarouselWithForwardPlanes extends BasicView
  12.     {
  13.         private static const NUM_PLANES:int = 10;
  14.         private static const RADIUS:Number = 600;
  15.         private var diameter:Number = RADIUS * 2;
  16.         //defines the carousel (thanks to CASA)
  17.         private var circle:Ellipse = new Ellipse(-RADIUS, -RADIUS, diameter, diameter);
  18.         private var planes:Array = [];
  19.  
  20.         public function CarouselWithForwardPlanes()
  21.         {
  22.             for(var i:int = 0; i < NUM_PLANES; i++)
  23.             {
  24.                 var color:Number = Math.random() * 0xffffff;
  25.                 var colorMaterial:ColorMaterial = new ColorMaterial(color);
  26.                 var plane:Plane = new Plane(colorMaterial, 150, 150);
  27.                 //get the x and y (or z) point based on the current index
  28.                 var point:Point = circle.getPointOfDegree(360 / NUM_PLANES * i);
  29.  
  30.                 plane.x = point.x;
  31.                 plane.z = point.y;
  32.                 planes.push(plane);
  33.  
  34.                 scene.addChild(plane);
  35.             }
  36.  
  37.             startRendering();
  38.         }
  39.  
  40.         override protected function onRenderTick(event:Event = null):void
  41.         {
  42.             var n:int = 0
  43.             for each(var plane:Plane in planes)
  44.             {
  45.                 var degrees:Number = 360 / NUM_PLANES * n;
  46.                 var mouseDegrees:Number = viewport.containerSprite.mouseX / 2;
  47.                 var totalDegrees:Number = degrees + mouseDegrees;
  48.  
  49.                 var point:Point = circle.getPointOfDegree(totalDegrees);
  50.                 plane.x = point.x;
  51.                 plane.z = point.y;
  52.  
  53.                 n++;
  54.             }          
  55.  
  56.             super.onRenderTick(event);         
  57.         }
  58.     }
  59. }

_________________
http://pv3d.org


Mon Mar 09, 2009 3:41 am
Profile WWW
User avatar

Joined: Sun Mar 08, 2009 7:00 pm
Posts: 5
Location: Düsseldorf/Germany
Post Re: Now with syntax highlighting!
Thank you very much. Helps alot lateron when long codes will be postet ;)


Mon Mar 09, 2009 4:42 am
Profile ICQ
Papervision3D Team

Joined: Mon Mar 09, 2009 5:01 am
Posts: 5
Post Re: Now with syntax highlighting!
sweeeeeeet


Mon Mar 09, 2009 5:03 am
Profile
Forum Administrator

Joined: Sat Mar 07, 2009 9:59 pm
Posts: 1107
Post Re: Now with syntax highlighting!
Slight problem when you preview before posting, ends up like this
Code:
  1.  package {    import flash.events.Event;    import org.papervision3d.core.effects.view.ReflectionView;     [SWF (width="640", height="480", backgroundColor="0xffffff", frameRate="30")]      public class ReflectionCubeSimple extends ReflectionView    {         private var cube : Cube;          public function ReflectionCubeSimple()        {             super(0,0,true, false);        }                public function enterFrame(e:Event) : void        {            // rotate the cube dependent on the mouse position            cube.yaw(1);             cube.y=(120-(mouseY/2));              if(cube.y< -50) cube.y = -50;              singleRender();          }     }} 


Mon Mar 09, 2009 4:33 pm
Profile
Papervision3D Team

Joined: Sun Mar 08, 2009 7:39 pm
Posts: 3
Post Re: Now with syntax highlighting!
Same trouble here. Preview seems to eat newlines :-)


Mon Mar 09, 2009 4:36 pm
Profile
Forum Administrator
User avatar

Joined: Mon Mar 09, 2009 4:10 pm
Posts: 147
Location: 0x000000
Post Re: Now with syntax highlighting!
i think code=actionscript
needs to be a default for this forum.

_________________
Image


Mon Mar 09, 2009 5:16 pm
Profile WWW
Papervision3D Team
User avatar

Joined: Sat Mar 07, 2009 3:02 am
Posts: 15
Post Re: Now with syntax highlighting!
I'll have to go back and look through the source code to see if I can find a fix for that preview newline issue. One "workaround" for right now:

Don't add the [ code ] tags until you're ready to post. You can preview without the code tags and the newlines will be kept.

_________________
http://pv3d.org


Mon Mar 09, 2009 5:52 pm
Profile WWW
Forum Administrator
User avatar

Joined: Sat Mar 07, 2009 10:11 pm
Posts: 183
Post Re: Now with syntax highlighting!
This is awesome, now to just get people using it!

_________________
www.tyleregeto.com


Mon Mar 09, 2009 9:35 pm
Profile WWW
Forum Administrator

Joined: Sat Mar 07, 2009 9:59 pm
Posts: 1107
Post Re: Now with syntax highlighting!
Another anooyance is getting line numbers when you copy someones posted code.
So I've made a little bookmarklet for firefox.
Removes the li tags and replaces with div tags.

http://www.shrewballooba.co.uk/pv/pitaLineNumbers.html

seems to work.


Sat Mar 14, 2009 7:55 pm
Profile
Forum Administrator
User avatar

Joined: Sat Mar 07, 2009 10:11 pm
Posts: 183
Post Re: Now with syntax highlighting!
That's awesome! Thanks for sharing that!

_________________
www.tyleregeto.com


Sat Mar 14, 2009 9:42 pm
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.