Archive for the ‘Samples’ Category

Posix Regex

Wednesday, March 12th, 2008

Hi there!

I’m Redj, Ecere Contributor. :) This is my first post and I hope to be posting more and more as I have interesting news to report or cool code snippets like I have today.

Here is an early implementation of a Regex class the ecere way…

Download Regex.ec

Just add Regex.ec to your project and use it as follows:


import "Regex"

void TestRegex()
{
   char * result;
   Regex regex { "[abc][xyz]", true };
   if((result = regex.Match("match me aZ I am")))
      printf("we have a match: %s\n", result);
}

Note that at line 6, “[abc][xyz]“ sets the regex property and true sets the caseInsensitive property.

If you need the POSIX Regex extended syntax, just set the extendedSyntax property to true. Do the same for the newLineException, lineStartException and lineEndException properties if you need them. If you don’t know what they are, you probably don’t need them.

For Windows users: Note that in order to use this class, you will need to download the user contributed mingw regex library mingw-libgnurx-2.5.1-bin.tar.gz and extract it’s contents (libgnurx-0.dll) to Ecere SDK’s bin directory. You will also need this regex.h file to be present in mingw’s include directory.

For Linux users: Make sure your include paths are correctly set to find regex.h and you should be all set.

If you need assistance or would like to give use feedback, join us in #ecere on freenode.net or visit the forums and wiki (see links in the Ecere section of the sidebar).

That’s it for now. Enjoy!

Posted by Redj

Windowless Desktop Toys, Chess & New SDK for Linux (0.41.17.5)

Wednesday, November 14th, 2007

After much wrestling with X, XRender, XShape & GLX, here they are: the Linux versions of the desktop toys.

Here is a screen shot of them in action:

Linux Toys Shot

The Linux Ecere SDK now supports alpha blending window contents through the “bool alphaBlend” property of the window class. When set to true, the window has its own alpha channel which a proper composite manager such as xcompmgr will happily use to make parts of the window translucent or completely transparent. The SDK will also automatically redefine the input region through the XShape extension so that clicks in transparent areas will click through on the underneath windows.

To render non opaque contents on the window, use a value smaller than 255 for the surface’s foreground and background while calling drawing methods (Proper support through both XRender and OpenGL in this release). You can also use a value between 0 and 1.0 (exclusively) for the window’s opacity to automatically have a translucent background drawn for you.

A few fixes were also done to the X OpenGL driver and it should now properly run anti-aliased if possible. Here is a binary version of Chess for those who do not yet wish to install the SDK.

Feel free to let me know if you get these running nicely on your system, and I’ll appreciate if you send me nice screen shots of those in action on your own favorite Linux desktop environment. The above screenshot is lacking hiragana characters on the cube as a CJK enabled Unicode font was not found by fontconfig. Ensure you have one of those (see previous post) if you wish to see them.

Download Ecere SDK 0.41.17.5 for Linux (obsolete)

Download Ecere Chess for Linux

Download Windowless Hiragana Cube and Color Spheres for Linux

Ecere Chess Source Code

Monday, October 22nd, 2007

3D Chess Here I just decided to share the source code for Ecere Chess with the world…

The 3D chess set is looking quite good, modeled by my friend Gaetan Loyer.
Ecere Chess has a very simple AI, seeing 2 moves of each players ahead…

It doesn’t know anything about openings or endings.

But it will probably still kick your a**.

Here’s the source code.

Linux Executable

Windows Executable

Some 3D Desktop Toys

Sunday, October 21st, 2007

Searching for what could make a nice little demo of Unicode in 3D, here’s what I came up with:

Hiragana Cube Cube toys to learn hiragana :)

(Source code Windows executable – rar’ed / Linux executable – tar’ed)
(Note: This looks for the Arial Unicode MS font, if it can’t find it you won’t see the hiragana)

I made it float on the Windows desktop using alpha-blending…

Then I got carried away and wanted to see how easy it would be to make something similar to Corey Tabaka‘s color spheres:

Color Spheres (Source code / Windows executable – rar’ed / Linux executable – tar’ed)