Now with syntax highlighting!
| Author |
Message |
|
johnlindquist
Papervision3D Team
Joined: Sat Mar 07, 2009 3:02 am Posts: 15
|
 Now with syntax highlighting!
Apply code highlighting with the following tags: Code: - [code=actionscript]//a bunch of code here[/code]
And you can get results such as these! Code: - package {
- import flash.events.Event;
- import flash.geom.Point;
-
- import org.casalib.math.geom.Ellipse;
- import org.papervision3d.materials.ColorMaterial;
- import org.papervision3d.objects.primitives.Plane;
- import org.papervision3d.view.BasicView;
-
- [SWF(width="900", height="480", backgroundColor="#ffffff", frameRate="60")]
- public class CarouselWithForwardPlanes extends BasicView
- {
- private static const NUM_PLANES:int = 10;
- private static const RADIUS:Number = 600;
- private var diameter:Number = RADIUS * 2;
- //defines the carousel (thanks to CASA)
- private var circle:Ellipse = new Ellipse(-RADIUS, -RADIUS, diameter, diameter);
- private var planes:Array = [];
-
- public function CarouselWithForwardPlanes()
- {
- for(var i:int = 0; i < NUM_PLANES; i++)
- {
- var color:Number = Math.random() * 0xffffff;
- var colorMaterial:ColorMaterial = new ColorMaterial(color);
- var plane:Plane = new Plane(colorMaterial, 150, 150);
- //get the x and y (or z) point based on the current index
- var point:Point = circle.getPointOfDegree(360 / NUM_PLANES * i);
-
- plane.x = point.x;
- plane.z = point.y;
- planes.push(plane);
-
- scene.addChild(plane);
- }
-
- startRendering();
- }
-
- override protected function onRenderTick(event:Event = null):void
- {
- var n:int = 0;
- for each(var plane:Plane in planes)
- {
- var degrees:Number = 360 / NUM_PLANES * n;
- var mouseDegrees:Number = viewport.containerSprite.mouseX / 2;
- var totalDegrees:Number = degrees + mouseDegrees;
-
- var point:Point = circle.getPointOfDegree(totalDegrees);
- plane.x = point.x;
- plane.z = point.y;
-
- n++;
- }
-
- super.onRenderTick(event);
- }
- }
- }
_________________ http://pv3d.org
|
| Mon Mar 09, 2009 3:41 am |
|
 |
|
Indyaner
Joined: Sun Mar 08, 2009 7:00 pm Posts: 5 Location: Düsseldorf/Germany
|
 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 |
|
 |
|
neoRiley
Papervision3D Team
Joined: Mon Mar 09, 2009 5:01 am Posts: 5
|
 Re: Now with syntax highlighting!
sweeeeeeet
|
| Mon Mar 09, 2009 5:03 am |
|
 |
|
John Brookes
Forum Administrator
Joined: Sat Mar 07, 2009 9:59 pm Posts: 1107
|
 Re: Now with syntax highlighting!
Slight problem when you preview before posting, ends up like this Code: - 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 |
|
 |
|
Tim Knip
Papervision3D Team
Joined: Sun Mar 08, 2009 7:39 pm Posts: 3
|
 Re: Now with syntax highlighting!
Same trouble here. Preview seems to eat newlines 
|
| Mon Mar 09, 2009 4:36 pm |
|
 |
|
xero
Forum Administrator
Joined: Mon Mar 09, 2009 4:10 pm Posts: 147 Location: 0x000000
|
 Re: Now with syntax highlighting!
i think code=actionscript needs to be a default for this forum.
_________________
|
| Mon Mar 09, 2009 5:16 pm |
|
 |
|
johnlindquist
Papervision3D Team
Joined: Sat Mar 07, 2009 3:02 am Posts: 15
|
 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 |
|
 |
|
Tyler Egeto
Forum Administrator
Joined: Sat Mar 07, 2009 10:11 pm Posts: 183
|
 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 |
|
 |
|
John Brookes
Forum Administrator
Joined: Sat Mar 07, 2009 9:59 pm Posts: 1107
|
 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.htmlseems to work.
|
| Sat Mar 14, 2009 7:55 pm |
|
 |
|
Tyler Egeto
Forum Administrator
Joined: Sat Mar 07, 2009 10:11 pm Posts: 183
|
 Re: Now with syntax highlighting!
That's awesome! Thanks for sharing that!
_________________ www.tyleregeto.com
|
| Sat Mar 14, 2009 9:42 pm |
|
 |
|