Nicolas Cannasse Blog http://ncannasse.fr/ Blog haXe Wiki System en Thunderbird Trash Folder http://ncannasse.fr/blog/thunderbird_trash_folder http://ncannasse.fr/blog/thunderbird_trash_folder Sat, 12 May 2012 01:06:26 +0200 Sat, 12 May 2012 01:06:26 +0200 Nicolas Cannasse Nicolas Cannasse <p>Just for the record, I'm posting this here. It might help other people as well, or myself if I forge...</p> <p>Just for the record, I'm posting this here. It might help other people as well, or myself if I forget exactly how I did it the first time.</p> <p>I'm using Thunderbird with IMAP quite often. It works quite nicely. However specifying an alternative Trash folder doesn't always work as expected.</p> <p>For instance on your GMail account Thunderbird will correctly detect that your trash is in <code>[Gmail]/Trash</code>, but messages put in that Trash are automatically deleted after 30 days. I prefer in general to keep all my old mails in an <code>Archives</code> folder.</p> <p>Thunderbird has a nice option that ask you in which folder you want deleted items to placed, but that's not exactly what it does. Actually this give it another &quot;Default Trash&quot; folder name, as shown in the <code>prefs.js</code> (it is stored in a <code>trash_folder_name</code> key).</p> <p>And this other trash folder will conflict with Gmail one, leading in most of the cases your mails being put in the Gmail Trash instead of your custom one.</p> <p>One simple fix I found is to Unsubscribe to the Gmail Trash folder. This way you have one single active Trash (your custom one / Archives), et voilĂ .</p> WWX Conference Review http://ncannasse.fr/blog/wwx_review http://ncannasse.fr/blog/wwx_review Tue, 17 Apr 2012 22:07:47 +0200 Tue, 17 Apr 2012 22:07:47 +0200 Nicolas Cannasse Nicolas Cannasse <p>Had a lot of fun at the <a href="http://wwx.haxe.org" class="extern">WWX</a> conference this weekend !</p> <p>We had many great speakers, covering many diff...</p> <p>Had a lot of fun at the <a href="http://wwx.haxe.org" class="extern">WWX</a> conference this weekend !</p> <p>We had many great speakers, covering many different topics. The Haxe ability to target many different platforms is a real freedom that enable a high level of innovation.</p> <p>For those who were not there, here's a quick resume until the recordings are made available :</p> <h1>Day 1</h1> <div class="biglist"> <ul><li>I made a keynote about the year that we went past, announced Haxe 2.09 release and detailed its changes, then presented plans about Haxe 3.0 that we will start working now and finally talked about medium and long terms plans for Haxe, such as creating a non-profit foundation. Here's <a href="/file/wwx2012.pdf" class="file file_pdf">my slides</a> if you want to check them.</li></ul> <ul><li>Franco Ponticelli presented the work he's making at <a href="http://www.reportgrid.com" class="extern">ReportGrid</a> with very nice SVG graphics, entirely done in Haxe</li></ul> <ul><li>The <a href="http://silexlabs.org" class="extern">Silex Labs</a> team, which did also a great job at organizing the conference, presented the promising Cocktail library : a full HTML+CSS engine written in pure Haxe, which can run into Flash and NME</li></ul> <ul><li>Hugh Sanderson (<a href="http://gamehaxe.com" class="extern">GameHaxe</a>) presented the general principles and nifty details of the Haxe/C++ backend, which is the base for NME and other great usages of Haxe. Technical devs loved it, designers went for a coffee break</li></ul> <ul><li>Robert Fell presented the <a href="http://code.google.com/p/awe6/" class="extern">awe6</a> inverted game framework, which is used to made several Lego Star Wars games in Haxe. The force was definitely with him.</li></ul> <ul><li>Dominic de Lozenzo and David Peek from <a href="http://massiveinteractive.com/" class="extern">Massive</a> (which have a 15+ Haxe developers team) presented an excellent review of Selling Haxe to clients and upper-management. Some great advice that we will use to improve communication around Haxe</li></ul> <ul><li>We then got many great Lightning Talks (8 minutes per speaker), which were showing great tools and promising techs, perfect brainstorming before...</li></ul> <ul><li><b>The Party</b> in a nice bistrot in the very center of Paris that was entirely reserved for us, we got the full night to eat, drink and talk about Haxe of course. Everybody will remember the <em>Palinka</em> that our friends from Prezi bring from Hungary : that was delicious and many of us (including me) got to drink more than they were expecting in the first place :)</li></ul> </div> <h1>Day 2</h1> <div class="biglist"> <ul><li><a href="http://robertbak.com" class="extern">Robert Bak</a> did a great demonstration explaining how to explain/teach Haxe to developers. Really insightful talk, perfect complementary with Dominic and David one. Great thoughts for the incoming year.</li></ul> <ul><li>Caue Waneck announced the release of the awaited Haxe/Java and Haxe/C# targets, which are now part of the Haxe nightly builds. Being a perfectionist, he explained a lot the things that could be improved, whereas the results are already wonderful !</li></ul> <ul><li><a href="http://philippe.elsass.me/" class="extern">Philippe Elsass</a> (aka 'The FlashDevelop guy') presented the <a href="http://haxenme.com" class="extern">NME</a> framework, explaining how you can make games for Mobile, Flash and HTML5, using a single code base.</li></ul> <ul><li>Peter Halacsy from <a href="http://prezi.com" class="extern">Prezi.com</a> explained how and why the decided to switch their whole product to Haxe, how they were successful so far and how they want to contribute back to the community. He didn't tell us how many liters of <em>Palinka</em> its developers consume per month</li></ul> <ul><li>Juraj Kircheim (aka <a href="http://back2dos.de/" class="extern">Back2Dos</a>) was smiling and seemed very happy to introduce fellow developers the principles and examples of Haxe <a href="http://haxe.org/manual/macros" class="extern">Macros</a>. Seems like it made the life of a few of them much more easy (and hopefully happy) now that they got it.</li></ul> <ul><li>And - last but not least - it was a real pleasure to learn about Nico Zimmerman artistic work at <a href="http://britzpetermann.com/" class="extern">Britzpetermann</a>, and how they use Haxe for many different things such as wining an award from Mozilla with a WebGL demo or making interactive window installation combining different technologies together. A wonderful inspiration moment that we enjoyed together.</li></ul> </div> <p>And after a few questions and community talks it was already time to finish and come back home.</p> <p>A very huge thanks to SilexLabs for organizing the whole event, and to all the speakers and attendees for being there.</p> <p>I'm already looking forward for next year edition, actually would be great to have the same kind of events in the US as well, if anybody want to take care of the organization.</p> Adobe Announce Speed Tax ! http://ncannasse.fr/blog/adobe_announce_speed_tax http://ncannasse.fr/blog/adobe_announce_speed_tax Wed, 28 Mar 2012 16:23:31 +0200 Wed, 28 Mar 2012 16:23:31 +0200 Nicolas Cannasse Nicolas Cannasse <p>Today Adobe announced its plans for so-called &quot;Premium Features&quot;, check it out <a href="http://www.adobe.com/devnet/flashplayer/articles/premium-features.html" class="extern">here</a></p> <p>Basica...</p> <p>Today Adobe announced its plans for so-called &quot;Premium Features&quot;, check it out <a href="http://www.adobe.com/devnet/flashplayer/articles/premium-features.html" class="extern">here</a></p> <p>Basically, what it means is that you'll have to get a license from Adobe and pay them <b>9% of your net revenues</b> if you want to use the &quot;premium features&quot; together with Stage3D API which allow hardware-accelerated 3D in the browser.</p> <p>Sadly, instead of providing real actual &quot;premium features&quot; that could have appealed to AAA games developers and let independent developers continue making their games and other apps without paying Adobe Tax, the so-called &quot;premium features&quot; consists in one simple thing : Alchemy opcodes.</p> <p>For those who don't know about it, there are two actual usages for Alchemy :</p> <ul><li>the Alchemy toolkit allows to convert C++ code to AVM2 Flash bytecode, and introduces additional opcodes for fast Memory access</li><li>these opcodes can be reused by some tools, such as Haxe <a href="http://haxe.org/api/flash/Memory" class="extern">flash.Memory</a> or Joa's <a href="https://github.com/joa/apparat" class="extern">Apparat</a> for AS3</li></ul> <p>Why Alchemy is so much important ? Because the AVM2 - the virtual machine that powers the flash player - is <b> AWFULLY SLOW</b> when it comes to memory manipulation.</p> <p>As soon as you want to manipulate memory, whatever you choose : Array, Vector or even ByteArray (sic) are painfully slow compared to JavaScript or other competing technologies.</p> <p>So far the Alchemy opcodes have been used as a replacement to cope with bad memory performances of AVM2, in order to speedup various tasks such as PNG encoding, Raytracing, Cryptography, Away3D Physics engine and many other tasks that just manipulate memory.</p> <p>Another example of Alchemy usage is the latest technical demo of a game I've been working on : <a href="http://galaxy55.com" class="extern">Galaxy55</a> is a Minecraft-like engine that absolutely needs Alchemy to build the world triangles and calculate lightning occlusion. Doing it without Alchemy would just make the game impossible since it would require more than one second to rebuild a part of the geometry when a block is changed, which occurs quite often.</p> <p>A last example is Unity3D which is using Alchemy opcodes to target Flash Player.</p> <p>So this is it : Adobe just made <b>DECENT SPEED</b> a &quot;premium feature&quot;.</p> <p>And since you really need that speed for doing (serious) Flash 3D games, it means that you will have to pay <b>Adobe Speed Tax</b> when you want to make a 3D game.</p> <p>More important, it means that there is no hope that they will improve the slowness of the Flash Player memory, since it would then allow developers such as me or tools such as Unity3D to run 3D content without the need to get a premium license !</p> <p>Oh, and what about the openness of the SWF format ? Sure : it's still open, you can build your own SWF without Adobe tools. But if you use X and Y feature, then you'll have to pay Adobe for it. Not a fixed amount of money, but a 9% tax on your revenues to get your content to run at a decent speed !</p> <p>Honestly, Adobe just killed the idea of making 3D flash games, especially for independent game developers that don't make that much money that they can afford paying Adobe taxes.</p> <p>The only &quot;good news&quot; I see is that the <a href="http://haxe.org" class="extern">Haxe</a> compiler itself is not relying on Alchemy opcodes (unless you use <code>flash.Memory</code>) and that it easily allows me to target other 3D technologies such as WebGL, which I will definitely consider seriously for the next 3D games, instead of Flash.</p> Open Letter to the Apache Flex Community http://ncannasse.fr/blog/open_letter_to_flex_community http://ncannasse.fr/blog/open_letter_to_flex_community Wed, 22 Feb 2012 11:36:51 +0100 Wed, 22 Feb 2012 11:36:51 +0100 Nicolas Cannasse Nicolas Cannasse <p>I was asked to comment on the possibility of the Apache Flex Community to port Flex to Haxe, and use...</p> <p>I was asked to comment on the possibility of the Apache Flex Community to port Flex to Haxe, and use it has its main technology, so I posted the following mail on the Apache Flex mailing list.</p> <p>I'm sharing it as well on my blog because it might also interest people that are not Flex subscribers.</p> <p>--</p> <p>I would say that there actually two choices to make there : one from a technical point of view, and one from a political point of view.</p> <p>From the technical point, and with all due respect to AS3, Haxe as-a-language is way ahead in terms of features. I'll not make the list of all the improvements we made, please look at the documentation and make your own idea about it.</p> <p>Of course, Haxe is a different language from AS3. In particular because it's been designed from the very start to be able to compile and run efficiently on different platforms (Flash, JavaScript, but also PHP,C++,C#,Java,etc.) </p> <p>Efficiently is the keyword here.</p> <p>Everybody working on compilers know that running a X language on a Y platform it's not been designed to run on is HARD. You can easily convert it to 80% - the part that always looks easy - then the next 10% are very hard, and the last 10% almost impossible without killing overall performances.</p> <p>The reason is simple : most of the languages (including AS3) have been designed together with the platform/VM they run on, so adapting it to another runtime which made different choices is like trying to fit a square in a round hole : it doesn't fit - unless maybe you cut the square corners.</p> <p>Haxe has been designed from the start to favor features that enable us to compile it efficiently on all platforms. It doesn't mean that we are using the lowest common denominator of all possible platforms, it's just that we make actual design choices that enable us to have great highlevel language features while still being able to compile them natively and efficiently on each platform.</p> <p>I'm explaining that because I know you want to target Javascript/HTML5 with Flex as well. Don't take it lightly : one good share of Flex future is definitely there, and trying to do everything by yourself is definitely a very hard road to take.</p> <p>I'm not a Flex expert, and to be honest I have never used it, so there might be pending issues and technical questions that you have regarding the best way to port Flex to Haxe : feel free to ask them there, I'll try to answer them to my best.</p> <p>Now from the political point of view :</p> <p>First, let me say that in the Flash world, Haxe is one of the most active open source community and we are very happy to welcome Apache Flex developers as a open source sister community.</p> <p>I've personally always been a huge support of open source philosophy : some of you might also have used MTASC a long time ago, I hope you enjoyed its quality and speed and that you will find the same enjoyment at using Haxe - if you use it at some point.</p> <p>You are now an independent community, which is great : you can now make your own choices, which should not be based on marketing, branding or overselling of a given tech, but on technical points.</p> <p>Adobe is currently pressured and has to make hard choices. You don't know what they will be, you don't know where they will go, and if they say Left, it might finally be Right after a few months. I don't blame them : they're a commercial company, they have their own agenda to take care of, it's just the way it is.</p> <p>OTOH, Haxe community has no hidden agenda : we thrive for the best technology, everything is open source, discussions and patches are welcome. We of course need to be conservative in terms of language features in order to not bloat the compiler and to keep the language elegant and coherent, so in the past years we've been improving things step by step, without either hurrying or slowing down.</p> <p>In the past year, while Flash has suffered several drawbacks, Haxe has definitely gained a huge momentum. In great part this is thanks to its community which has been writing code, but also making things more visible / accessible for developers.</p> <p>For instance http://haxenme.org is a great example of it : Haxe now enables to write-once compile-natively-everywhere on iOS, Android, Flash, Desktop and much more. You could do it before, but it's now much more easy, and people know about it.</p> <p>Sorry if I feel to much enthusiast about it, but I'm definitely excited about the times to come. </p> <p>Momentum is an important things for technology, especially when it's open source : it keeps developers motivated, it brings new people to the community, it helps making the right choices at the good time.</p> <p>I'm definitely sure that Haxe momentum can help the Flex community, and vice-versa. </p> <p>Now I guess you have two distincts choices left : continue to follow Adobe plans or adopt another technology (Haxe or something else) and move forward.</p> <p>I can't decide for you, but I can at least answer the questions you might have.</p> <p>Best,<br/>Nicolas</p> Optimizing your Printer http://ncannasse.fr/blog/optimizing_your_printer http://ncannasse.fr/blog/optimizing_your_printer Fri, 30 Dec 2011 13:07:38 +0100 Fri, 30 Dec 2011 13:07:38 +0100 Nicolas Cannasse Nicolas Cannasse <p>Today I'll not talk about code optimization but instead about hardware optimization.</p> <p>First, allow me...</p> <p>Today I'll not talk about code optimization but instead about hardware optimization.</p> <p>First, allow me to say I hate printers.</p> <p>They are actually quite useful tools for everyday interactions with the &quot;real world&quot; (or at least, the part of the real world that still use paper instead of digital documents). But the printer vendors are one of the most hateful industry : proprietary drivers, bloated software that you HAVE to install with your printer, and - most of all - toner page counters.</p> <p>Today I had to print many documents to send them back as snail mail. This is already an annoying thing to do. But when I was about to print the <b>last</b> page (of about 40) my printer stopped working and all was displayed was <em>Please replace the Toner</em>. </p> <p>WTF ? It was just printing very nicely just seconds ago ! In my old printers memories I was thinking that a toner would die when there is no more ink, or more exactly when you can no longer read what it prints...</p> <p>Looking at my Brother MFC-7440 printer settings, I found something called the &quot;Page Counter&quot;. It tells you how many pages you have printed so far.</p> <p>Guess what ? It was stopped at <b>exactly</b> 1500.</p> <p>Conclusion - in case you don't know about it - toners have a page counter, and toners will stop working when the page counter hits the limit, whatever if you have ink left or not.</p> <p>This just another form of <a href="http://en.wikipedia.org/wiki/Planned_obsolescence" class="extern">planned obsolescence</a>, and I hate it. Since when engineers should design products that are planned to break ? Since when science should be used not to improve the products, but to degrade their quality ? With all the waste of both energy and raw materials (and your money as well btw), this kind of behavior should become a crime, or at least I hope it will become in the upcoming years.</p> <p>But let's back to my printer, which looks like this actually :</p> <div class="align_left"> <p><img src="/file/IMAG0014.jpg" alt="IMAG0014.jpg" class="intern"/></p> </div> <p>I searched a bit on the internet and people were talking about different ways to reset the counter. I didn't find any information for my specific Printer/Toner.</p> <p>Some people were suggesting to remove and put back again the Toner. That didn't work for me.</p> <p>In terms of planned-obsolescence-engineering, it was making sense to put the counter inside the toner itself. And to have the printer ask the toner how many pages were left.</p> <p>So one of the way to reset the page counter was to stop all possible communications between the toner and the printer.</p> <span class="align_clear"></span> <div class="align_right"> <p><img src="/file/IMAG0015.jpg" alt="IMAG0015.jpg" class="intern"/></p> </div> <p>So I removed the toner and looked at it :</p> <p>On both left and right sides, I found some round-looking holes ending with a small glass-like window. Some place where maybe a laser could &quot;communicate&quot; with the toner.</p> <p>I tried then to simply close these holes. Putting tape was not very easy so I instead used tissue paper with a little water to make it stick.</p> <p>And once the toner was put back and the printer turned ON... Tadaaaa ! It was working like a charm and I could print my page number 1501 !</p> <p>I'm not sure how many pages the toner will actually be able to print, but I'll make sure once it <b>really</b> die to update this post with my optimized page counter.</p> <p>I expect a x1.5 to x3 optimization here.</p> <span class="align_clear"></span> <p>And what about you ? Do you know good ways to fight against planned obsolescence ?</p> <p><b>Update :</b> as mentioned in the comments, a must-see documentary on planned obsolescence is available in <a href="http://www.youtube.com/watch?v=Wv9MyB0hbI4" class="extern">English</a> <a href="http://www.youtube.com/watch?v=iB8DbSE0Y90" class="extern">French</a> and <a href="http://www.youtube.com/watch?v=tI798T2tRrQ" class="extern">German</a>. It was haired in early 2011 on the <a href="http://www.arte.tv" class="extern">Arte</a> tv channel.</p> World Wide Haxe Conference ! http://ncannasse.fr/blog/wwx http://ncannasse.fr/blog/wwx Tue, 20 Dec 2011 12:44:14 +0100 Tue, 20 Dec 2011 12:44:14 +0100 Nicolas Cannasse Nicolas Cannasse <p>I'm please to announce that the World Wide Haxe Conference 2012 (WWX-2012) will take place in Paris ...</p> <p>I'm please to announce that the World Wide Haxe Conference 2012 (WWX-2012) will take place in Paris on April 13-16 2012.</p> <p>This conference will be the best place to meet fellow Haxers and exchange both ideas and drinks ! Expect some big announcements to be made there as well !</p> <p>In short : if you are either an experienced Haxe developer or someone that want to learn more about it, this is THE place to be !</p> <p>Check <a href="http://wwx.haxe.org" class="extern">http://wwx.haxe.org</a> for all the details.</p> <p>This year we have enough room for ~100 persons so we put a ticket system in place, please not do wait for the last minute to get your seat or you might not make it.</p> <p>We are also looking for Speakers ! If you want to talk about your work or introduce your tools/library or want to show/teach/introduce something to the Haxe community, take your chance and please send us a mail with your speaking proposal at <code>speakers@haxe.org</code>.</p> <p>Selected speakers will be announce little by little but expect the main contributors to Haxe and Haxe libraries to show up ;)</p> <p>Big thanks to the SilexLabs.org team for taking care of the whole conference organization and WWX website !</p> <p>See you there !</p> Adobe Make Some Alchemy ! http://ncannasse.fr/blog/adobe_make_some_alchemy http://ncannasse.fr/blog/adobe_make_some_alchemy Wed, 23 Nov 2011 20:34:51 +0100 Wed, 23 Nov 2011 20:34:51 +0100 Nicolas Cannasse Nicolas Cannasse <p>Today I had some issues trying to recompile one of our SWF game to work with Flash Player 11.2 Beta....</p> <p>Today I had some issues trying to recompile one of our SWF game to work with Flash Player 11.2 Beta. I was getting an error #2500 <em>An error occured while decrypting the signed SWF. The SWF will not be loaded</em></p> <p>After trying different things to understand what's going on, I thought it was just a beta bug that would be fixed in final release. Until I saw the following quote that was added afterwards to the <a href="http://blogs.adobe.com/flashplayer/2011/09/updates-from-the-lab.html" class="extern">Adobe Release Notes</a> :</p> <span class="box1">Starting with Flash Player 11.2 and AIR 3.2, content targeting Flash Player 11 and AIR 3 (i.e., content using SWF version 13 and above) will not support the experimental Alchemy prototype.</span> <p>What the F.... ?</p> <p>But let's explain first what is <b>really</b> Alchemy for those of you that haven't used it. Alchemy is a tool to run C/C++ code in Flash Player. But this is <em>also</em> a set of Flash Virtual Machine opcodes (low level operations) that can be used to get quick memory access.</p> <p>These opcodes are available by using Haxe <a href="http://haxe.org/api/flash9/Memory" class="extern">flash.Memory</a> class or Joa Ebert <a href="http://blog.joa-ebert.com/2010/10/06/apparat-1-0-rc7-is-here/" class="extern">Apparat</a> optimization tool.</p> <p>These operations allow to perform very fast memory operations that crush the performances of using (very slow) native Vector or Array classes. See for instance <a href="http://lab.polygonal.de/2010/03/15/memorymanager-revisited/" class="extern">Polygonal Labs Benchs</a> that show a x3 to x8 speedup by using Alchemy operations.</p> <p>With native 3D now in Flash Player, it is really important to be able to use these operations as well, since a lot of API require you to build both vertex and index buffers, and Alchemy can improve your framerate by orders of magnitudes !</p> <p>I've been using Haxe <code>flash.Memory</code> in many different games right now, in order to perform many different operations such as fast 3D (x,y,time) PerlinNoise, custom filters, fast vertex buffer creation, etc etc etc.</p> <p>Seeing it removed from future versions of the Flash Player is a terrible signal sent to all Flash games developers !</p> <p>So what to do ?</p> <p>Adobe history of taking random decisions that piss off the whole community being what it is, I guess the only thing left it to complain, complain, and complain, until they hear us out and bring it back !</p> <p>Two steps for that :</p> <ul><li>spread the word ! Tweet this post or other related news around you</li><li>send emails/tweets to Adobe community managers interested in flash gaming such as <a href="http://www.bytearray.org/" class="extern">Thibault Imbert</a></li></ul> <p>...with the hope that it will make them change their plans.</p> <p>Thank you !</p> <p><b>Update :</b> Actually this is even worse since existing content built for FP11+ (SWF-version=13+) and using Alchemy opcodes will BREAK as soon as you install FP 11.2 !!! You'll have to buy Alchemy2 and recompile your existing content so it can continue to work (WTF ! again) - this information is confirmed by Adobe.</p> Flash is dead, again ? http://ncannasse.fr/blog/flash_is_dead_again http://ncannasse.fr/blog/flash_is_dead_again Sun, 13 Nov 2011 09:15:59 +0100 Sun, 13 Nov 2011 09:15:59 +0100 Nicolas Cannasse Nicolas Cannasse <p>I didn't wrote that much about recent Adobe announcement that they are dropping Flash Player for mob...</p> <p>I didn't wrote that much about recent Adobe announcement that they are dropping Flash Player for mobile and focusing on AIR for apps instead. I wanted first to see what kind of reactions people had.</p> <p>There is actually many different point of views.</p> <p><b>Joy</b> : people that didn't like Flash (some of them actually hate it) are rejoicing, seeing that as the next step toward complete flash demise. I can understand why people don't like proprietary technologies. As a developer, you get more frustrated since you can't contribute or try changing things that are just broken. And companies are often driving you into some kind of vendor-locking strategies in order to make sure that you can't reuse your skills if you buy another product from another company or - worse - use open source software. Which leads to...</p> <p><b>Fear</b> : &quot;omgwtf I know only about Flash how am I going to eat in the upcoming years if it's dead ???&quot; that's what a lot of flash developers are thinking now. They spent years building their skills for a given particular usage. Seeing this usage fade away must be quite fearsome. Of course they are people that will told them that nothing is wrong...</p> <p><b>Deny</b> : &quot;I have never used Flash browser on mobile so it changes nothing, and you can still use with AIR for apps, actually this is great news !&quot; .... Well, that's one way to put it, and actually that's not entirely wrong since actually flash browser usage on mobile has never been the main way to use Flash. That's just missing the point.</p> <p>People thinking that way are just completely ignoring that technology popularity has never been about facts, but about hype, buzz, and somehow communication. Like it or not (being a scientist I'm actually very sad about it) but it works this way. And Adobe just sent a very bad red-light signal to all their actual (and potential) users. That might not be what they intended, but the result is the same : some companies will cancel their flash/mobile projects, some other will not choose Flash why they could have, etc. Of course some people know about that, but they just don't care...</p> <p><b>Positivism</b> : &quot;every technology have its own life cycle, change is good, try to adapt it and follow where it leads you to&quot;. Which is true. But frustrating. First, because I want to be able to use the technology I choose and not the one that happen to be the one everybody is telling me to use. And second, because the only way out is Javascript.</p> <p>Not that I don't like Javascript : this is a not-so-bad scripting language (btw the term scripting does not actually mean anything in terms of programming language, but I'm still using it there) which is quite easy to both learn and master, an active community, several good open source virtual machines, good tools, debuggers etc. But it's not my language of choice. First because I prefer statically typed programming languages : they might be harder to learn and master, but - when done right - I feel they give you a great productivity boost by letting you focus on your actual code and warning you for all the other minor errors you might be doing (typos, wrong parameters, etc.)</p> <p>I don't think that statically typed PL will work for everybody - some people might spend more time actually figuring out how to correctly &quot;type&quot; their programs that they spend on actually programming - and I don't think that a single programming language can work for everybody, that language being my own (<a href="http://haxe.org" class="extern">Haxe</a> btw) or Javascript.</p> <p>But let's back to the topic, which was Flash.</p> <p>To answer the original question &quot;Is Flash dead ?&quot;, I would say &quot;again&quot; : that's one more blow to it, and a big failure PR-wise for Adobe. But a technology is not dying so easily. It might eventually fade away in the upcoming years, or raise back (which is possible be have less probability) . In all cases, if you are a flash developer : don't panic. But don't do anything either ! Try to learn new things, not for the immediate present, but for the middle-term future. If you find Javascript sexy, then go for it. If you prefer structured/typed programming, then learn Haxe.</p> <p>One more word about Haxe btw (it's my blog actually so I feel free to talk about my own things, hope you don't care - hopefully not if you've been reading all this post). The particularity of Haxe is that it is a language without its own platform. Usually all languages have their own platform : ActionScript has Flash, Java the JVM, C# has .Net, Javascript the web browser. Of course some people are trying to run these languages on other platforms as well, but it's often awkward and slow because the languages have usually been designed to run on their own platform. Haxe is about having one single highlevel strictly typed programming language that compiles - natively - too all the mainstream platforms. That's what we have a last kind of thoughts.</p> <p><b>Don't care</b> : Haxe developers don't care about petty platform wars, they know that Haxe will always adapt the mainstream platforms, that the community will build crossplatform apis as they did for Flash with NME (to run on C++/Mobile) or Jeash (to run on Javascript), and that you can still target natively a given platform to get the best performances and full features access.</p> <p>Of course, I am part of this last category of people. </p> <p>Hope you will join us too !</p> Perlin Noise Shader http://ncannasse.fr/blog/perlin_noise_shader http://ncannasse.fr/blog/perlin_noise_shader Sat, 22 Oct 2011 23:07:49 +0200 Sat, 22 Oct 2011 23:07:49 +0200 Nicolas Cannasse Nicolas Cannasse <p>A few months ago I spent some time trying to run perlin noise on full GPU with a hardware shader.</p> <p>Of...</p> <p>A few months ago I spent some time trying to run perlin noise on full GPU with a hardware shader.</p> <p>Of course, thanks to <a href="http://haxe.org/manual/hxsl" class="extern">HxSL</a> I didn't have to write it in assembler.</p> <p>Before getting into code details, let's have a small demo :</p> <p><div class="swf" id="swf_1" style="width : 600px">[perlin_shader.swf]</div><script type="text/javascript" id="js_1">var o = new js.SWFObject('/file/perlin_shader.swf','swfobj_1',600,400,'9','#FFFFFF');o.addParam('wmode','direct');o.write('swf_1');</script></p> <p>Here's the final shader code in HxSL :</p> <pre class="haxe"><span class="kwd">var</span> input : <span class="op">{</span> pos : Float3, <span class="op">}</span>; <span class="kwd">var</span> perlinPos : Float3; <span class="kwd">function</span> vertex<span class="op">(</span>delta : Float3, scale : <span class="type">Float</span><span class="op">)</span> <span class="op">{</span> out = pos<span class="number">.</span>xyzw; perlinPos = <span class="op">(</span><span class="op">[</span><span class="op">(</span>pos<span class="number">.</span>x + <span class="number">1</span><span class="op">)</span> * <span class="number">0.5</span>, <span class="number">1</span> - <span class="op">(</span>pos<span class="number">.</span>y + <span class="number">1</span><span class="op">)</span> * <span class="number">0.5</span>, <span class="number">0</span><span class="op">]</span> + delta<span class="op">)</span> * scale; <span class="op">}</span> <span class="kwd">function</span> gradperm<span class="op">(</span> g : Texture, v : <span class="type">Float</span>, pp : Float3 <span class="op">)</span> <span class="op">{</span> <span class="kwd">return</span> <span class="op">(</span>g<span class="number">.</span>get<span class="op">(</span>v,single,nearest,wrap<span class="op">)</span>.xyz * <span class="number">2</span> - <span class="number">1</span><span class="op">)</span>.dot<span class="op">(</span>pp<span class="op">)</span>; <span class="op">}</span> <span class="kwd">function</span> lerp<span class="op">(</span> x : <span class="type">Float</span>, y : <span class="type">Float</span>, v : <span class="type">Float</span> <span class="op">)</span> <span class="op">{</span> <span class="kwd">return</span> x * <span class="op">(</span><span class="number">1</span> - v<span class="op">)</span> + y * v; <span class="op">}</span> <span class="kwd">function</span> fade<span class="op">(</span> t : Float3 <span class="op">)</span> : Float3 <span class="op">{</span> <span class="kwd">return</span> t * t * t * <span class="op">(</span>t * <span class="op">(</span>t * <span class="number">6</span> - <span class="number">15</span><span class="op">)</span> + <span class="number">10</span><span class="op">)</span>; <span class="op">}</span> <span class="kwd">function</span> gradient<span class="op">(</span> permut : Texture, g : Texture, pos : Float3 <span class="op">)</span> <span class="op">{</span> <span class="kwd">var</span> p = pos<span class="number">.</span>frc<span class="op">(</span><span class="op">)</span>; <span class="kwd">var</span> i = pos - p; <span class="kwd">var</span> f = fade<span class="op">(</span>p<span class="op">)</span>; <span class="kwd">var</span> one = <span class="number">1</span> / <span class="number">256</span>; i *= one; <span class="kwd">var</span> a = permut<span class="number">.</span>get<span class="op">(</span>i<span class="number">.</span>xy, nearest, wrap<span class="op">)</span> + i<span class="number">.</span>z; <span class="kwd">return</span> lerp<span class="op">(</span> lerp<span class="op">(</span> lerp<span class="op">(</span> gradperm<span class="op">(</span>g, a<span class="number">.</span>x, p<span class="op">)</span>, gradperm<span class="op">(</span>g, a<span class="number">.</span>z, p + <span class="op">[</span> -<span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span><span class="op">]</span> <span class="op">)</span>, f<span class="number">.</span>x<span class="op">)</span>, lerp<span class="op">(</span> gradperm<span class="op">(</span>g, a<span class="number">.</span>y, p + <span class="op">[</span><span class="number">0</span>, -<span class="number">1</span>, <span class="number">0</span><span class="op">]</span> <span class="op">)</span>, gradperm<span class="op">(</span>g, a<span class="number">.</span>w, p + <span class="op">[</span> -<span class="number">1</span>, -<span class="number">1</span>, <span class="number">0</span><span class="op">]</span> <span class="op">)</span>, f<span class="number">.</span>x<span class="op">)</span>, f<span class="number">.</span>y <span class="op">)</span>, lerp<span class="op">(</span> lerp<span class="op">(</span> gradperm<span class="op">(</span>g, a<span class="number">.</span>x + one, p + <span class="op">[</span><span class="number">0</span>, <span class="number">0</span>, -<span class="number">1</span><span class="op">]</span> <span class="op">)</span>, gradperm<span class="op">(</span>g, a<span class="number">.</span>z + one, p + <span class="op">[</span> -<span class="number">1</span>, <span class="number">0</span>, -<span class="number">1</span><span class="op">]</span> <span class="op">)</span>, f<span class="number">.</span>x<span class="op">)</span>, lerp<span class="op">(</span> gradperm<span class="op">(</span>g, a<span class="number">.</span>y + one, p + <span class="op">[</span><span class="number">0</span>, -<span class="number">1</span>, -<span class="number">1</span><span class="op">]</span> <span class="op">)</span>, gradperm<span class="op">(</span>g, a<span class="number">.</span>w + one, p + <span class="op">[</span> -<span class="number">1</span>, -<span class="number">1</span>, -<span class="number">1</span><span class="op">]</span> <span class="op">)</span>, f<span class="number">.</span>x<span class="op">)</span>, f<span class="number">.</span>y <span class="op">)</span>, f<span class="number">.</span>z <span class="op">)</span>; <span class="op">}</span> <span class="kwd">function</span> fragment<span class="op">(</span> permut : Texture, g : Texture<span class="op">)</span> <span class="op">{</span> <span class="kwd">var</span> pos = perlinPos; <span class="kwd">var</span> tot = <span class="number">0</span>; <span class="kwd">var</span> per = <span class="number">1.0</span>; <span class="kwd">for</span><span class="op">(</span> k <span class="kwd">in</span> <span class="number">0...2</span> <span class="op">)</span> <span class="op">{</span> tot += gradient<span class="op">(</span>permut, g, pos<span class="op">)</span> * per; per *= <span class="number">0.5</span>; pos *= <span class="number">2</span>; <span class="op">}</span> <span class="kwd">var</span> n = <span class="op">(</span>tot + <span class="number">1</span><span class="op">)</span> * <span class="number">0.5</span>; out = <span class="op">[</span>n, n, n, <span class="number">1</span><span class="op">]</span>; <span class="op">}</span></pre> <p>Sadly, because of Flash11 limitation to 200 opcodes in shaders, we can only perform two octaves (which are done through for loop unrolling).</p> <p>You'll notice that two textures are used for this shader : the <code>permut</code> texture and the <code>g</code> texture.</p> <p>They correspond to the two main operations done by perlin noise : for each point (x,y) the perlin noise will calculate the integer part (ix,iy). It will then use a lookup in the <code>permut</code> texture to perform some kind of pseudo-randomization.</p> <p>So this way the (ix,iy) integer coordinates will give us a random index into a gradient value, which is the gradient at the top-left corner of the &quot;box&quot;. Now what's left is only to get the other 3 gradients values at the other box corners (which are at (ix+1,iy) (ix,iy+1) and (ix+1,iy+1)).</p> <p>The algorithm will then interpolate between these 4 corner values : if we are at the top-left corner, it means that we should reach the top-left gradient value, and so on... The interpolation is not linear but uses a <code>fade</code> function which will smooth transitions between gradients.</p> <p>One other issue with Flash11 is the lack of Float textures : the gradient values are usually between [-1 and 1] and all three values needs to represent a unit-sized 3D vector. Because we have to encode the gradients into RGB texture color space which is between [0...1] with only 1/256 precision, it is needed to perform two additional operations per gradient lookup which is (g * 2 - 1). Normalization of the gradient after that is not really needed since the precision is good-enough in most cases.</p> <p>Another important part of the code is the one that builds both textures :</p> <pre class="haxe"><span class="kwd">static</span> <span class="kwd">var</span> PTBL = flash<span class="number">.</span>Vector<span class="number">.</span>ofArray<span class="op">(</span><span class="op">[</span> <span class="number">151</span>, <span class="number">160</span>, <span class="number">137</span>, <span class="number">91</span>, <span class="number">90</span>, <span class="number">15</span>, <span class="number">131</span>,<span class="number">13</span>,<span class="number">201</span>,<span class="number">95</span>,<span class="number">96</span>,<span class="number">53</span>,<span class="number">194</span>,<span class="number">233</span>,<span class="number">7</span>,<span class="number">225</span>,<span class="number">140</span>,<span class="number">36</span>,<span class="number">103</span>,<span class="number">30</span>,<span class="number">69</span>,<span class="number">142</span>,<span class="number">8</span>,<span class="number">99</span>,<span class="number">37</span>,<span class="number">240</span>,<span class="number">21</span>,<span class="number">10</span>,<span class="number">23</span>, <span class="number">190</span>, <span class="number">6</span>,<span class="number">148</span>,<span class="number">247</span>,<span class="number">120</span>,<span class="number">234</span>,<span class="number">75</span>,<span class="number">0</span>,<span class="number">26</span>,<span class="number">197</span>,<span class="number">62</span>,<span class="number">94</span>,<span class="number">252</span>,<span class="number">219</span>,<span class="number">203</span>,<span class="number">117</span>,<span class="number">35</span>,<span class="number">11</span>,<span class="number">32</span>,<span class="number">57</span>,<span class="number">177</span>,<span class="number">33</span>, <span class="number">88</span>,<span class="number">237</span>,<span class="number">149</span>,<span class="number">56</span>,<span class="number">87</span>,<span class="number">174</span>,<span class="number">20</span>,<span class="number">125</span>,<span class="number">136</span>,<span class="number">171</span>,<span class="number">168</span>, <span class="number">68</span>,<span class="number">175</span>,<span class="number">74</span>,<span class="number">165</span>,<span class="number">71</span>,<span class="number">134</span>,<span class="number">139</span>,<span class="number">48</span>,<span class="number">27</span>,<span class="number">166</span>, <span class="number">77</span>,<span class="number">146</span>,<span class="number">158</span>,<span class="number">231</span>,<span class="number">83</span>,<span class="number">111</span>,<span class="number">229</span>,<span class="number">122</span>,<span class="number">60</span>,<span class="number">211</span>,<span class="number">133</span>,<span class="number">230</span>,<span class="number">220</span>,<span class="number">105</span>,<span class="number">92</span>,<span class="number">41</span>,<span class="number">55</span>,<span class="number">46</span>,<span class="number">245</span>,<span class="number">40</span>,<span class="number">244</span>, <span class="number">102</span>,<span class="number">143</span>,<span class="number">54</span>, <span class="number">65</span>,<span class="number">25</span>,<span class="number">63</span>,<span class="number">161</span>, <span class="number">1</span>,<span class="number">216</span>,<span class="number">80</span>,<span class="number">73</span>,<span class="number">209</span>,<span class="number">76</span>,<span class="number">132</span>,<span class="number">187</span>,<span class="number">208</span>, <span class="number">89</span>,<span class="number">18</span>,<span class="number">169</span>,<span class="number">200</span>,<span class="number">196</span>, <span class="number">135</span>,<span class="number">130</span>,<span class="number">116</span>,<span class="number">188</span>,<span class="number">159</span>,<span class="number">86</span>,<span class="number">164</span>,<span class="number">100</span>,<span class="number">109</span>,<span class="number">198</span>,<span class="number">173</span>,<span class="number">186</span>, <span class="number">3</span>,<span class="number">64</span>,<span class="number">52</span>,<span class="number">217</span>,<span class="number">226</span>,<span class="number">250</span>,<span class="number">124</span>,<span class="number">123</span>, <span class="number">5</span>,<span class="number">202</span>,<span class="number">38</span>,<span class="number">147</span>,<span class="number">118</span>,<span class="number">126</span>,<span class="number">255</span>,<span class="number">82</span>,<span class="number">85</span>,<span class="number">212</span>,<span class="number">207</span>,<span class="number">206</span>,<span class="number">59</span>,<span class="number">227</span>,<span class="number">47</span>,<span class="number">16</span>,<span class="number">58</span>,<span class="number">17</span>,<span class="number">182</span>,<span class="number">189</span>,<span class="number">28</span>,<span class="number">42</span>, <span class="number">223</span>,<span class="number">183</span>,<span class="number">170</span>,<span class="number">213</span>,<span class="number">119</span>,<span class="number">248</span>,<span class="number">152</span>, <span class="number">2</span>,<span class="number">44</span>,<span class="number">154</span>,<span class="number">163</span>, <span class="number">70</span>,<span class="number">221</span>,<span class="number">153</span>,<span class="number">101</span>,<span class="number">155</span>,<span class="number">167</span>, <span class="number">43</span>,<span class="number">172</span>,<span class="number">9</span>, <span class="number">129</span>,<span class="number">22</span>,<span class="number">39</span>,<span class="number">253</span>, <span class="number">19</span>,<span class="number">98</span>,<span class="number">108</span>,<span class="number">110</span>,<span class="number">79</span>,<span class="number">113</span>,<span class="number">224</span>,<span class="number">232</span>,<span class="number">178</span>,<span class="number">185</span>, <span class="number">112</span>,<span class="number">104</span>,<span class="number">218</span>,<span class="number">246</span>,<span class="number">97</span>,<span class="number">228</span>, <span class="number">251</span>,<span class="number">34</span>,<span class="number">242</span>,<span class="number">193</span>,<span class="number">238</span>,<span class="number">210</span>,<span class="number">144</span>,<span class="number">12</span>,<span class="number">191</span>,<span class="number">179</span>,<span class="number">162</span>,<span class="number">241</span>, <span class="number">81</span>,<span class="number">51</span>,<span class="number">145</span>,<span class="number">235</span>,<span class="number">249</span>,<span class="number">14</span>,<span class="number">239</span>,<span class="number">107</span>, <span class="number">49</span>,<span class="number">192</span>,<span class="number">214</span>, <span class="number">31</span>,<span class="number">181</span>,<span class="number">199</span>,<span class="number">106</span>,<span class="number">157</span>,<span class="number">184</span>, <span class="number">84</span>,<span class="number">204</span>,<span class="number">176</span>,<span class="number">115</span>,<span class="number">121</span>,<span class="number">50</span>,<span class="number">45</span>,<span class="number">127</span>, <span class="number">4</span>,<span class="number">150</span>,<span class="number">254</span>, <span class="number">138</span>,<span class="number">236</span>,<span class="number">205</span>,<span class="number">93</span>,<span class="number">222</span>,<span class="number">114</span>,<span class="number">67</span>,<span class="number">29</span>,<span class="number">24</span>,<span class="number">72</span>,<span class="number">243</span>,<span class="number">141</span>,<span class="number">128</span>,<span class="number">195</span>,<span class="number">78</span>,<span class="number">66</span>,<span class="number">215</span>,<span class="number">61</span>,<span class="number">156</span>,<span class="number">180</span> <span class="op">]</span><span class="op">)</span>; <span class="kwd">static</span> <span class="kwd">var</span> GRAD = <span class="op">[</span> <span class="number">1</span>,<span class="number">1</span>,<span class="number">0</span>, -<span class="number">1</span>,<span class="number">1</span>,<span class="number">0</span>, <span class="number">1</span>,-<span class="number">1</span>,<span class="number">0</span>, -<span class="number">1</span>,-<span class="number">1</span>,<span class="number">0</span>, <span class="number">1</span>,<span class="number">0</span>,<span class="number">1</span>, -<span class="number">1</span>,<span class="number">0</span>,<span class="number">1</span>, <span class="number">1</span>,<span class="number">0</span>,-<span class="number">1</span>, -<span class="number">1</span>,<span class="number">0</span>,-<span class="number">1</span>, <span class="number">0</span>,<span class="number">1</span>,<span class="number">1</span>, <span class="number">0</span>,-<span class="number">1</span>,<span class="number">1</span>, <span class="number">0</span>,<span class="number">1</span>,-<span class="number">1</span>, <span class="number">0</span>,-<span class="number">1</span>,-<span class="number">1</span>, <span class="number">1</span>,<span class="number">1</span>,<span class="number">0</span>, <span class="number">0</span>,-<span class="number">1</span>,<span class="number">1</span>, -<span class="number">1</span>,<span class="number">1</span>,<span class="number">0</span>, <span class="number">0</span>,-<span class="number">1</span>,-<span class="number">1</span>, <span class="op">]</span>; <span class="kwd">inline</span> <span class="kwd">function</span> perm<span class="op">(</span> x : <span class="type">Int</span> <span class="op">)</span> <span class="op">{</span> <span class="kwd">return</span> ptbl<span class="op">[</span>x &amp; 0xFF<span class="op">]</span>; <span class="op">}</span> <span class="kwd">function</span> initPermut<span class="op">(</span><span class="op">)</span> <span class="op">{</span> <span class="kwd">var</span> bytes = <span class="kwd">new</span> flash<span class="number">.</span>utils<span class="number">.</span>ByteArray<span class="op">(</span><span class="op">)</span>; bytes<span class="number">.</span>length = <span class="number">256</span> * <span class="number">256</span> * <span class="number">4</span>; flash<span class="number">.</span>Memory<span class="number">.</span>select<span class="op">(</span>bytes<span class="op">)</span>; <span class="kwd">var</span> out = <span class="number">0</span>; <span class="kwd">for</span><span class="op">(</span> y <span class="kwd">in</span> <span class="number">0...256</span> <span class="op">)</span> <span class="kwd">for</span><span class="op">(</span> x <span class="kwd">in</span> <span class="number">0...256</span> <span class="op">)</span> <span class="op">{</span> <span class="kwd">var</span> a = perm<span class="op">(</span>x<span class="op">)</span> + y; <span class="kwd">var</span> aa = perm<span class="op">(</span>a<span class="op">)</span>; <span class="kwd">var</span> ab = perm<span class="op">(</span>a + <span class="number">1</span><span class="op">)</span>; <span class="kwd">var</span> b = perm<span class="op">(</span>x + <span class="number">1</span><span class="op">)</span> + y; <span class="kwd">var</span> ba = perm<span class="op">(</span>b<span class="op">)</span>; <span class="kwd">var</span> bb = perm<span class="op">(</span>b + <span class="number">1</span><span class="op">)</span>; flash<span class="number">.</span>Memory<span class="number">.</span>setByte<span class="op">(</span>out++, ba<span class="op">)</span>; <span class="comment">// B</span> flash<span class="number">.</span>Memory<span class="number">.</span>setByte<span class="op">(</span>out++, ab<span class="op">)</span>; <span class="comment">// G</span> flash<span class="number">.</span>Memory<span class="number">.</span>setByte<span class="op">(</span>out++, aa<span class="op">)</span>; <span class="comment">// R</span> flash<span class="number">.</span>Memory<span class="number">.</span>setByte<span class="op">(</span>out++, bb<span class="op">)</span>; <span class="comment">// A</span> <span class="op">}</span> <span class="kwd">var</span> t = c<span class="number">.</span>createTexture<span class="op">(</span><span class="number">256</span>, <span class="number">256</span>, TextureFormat<span class="number">.</span>BGRA, false<span class="op">)</span>; t<span class="number">.</span>uploadFromByteArray<span class="op">(</span>bytes, <span class="number">0</span><span class="op">)</span>; <span class="kwd">return</span> t; <span class="op">}</span> <span class="kwd">function</span> initGradient<span class="op">(</span><span class="op">)</span> <span class="op">{</span> <span class="kwd">var</span> bytes = <span class="kwd">new</span> flash<span class="number">.</span>utils<span class="number">.</span>ByteArray<span class="op">(</span><span class="op">)</span>; <span class="kwd">for</span><span class="op">(</span> x <span class="kwd">in</span> <span class="number">0...256</span> <span class="op">)</span> <span class="op">{</span> <span class="kwd">var</span> p = <span class="op">(</span>perm<span class="op">(</span>x<span class="op">)</span> &amp; <span class="number">15</span><span class="op">)</span> * <span class="number">3</span>; <span class="kwd">var</span> r = GRAD<span class="op">[</span>p<span class="op">]</span>; <span class="kwd">var</span> g = GRAD<span class="op">[</span>p + <span class="number">1</span><span class="op">]</span>; <span class="kwd">var</span> b = GRAD<span class="op">[</span>p + <span class="number">2</span><span class="op">]</span>; bytes<span class="number">.</span>writeByte<span class="op">(</span><span class="type">Std</span>.int<span class="op">(</span><span class="op">(</span>b + <span class="number">1</span><span class="op">)</span> * <span class="number">127.5</span><span class="op">)</span><span class="op">)</span>; bytes<span class="number">.</span>writeByte<span class="op">(</span><span class="type">Std</span>.int<span class="op">(</span><span class="op">(</span>g + <span class="number">1</span><span class="op">)</span> * <span class="number">127.5</span><span class="op">)</span><span class="op">)</span>; bytes<span class="number">.</span>writeByte<span class="op">(</span><span class="type">Std</span>.int<span class="op">(</span><span class="op">(</span>r + <span class="number">1</span><span class="op">)</span> * <span class="number">127.5</span><span class="op">)</span><span class="op">)</span>; bytes<span class="number">.</span>writeByte<span class="op">(</span><span class="number">255</span><span class="op">)</span>; <span class="comment">// A</span> <span class="op">}</span> <span class="kwd">var</span> t = c<span class="number">.</span>createTexture<span class="op">(</span><span class="number">256</span>, <span class="number">1</span>, TextureFormat<span class="number">.</span>BGRA, false<span class="op">)</span>; t<span class="number">.</span>uploadFromByteArray<span class="op">(</span>bytes, <span class="number">0</span><span class="op">)</span>; <span class="kwd">return</span> t; <span class="op">}</span></pre> <p>The PTBL is the classic perlin noise permutation table, everything else is just precomputing some perlin noise operations in order to make sure that is can be performed with less texture lookups.</p> <p>Now all you have to do is to build a quad covering a part of the screen, initialize it with a <code>delta</code> corresponding to the perlin scroll and a <code>scale</code> value.</p> <p>Download the <a href="/file/perlin3d.zip" class="file file_zip">Full Haxe source code </a></p> Haxe 2.08 http://ncannasse.fr/blog/haxe_2.08 http://ncannasse.fr/blog/haxe_2.08 Sun, 25 Sep 2011 15:32:42 +0200 Sun, 25 Sep 2011 15:32:42 +0200 Nicolas Cannasse Nicolas Cannasse <p>I'm very happy to announce the 2.08 release of Haxe, available now on <a href="http://haxe.org/download" class="extern">http://haxe.org/download</a></p> <p>This ...</p> <p>I'm very happy to announce the 2.08 release of Haxe, available now on <a href="http://haxe.org/download" class="extern">http://haxe.org/download</a></p> <p>This release was initially planned for this summer, but it got a bit delayed because of many new features (and community requests) that needed some additional testing/feedback before a proper release.</p> <p>Because Haxe increasing popularity there's still a lot of <a href="http://code.google.com/p/haxe/issues" class="extern">pending things</a> that needs to be done, but we had to stop a bit adding new things and make a proper release at some time. This is most likely the latest 2.xx release, next one should be Haxe 3.0, around spring 2012.</p> <p>Let's see now what's new in 2.08 :</p> <div class="biglist"> <ul><li>For Javascript, we've been improving the <code>.js</code> code output : it looks nicer, more hand-written, less verbose. There's still some improvements that can be done, but don't forget that you can write your own <a href="http://haxe.org/manual/macros_compiler" class="extern">custom JS generator</a> in Haxe.</li></ul> <ul><li>there's now <code>js.JQuery</code> as part of the standard library. It uses the new <code>@:overload</code> <a href="http://haxe.org/manual/tips_and_tricks" class="extern">metadata</a> to have a fully typed JQuery access in Haxe. By default JQuery-1.5 is automatically embedded, you can disable this by using <code>-D noEmbedJS</code></li></ul> <ul><li>the full Flash Player 11 Apis are now available, with Haxe high level 3D shaders <a href="http://haxe.org/manual/hxsl" class="extern">HxSL</a> and it is now possible to directly embed bitmaps with the following code :<br/><pre class="haxe">@:bitmap<span class="op">(</span><span class="string">"file.png"</span><span class="op">)</span> <span class="kwd">class</span> File <span class="kwd">extends</span> flash<span class="number">.</span>display<span class="number">.</span>BitmapData <span class="op">{</span><span class="op">}</span></pre></li></ul> <ul><li>two new apis for server-side web developement : the <a href="http://haxe.org/manual/dispatch" class="extern">URL Dispatcher</a> and a brand new version of SPOD which enable you to write directly your SQL as Haxe expressions, see <a href="http://haxe.org/manual/spod" class="extern">SPOD Macros</a></li></ul> <ul><li>the ability to directly reuse <code>this</code> and member variables from within the locally declared functions, such as the following example show :<br/><pre class="haxe"><span class="kwd">class</span> Foo <span class="op">{</span> <span class="kwd">var</span> count : <span class="type">Int</span>; <span class="kwd">public</span> <span class="kwd">function</span> <span class="kwd">new</span><span class="op">(</span><span class="op">)</span> <span class="op">{</span> sprite<span class="number">.</span>addEventListener<span class="op">(</span><span class="string">"click"</span>,<span class="kwd">function</span><span class="op">(</span>e<span class="op">)</span> count++<span class="op">)</span>; <span class="op">}</span> <span class="op">}</span></pre></li></ul> <ul><li>a lot of improvements on <a href="http://haxe.org/manual/macros" class="extern">Macros</a>, in particular a lot of optimization for the runtime performances and better ways to manipulate a type declaration and to define new types, see <a href="http://haxe.org/manual/macros/build" class="extern">Building Types with Macros</a></li></ul> <ul><li>and much more... (see the <a href="http://haxe.org/file/CHANGES.txt" class="extern">change log</a>)</li></ul> </div> <p>There's actually much more than this, and this is only a small part of what's happening around Haxe, since there are much more work done in 3rd party libraries by the Haxe community, watch for <a href="http://haxenme.org" class="extern">http://haxenme.org</a> for an example.</p> <p>Enjoy !</p>