haxefoundation / code-cookbook Goto Github PK
View Code? Open in Web Editor NEWThe Haxe Code Cookbook - A community driven resource website for learning Haxe in practise
Home Page: https://code.haxe.org
The Haxe Code Cookbook - A community driven resource website for learning Haxe in practise
Home Page: https://code.haxe.org
A fixed ring array are especially useful when you need a hard upper bound for how much data can be in the queue.
https://code.haxe.org/category/data-structures/ring-array.html
I came across the example using ereg for email validation. It uses a way too restrictive regex for validation, which users will copy and paste. I suggest simplifying it, something like ~/.+@.+\..+/i.
Sources:
It didn't take us long to become inconsistent with our indentation:
http://haxe-cookbook.stroep.nl/validate-json.html has two-space tabs.
http://haxe-cookbook.stroep.nl/Null-safety.html has four-space tabs.
This example uses haxe.Http to load external json file using and demonstrates how to handle the result.
https://code.haxe.org/category/beginner/loading-external-files.html
I know there are different opinions on this, but I've had good experience having the .n file in the repository for Dox because it means people don't have to install the dependencies in order to run the thing. Any opinions?
In Haxe, the Array type represents a collection of elements ordered by their index (order number) in the collection.
Have: No deployment
Want: Deployment
That's all I really know about this repository at the moment. Assigning to special CI investigator Rudy!
Classes inherit from other classes using the extends keyword:
there is a "zz" that I think should be a "ss". I am new here so I could be wrong.
Sources:
For some reason, code.haxe.org doesn't seem to rank very highly on google.. googling for static extensions haxe
, I get the Haxe Manual's article as the first result:
https://haxe.org/manual/lf-static-extension.html
The code cookbook snippet for static extensions doesn't show up anywhere though (at least not in the first five pages):
http://code.haxe.org/category/beginner/using-static-extensions.html
This is a bit of a shame, especially because a lot of people seem to struggle with the manual's technical wording - the cookbook has more of a tutorial-style that is beginner-friendly.
Linking to code cookbook snippets from the Haxe Manual might help. Perhaps some things could also be linked to from the API docs? Not static extensions of course, there's no API for that, but maybe macros.
Recently found this:
https://github.com/lbergman/GASM/blob/develop/src/gasm/core/macros/ComponentMacros.hx#L37-L52
After some investigation, I heard you can do (macro class { ... }).fields
.
As example it can be reduced to:
var fields = Context.getBuildFields();
var name = "Message";
var extraFields = (macro : {
public function name(get, null):String;
private inline function get_name() return $v{name};
public static var NAME:String = $v{name};
}).fields;
fields = fields.concat(extraFields);
Some info from nadako:
One just has to remember -
macro something
is just a syntax sugar for creating data structures (Expr, TypeDefinition, ComplexType, etc), so of course if you createmacro class {...}
that's going to be a TypeDefinition, so you can access its fields normally
I almost always create fields manually, but for exprs I use reification. It doesn't feel right to create a TypeDefinition that will be thrown away later, but OTOH Haxe will inline and eliminate it.
This is awesome and much more readable than creating fields manually for some cases.
ref https://haxe.org/manual/macro-reification-class.html
TODO: Make article about this, and/or integrate in those https://code.haxe.org/tag/building-fields.html
Can go into "design patterns"
https://blog.onthewings.net/2010/12/19/method-chaining-and-fluent-interface-in-haxe/
The link in the last sentence is broken :
Learn about available global compiler flags here: https://haxe.org/manual/lf-condition-compilation-flags.html
Sources:
https://code.haxe.org/category/macros/
The tags here aren't links:
However, on the page itself, they are:
I'd like to be able to click them in both cases.
Sources:
When compiling the example there is an error
src/MyMacro.hx:19: characters 10-23 : Array<haxe.macro.ClassField> has no field exists
I created a corrected version
https://github.com/ustutz/init_locals_macro
It does compile but the neko call to generate stuff fails.
Is it ok to put examples into the cookbook that make use of libraries from haxelib (not in the standard library)?
For example, using the thx.csv library for working with csv files.
Are you allowed to have import inside a class definition, or was that a copy/paste error? I got a compiler error, Unexpected import, using Haxe 3.3.0.
Sources:
Currently, the cookbook is designed to accommodate single entries grouped by tags and categories. This is great for code snippets and small examples.
However, there is no way to effectively group together a series of entries, for instance, that concern the development of a (larger) project. Displaying every series entry in the sidebar would quickly inflate the sidebar and make it hard to navigate.
I would like to discuss the possibility of supporting a system for series. I feel like this is a necessity if bigger examples are to be hosted by the cookbook, such as those that were present in the old Haxe documentation.
Here is a proposal to start things off:
The folder structure might look something like this:
cookbook
+- ...
`- Series
`- my-cool-series
+- my-cool-series.md
+- my-cool-series-1-set-up.md
+- my-cool-series-2-tear-down.md
`- my-cool-series-3-conclusion.md
I'm interested in hearing your thoughts on the matter!
It would be awesome if we can auto deploy this website on Github Pages. Nicolas was ok with this, he will link code.haxe.org to it.
@andyli can you help with this? What do we need?
Everything after the regex literal here is just red:
http://code.haxe.org/category/macros/completion-from-url.html
Trying to understand how to use haxe.macro.Context.onGenerate(types:Array<Type>)
to create custom generators I noticed that the types
parameter comes with a strange order instead of the declaration order (line number) see the output bellow, this make it's usage a bit more involved than if it came ordered by file/line number, also probably in doing a working example several corner cases will surface and internal changes can be made to make life easy for Haxe users.
Would be nice to have an entry in the Code Cookbook
with a simple functional example and I suggest the one bellow as starting point (generate Haxe again for simplicity), any comments/suggestions/improvements are welcome !
final _version = "1.0";
/** Get version string. */
function getVersion(): String {
return _version;
}
enum Color {
Red;
Green;
Blue;
RGB(r: Int, g: Int, b: Int);
}
class Test {
static var _count: Int = 0;
public var name:String;
public var x:Float;
public var y:Float;
public function new(name:String, x:Float, y:Float) {
this.name = name;
this.x = x;
this.y = y;
}
public function toString() : String {
return name + "::" + Std.string(x) + "::" + Std.string(y);
}
}
class TestOnGenerate {
static function main() {
var t = new Test("dad", 1.4, 2.9);
trace(t.toString() + "::" + getVersion());
}
}
#if macro
import haxe.macro.Type;
import haxe.macro.Context;
using haxe.macro.PositionTools;
/**
* Callback on generating code from context
*/
private function mygenerate(types:Array<Type>, filterFileName: String):Void {
var buf = new StringBuf();
for (atype in types) {
// trace(atype);
var aref = atype.getParameters()[0].get();
var apos = Context.getPosInfos(aref.pos);
//trace(apos);
if(filterFileName != null && apos.file != filterFileName) continue;
switch (atype) {
case TMono(t):
trace(t + "::" + aref.pos);
case TEnum(t, params):
var t_ref = t.get();
//trace(t.toString() + "::" + aref.pos + "::" + params.toString());
buf.add('\nenum ${t_ref.name} {\n');
var enumFields = [];
for (efield in t_ref.constructs) {
//trace(efield);
var ebuf = new StringBuf();
ebuf.add('\t${efield.name}');
switch(efield.type) {
case TEnum(_, _): ebuf.add(";\n");
case TFun(args, _):
ebuf.add("(");
for (i in 0...args.length) {
var arg = args[i];
if (i > 0)
ebuf.add(", ");
var type_name = switch(arg.t) {
case TAbstract(t, params): t.get().name;
default:
throw 'Unsupported paramter ${arg.t}';
null;
};
ebuf.add('${arg.name}: ${type_name}');
}
ebuf.add(");\n");
default:
throw 'Unsupported paramter ${efield.type}';
}
enumFields.insert(efield.index, ebuf.toString());
}
for(elm in enumFields) buf.add(elm);
buf.add("}\n");
//trace(buf.toString());
case TInst(t, params):
var t_ref = t.get();
trace(aref.name + "::" + aref.pos /*.getInfos().min*/ + "::" + params.toString());
var classFields = t_ref.fields.get();
buf.add('\nclass ${t_ref.name} {\n');
//trace(classFields);
if(t_ref.constructor != null) trace(t_ref.constructor.get());
for (ifield in classFields) {
trace(ifield);
buf.add('\t${ifield.name};\n');
}
trace(t_ref.statics.get());
buf.add("}\n");
//trace(buf.toString());
case TType(t, params):
trace(aref.name + "::" + aref.pos /*.getInfos().min*/ + "::" + params.toString());
case TFun(args, ret):
trace(args + "::" + aref.pos + "::" + ret);
case TAnonymous(a):
trace(a + "::" + aref.pos);
case TDynamic(t):
trace(t + "::" + aref.pos);
case TLazy(f):
trace(f + "::" + aref.pos);
case TAbstract(t, params):
trace(aref.name + "::" + aref.pos /*.getInfos().min*/ + "::" + params.toString());
}
}
trace(buf.toString());
}
function set_on_generate(?ffname: String) {
haxe.macro.Context.onGenerate(function(types:Array<Type>){mygenerate(types, ffname);});
}
#end
-main TestOnGenerate
--macro MyOnGenerate.set_on_generate("TestOnGenerate.hx")
#--macro MyOnGenerate.set_on_generate()
#-dce full
#-D analyzer_optimize
Output:
haxe "TestOnGenerate.hxml"
MyOnGenerate.hx:58: Test::#pos(TestOnGenerate.hx:16: lines 16-30)::[]
MyOnGenerate.hx:62: {name: new, isFinal: false, namePos: #pos(TestOnGenerate.hx:22: characters 19-22), isPublic: true, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:22: lines 22-26), kind: FMethod(MethNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TFun([{name: name, t: TInst(<...>,[]), opt: false},{name: x, t: TAbstract(<...>,[]), opt: false},{name: y, t: TAbstract(<...>,[]), opt: false}],TAbstract(Void,[])), expr: #fun}
MyOnGenerate.hx:64: {name: name, isFinal: false, namePos: #pos(TestOnGenerate.hx:18: characters 14-18), isPublic: true, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:18: characters 3-26), kind: FVar(AccNormal,AccNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TInst(String,[]), expr: #fun}
MyOnGenerate.hx:64: {name: x, isFinal: false, namePos: #pos(TestOnGenerate.hx:19: characters 14-15), isPublic: true, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:19: characters 3-22), kind: FVar(AccNormal,AccNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TAbstract(Float,[]), expr: #fun}
MyOnGenerate.hx:64: {name: y, isFinal: false, namePos: #pos(TestOnGenerate.hx:20: characters 14-15), isPublic: true, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:20: characters 3-22), kind: FVar(AccNormal,AccNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TAbstract(Float,[]), expr: #fun}
MyOnGenerate.hx:64: {name: toString, isFinal: false, namePos: #pos(TestOnGenerate.hx:27: characters 19-27), isPublic: true, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:27: lines 27-29), kind: FMethod(MethNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TFun([],TInst(String,[])), expr: #fun}
MyOnGenerate.hx:67: [{name: _count, isFinal: false, namePos: #pos(TestOnGenerate.hx:17: characters 14-20), isPublic: false, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:17: characters 3-30), kind: FVar(AccNormal,AccNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TAbstract(Int,[]), expr: #fun}]
MyOnGenerate.hx:58: TestOnGenerate::#pos(TestOnGenerate.hx:32: lines 32-37)::[]
MyOnGenerate.hx:67: [{name: main, isFinal: false, namePos: #pos(TestOnGenerate.hx:33: characters 21-25), isPublic: false, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:33: lines 33-36), kind: FMethod(MethNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TFun([],TAbstract(Void,[])), expr: #fun}]
MyOnGenerate.hx:58: TestOnGenerate_Fields_::#pos(TestOnGenerate.hx:1: character 1)::[]
MyOnGenerate.hx:67: [{name: _version, isFinal: true, namePos: #pos(TestOnGenerate.hx:1: characters 7-15), isPublic: true, isAbstract: false, doc: null, params: [], pos: #pos(TestOnGenerate.hx:1: characters 1-24), kind: FVar(AccNormal,AccNever), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TInst(String,[]), expr: #fun},{name: getVersion, isFinal: false, namePos: #pos(TestOnGenerate.hx:5: characters 10-20), isPublic: true, isAbstract: false, doc: Get version string. , params: [], pos: #pos(TestOnGenerate.hx:5: lines 5-7), kind: FMethod(MethNormal), meta: {get: #fun, remove: #fun, has: #fun, extract: #fun, add: #fun}, overloads: overloads, isExtern: false, type: TFun([],TInst(String,[])), expr: #fun}]
MyOnGenerate.hx:84:
enum Color {
Red;
Green;
Blue;
RGB(r: Int, g: Int, b: Int);
}
class Test {
name;
x;
y;
toString;
}
class TestOnGenerate {
}
class TestOnGenerate_Fields_ {
}
As already established Haxe enums are a form of algebraic data types. In fact, they may even serve as so called generalized algebraic data types - GADTs for short. While for an ordinary enum every constructor yields the same type, with an GADT each constructor may yield a different type.
https://code.haxe.org/category/functional-programming/enum-gadt.html
Mark
Hi I started on improving the webgl triangle example ( just colored triangles yet to tidy up the image one yet ), and have made a start on a tutorial but there is just so much to cover it's tricky to know if I have the patience to try to go into every detail, but it's a start, but I suggest that Codebook has a Intermediate "Graphics" section where I could also add swing, svg, canvas, flash, kha, flambe, flump examples of triangle drawing, rendering an image etc..
I don't know it this quite fits with your vision please let me know if this is useful and worth integration of some form, also maybe if it is then it would be good to continue it separately before forming a pull ?
Best Justin
I think in a macro like this we should also show usage of #if display
, so macro won't call git
for completion.
Sources:
Try opening https://haxefoundation.github.io/code-cookbook/index.html in chrome and behold.
Mixed Content: The page at 'https://haxefoundation.github.io/code-cookbook/index.html' was loaded over HTTPS, but requested an insecure script 'http://haxe.org/js/bootstrap.min.js'. This request has been blocked; the content must be served over HTTPS.
var http = new haxe.Http("https://api.ipify.org?format=json");
http.onData = function (data:String) {
var result = haxe.Json.parse(data);
trace('Your IP-address: ${result.ip}');
}
http.onError = function (error) {
trace('error: $error');
}
http.request();
the above does not work. it throws an error in the most current haxe (2.4.6)
the code below does work. change the " changed to '
now it works and gives the jsonified ip address
I have NO idea what changeing the " to ' made it work.
var http = new haxe.Http('http://api.ipify.org?format=json);
http.onData = function (data:String) {
var result = haxe.Json.parse(data);
trace('Your IP-address: ${result.ip}');
}
http.onError = function (error) {
trace('error: $error');
}
http.request();
Sources:
Sources:
This is not likely the proper way to post this comment, but I am presuming that whomever owns/manages this documentation facility will receive some notification. Hopefully, you will be able to read my comments and then simply delete it so that it won't clutter your work.
I strongly feel the need to comment upon the high quality of the work being shown in the evolution of this Cookbook. I have decades of experience in dealing with the frustrations that arise wherever the documentation of new technology is required. Indeed, since I have spent about 12 hours per day and night for each of the last ten days in trying to get my arms around so many new pieces of technology from the Haxe ecosystem, and since much of that effort has resulted in incomplete and/or out of date snippets of information, that finally coming upon this work has truly been refreshing.
Several key ingredients are necessary to getting tutorial documentation right. The first key ingredient is the absolute understanding that the top-level stake holders must make. Where such stake-holders mostly come from the software engineering ranks, there is all-too-often a failure to understand and a failure to insist upon the timely release of documentation amidst the always-present pressure to release some new block of code. The second key ingredient is recognizing that the old fashioned ability to craft words in well-organized paragraphs never goes away -- the short-hand acronymiphomia that we have as writers of code, can never be used as some sort of a stand-in for quality writing by those dedicated to that profession. The third key ingredient comes from watching how these sorts of on-line references have evolved since the folks at Sun released the first java docs, but especially outstanding has been the manner in which Adobe evolved the living ActionScript documentation repleat with meaningful examples.
You are on the right track with what I have read so far and I hope you will be given the mandate and support to aggressively work towards a higher percentage of the total toolkit being properly documented. The toolkit, of course, has achieved earned respect for what it represents, but unless its key features can be properly conveyed to newcomers, its capture of the marketplace will always remain small. In the final analysis, engineers, marketeers and documentation specialists work together to get on paper and in a few well-contrived graphics the important facts that a user must master in order to move forward in developing applications with that toolkit.
Sources:
Hi Mark!
This example doesn't seem to work with --interp - the observable is never registered.
Works with ordinary neko though. Strange...
/ Jonas
Do we want to set a max width for our code examples? It would be nice to have them properly formatted on an average landscape cellphone screen, but I'm not sure if we would have to make too many concessions for this.
Hi would like to propose one or two additional sections.
"Library/Toolkit Connect"
This will eventually include forums on specific haxe targets if they are formed such as Java, NodeJS, c# etc..., but currently should include "active" groups, a good starter might be these.
Luxe
https://gitter.im/snowkit/public ( there is also a Luxe one but I think this is used more )
Kha
irc://ktxsoftware.com/kha
Openfl
http://community.openfl.org/
Flambe
https://groups.google.com/forum/#!forum/flambe
NME
https://gitter.im/haxenme/nme
Fixel
http://haxeflixel.com/documentation/community/
... probably some more but I am sure libraries / toolkits can suggest for themselves you just need a starting list, I can imagine Heaps, Nape etc.. should be added if they have ones, the important aspect maybe activity, I think it might be very hard to order these by activity but perhaps that would be ideal, certainly it would help new users know which projects to explore, and would be very relatively fair on projects.
Also it would be ideal to work towards a "Community Log"
Ideally it would be amazing to have a collated log of new posts/topics in some form from the Haxe and library forums, but I don't have any code for this it's just an additional suggestion to the Library Connect proposal, and not one I would be able to implement.
Certainly I can look at creating a pull request for "Library/Toolkit Connect" if such a concept seems interesting to reduce the workload on Mark, but maybe you disagree with my logic which I was originally going to put in a haxelang email but decided to post here.
"It would be really nice to maybe go a bit further with the "Connect" section to cover more specific ecosystems where users share promote and discuss Haxe related projects, it's often more worthwhile hanging out on some of these if you want to discuss more specific topics."
Certainly something along these lines might be useful to clarify the section.
All looks good best Justin. :)
Many programming languages split code into two kinds of elements: statements and expressions. Statements perform some action (e.g. if/else) and expressions return values (e.g. a + b).
https://code.haxe.org/category/principles/everything-is-an-expression.html
At the bottom of the page, the link next to "Learn about available global compiler flags here"
http://haxe.org/manual/lf-condition-compilation-flags.html
is broken.
I think the correct link is:
http://haxe.org/manual/compiler-usage-flags.html
Sources:
Article: https://code.haxe.org/category/principles/null-safety.html
"Created: Jan 02, 2018 Last modified: Nov 16, 2017"
Actual history: https://github.com/HaxeFoundation/code-cookbook/commits/master/assets/content/cookbook/Principles/Null-safety.md
Code to blame:
code-cookbook/src/util/GitUtil.hx
Lines 13 to 37 in fceab13
Some tag to easily embed try haxe snippets.
How do we want to structure all snippets, which categories do we need?
If you are in the mood for writing but don't know what, then you can use this list:
macro --include
to bundle external js filesBtw, these titles are suggestions. This list will get updated over time.
anniz on #haxe posted a fun little example of a vga text renderer:
class Main {
static var Font = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7E,0x81,0xA5,0x81,0xBD,0x99,0x81,0x7E,
0x7E,0xFF,0x00,0xFF,0xC3,0xE7,0xFF,0x7E,
0x6C,0xFE,0xFE,0xFE,0x7C,0x38,0x10,0x00,
0x10,0x38,0x7C,0xFE,0x7C,0x38,0x10,0x00,
0x38,0x7C,0x38,0xFE,0xFE,0x92,0x10,0x7C,
0x00,0x10,0x38,0x7C,0xFE,0x7C,0x38,0x7C,
0x00,0x00,0x18,0x3C,0x3C,0x18,0x00,0x00,
0xFF,0xFF,0xE7,0xC3,0xC3,0xE7,0xFF,0xFF,
0x00,0x3C,0x66,0x42,0x42,0x66,0x3C,0x00,
0xFF,0xC3,0x99,0xBD,0xBD,0x99,0xC3,0xFF,
0x0F,0x07,0x0F,0x7D,0xCC,0xCC,0xCC,0x78,
0x3C,0x66,0x66,0x66,0x3C,0x18,0x7E,0x18,
0x3F,0x33,0x3F,0x30,0x30,0x70,0xF0,0xE0,
0x7F,0x63,0x7F,0x63,0x63,0x67,0xE6,0xC0,
0x99,0x5A,0x3C,0xE7,0xE7,0x3C,0x5A,0x99,
0x80,0xE0,0xF8,0xFE,0xF8,0xE0,0x80,0x00,
0x02,0x0E,0x3E,0xFE,0x3E,0x0E,0x02,0x00,
0x18,0x3C,0x7E,0x18,0x18,0x7E,0x3C,0x18,
0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00,
0x7F,0x00,0x00,0x7B,0x1B,0x1B,0x1B,0x00,
0x3E,0x63,0x38,0x6C,0x6C,0x38,0x86,0xFC,
0x00,0x00,0x00,0x00,0x7E,0x7E,0x7E,0x00,
0x18,0x3C,0x7E,0x18,0x7E,0x3C,0x18,0xFF,
0x18,0x3C,0x7E,0x18,0x18,0x18,0x18,0x00,
0x18,0x18,0x18,0x18,0x7E,0x3C,0x18,0x00,
0x00,0x18,0x0C,0xFE,0x0C,0x18,0x00,0x00,
0x00,0x30,0x60,0xFE,0x60,0x30,0x00,0x00,
0x00,0x00,0xC0,0xC0,0xC0,0xFE,0x00,0x00,
0x00,0x24,0x66,0xFF,0x66,0x24,0x00,0x00,
0x00,0x18,0x3C,0x7E,0xFF,0xFF,0x00,0x00,
0x00,0xFF,0xFF,0x7E,0x3C,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x3C,0x3C,0x18,0x18,0x00,0x18,0x00,
0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,
0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00,
0x18,0x7E,0xC0,0x7C,0x06,0xFC,0x18,0x00,
0x00,0xC6,0xCC,0x18,0x30,0x66,0xC6,0x00,
0x38,0x6C,0x38,0x76,0xDC,0xCC,0x76,0x00,
0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,
0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x00,
0x60,0x30,0x18,0x18,0x18,0x30,0x60,0x00,
0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,
0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30,
0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,
0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,
0x7C,0xCE,0xDE,0xF6,0xE6,0xC6,0x7C,0x00,
0x30,0x70,0x30,0x30,0x30,0x30,0xFC,0x00,
0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00,
0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00,
0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x1E,0x00,
0xFC,0xC0,0xF8,0x0C,0x0C,0xCC,0x78,0x00,
0x38,0x60,0xC0,0xF8,0xCC,0xCC,0x78,0x00,
0xFC,0xCC,0x0C,0x18,0x30,0x30,0x30,0x00,
0x78,0xCC,0xCC,0x78,0xCC,0xCC,0x78,0x00,
0x78,0xCC,0xCC,0x7C,0x0C,0x18,0x70,0x00,
0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00,
0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30,
0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x00,
0x00,0x00,0x7E,0x00,0x7E,0x00,0x00,0x00,
0x60,0x30,0x18,0x0C,0x18,0x30,0x60,0x00,
0x3C,0x66,0x0C,0x18,0x18,0x00,0x18,0x00,
0x7C,0xC6,0xDE,0xDE,0xDC,0xC0,0x7C,0x00,
0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,
0xFC,0x66,0x66,0x7C,0x66,0x66,0xFC,0x00,
0x3C,0x66,0xC0,0xC0,0xC0,0x66,0x3C,0x00,
0xF8,0x6C,0x66,0x66,0x66,0x6C,0xF8,0x00,
0xFE,0x62,0x68,0x78,0x68,0x62,0xFE,0x00,
0xFE,0x62,0x68,0x78,0x68,0x60,0xF0,0x00,
0x3C,0x66,0xC0,0xC0,0xCE,0x66,0x3A,0x00,
0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0x00,
0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,
0x1E,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,
0xE6,0x66,0x6C,0x78,0x6C,0x66,0xE6,0x00,
0xF0,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,
0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0x00,
0xC6,0xE6,0xF6,0xDE,0xCE,0xC6,0xC6,0x00,
0x38,0x6C,0xC6,0xC6,0xC6,0x6C,0x38,0x00,
0xFC,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,
0x7C,0xC6,0xC6,0xC6,0xD6,0x7C,0x0E,0x00,
0xFC,0x66,0x66,0x7C,0x6C,0x66,0xE6,0x00,
0x7C,0xC6,0xE0,0x78,0x0E,0xC6,0x7C,0x00,
0xFC,0xB4,0x30,0x30,0x30,0x30,0x78,0x00,
0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xFC,0x00,
0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x00,
0xC6,0xC6,0xC6,0xC6,0xD6,0xFE,0x6C,0x00,
0xC6,0xC6,0x6C,0x38,0x6C,0xC6,0xC6,0x00,
0xCC,0xCC,0xCC,0x78,0x30,0x30,0x78,0x00,
0xFE,0xC6,0x8C,0x18,0x32,0x66,0xFE,0x00,
0x78,0x60,0x60,0x60,0x60,0x60,0x78,0x00,
0xC0,0x60,0x30,0x18,0x0C,0x06,0x02,0x00,
0x78,0x18,0x18,0x18,0x18,0x18,0x78,0x00,
0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x78,0x0C,0x7C,0xCC,0x76,0x00,
0xE0,0x60,0x60,0x7C,0x66,0x66,0xDC,0x00,
0x00,0x00,0x78,0xCC,0xC0,0xCC,0x78,0x00,
0x1C,0x0C,0x0C,0x7C,0xCC,0xCC,0x76,0x00,
0x00,0x00,0x78,0xCC,0xFC,0xC0,0x78,0x00,
0x38,0x6C,0x64,0xF0,0x60,0x60,0xF0,0x00,
0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0xF8,
0xE0,0x60,0x6C,0x76,0x66,0x66,0xE6,0x00,
0x30,0x00,0x70,0x30,0x30,0x30,0x78,0x00,
0x0C,0x00,0x1C,0x0C,0x0C,0xCC,0xCC,0x78,
0xE0,0x60,0x66,0x6C,0x78,0x6C,0xE6,0x00,
0x70,0x30,0x30,0x30,0x30,0x30,0x78,0x00,
0x00,0x00,0xCC,0xFE,0xFE,0xD6,0xD6,0x00,
0x00,0x00,0xB8,0xCC,0xCC,0xCC,0xCC,0x00,
0x00,0x00,0x78,0xCC,0xCC,0xCC,0x78,0x00,
0x00,0x00,0xDC,0x66,0x66,0x7C,0x60,0xF0,
0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0x1E,
0x00,0x00,0xDC,0x76,0x62,0x60,0xF0,0x00,
0x00,0x00,0x7C,0xC0,0x70,0x1C,0xF8,0x00,
0x10,0x30,0xFC,0x30,0x30,0x34,0x18,0x00,
0x00,0x00,0xCC,0xCC,0xCC,0xCC,0x76,0x00,
0x00,0x00,0xCC,0xCC,0xCC,0x78,0x30,0x00,
0x00,0x00,0xC6,0xC6,0xD6,0xFE,0x6C,0x00,
0x00,0x00,0xC6,0x6C,0x38,0x6C,0xC6,0x00,
0x00,0x00,0xCC,0xCC,0xCC,0x7C,0x0C,0xF8,
0x00,0x00,0xFC,0x98,0x30,0x64,0xFC,0x00,
0x1C,0x30,0x30,0xE0,0x30,0x30,0x1C,0x00,
0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,
0xE0,0x30,0x30,0x1C,0x30,0x30,0xE0,0x00,
0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0x00
];
public static function PcRenderLetter(charCode:Int, colorOn:Int, colorOff:Int, baseRow:Int, baseCol:Int, targetBMD:flash.display.BitmapData) {
var baseIndex = charCode << 3;
for (curRow in 0...8) {
var rowBits = Font[baseIndex + curRow];
for (curCol in 0...8) {
targetBMD.setPixel32(baseCol+curCol, baseRow+curRow, (((rowBits << curCol) & 0x80) == 0x80)? colorOn : colorOff);
}
}
}
public static function main() {
var bmd = new flash.display.BitmapData(320, 200, false, 0);
var bm = new flash.display.Bitmap(bmd);
var msgLines = [
"256KB OK",
"",
"",
"The current date is: Thu 04/20/1989",
"Enter new date: (mm-dd-yy)",
"",
"The current time is: 03:14:15.9",
"Enter new time:",
"",
"",
"MS-DOS 2.04",
"",
"A:\\>"
];
for (j in 0...msgLines.length) {
var msgStr = msgLines[j];
for (i in 0...msgStr.length) {
var c = msgStr.charCodeAt(i);
PcRenderLetter(c, 0xa0a0a0, 0, (j>>1) + (j<<3), (i>>1) + (i<<3), bmd);
}
}
flash.Lib.current.addChild(bm);
}
}
Maybe we could port it to canvas?
Table of contents -> Beginner -> Pattern matching -> Matching on structures:
If we would like to trace the age of the person in the first case we could have written
case { age: age > 50 => true}: trace('found somebody older than 50, the age is $age')
.
does not evaluate as expected.
To get the expected result it should be written something like:
case {age: age} if (age > 50): trace('found somebody older than 50, the age is $age.');
Especially with the new feature that doesnt require to create a class first like:
http://try.haxe.org/#92a4D
The examples should trace something if possible.
I wrote this article, which was merged some time ago after edits by @markknol , but I just realize now that the online article doesn't credit me at all. I believe it should list me as author, or at least contributor.
We should update this page to remove mention of minimingw as it is outdated:
In my opinion the code is a bit hard to read. I think it is a combination of the font and a somewhat small font size.
Here's a concrete example from the Cookbook where the text is big and clear but the code is lacking in clarity.
Here's an example where I've tried substituting the code font with another. I've used the Inconsolata font with a size of 15px.
In my opinion this makes for clearer code and aligns better with the text.
This macro function automatically assigns parameters of method to local variables.
https://code.haxe.org/category/macros/add-parameters-as-fields.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.