Nightmares - a dynamic dream testing utility

Posted by Julien on August 31st, 2008

Nightmares (Build 1.0.173) - Dynamic dream testing utilityNightmares is a small application created to test dynamic dreams. It runs them in a window,
allowing you to debug them easily or to record a preview video.

You can set the window size (default is 800×600), chose an output file and FourCC code for the output video.

It currently only runs unprotected dreams: the dreams that come with DeskScapes will work, but any dynamic dream that you bought won’t.

See the readme file for command line switches.

Download test build here.

Update: Added preliminary support for protected Dreams (you will have to activate them first through DeskScapes).

DXCanvas - a canvas implementation for DesktopX

Posted by Julien on August 26th, 2008

Every major browser has support for it, Yahoo! Widgets has support for it, how come there isn’t something for DesktopX?

Enter DXCanvas, a DesktopX drawing plugin that implements the Canvas spec (plus some DesktopX-specific additions).

How does it work

Configure Canvas Plugin

DXCanvas is a DesktopX drawing plugin, which means it takes over drawing for the object it is associated to.

In the configuration, you can set the initial size for the canvas. By default, the drawing surface size will be 300×150. You can also specify whether you want the surface to be transparent and show the other objects or windows under it, or opaque.

A canvas object is made available to scripting. To be able to draw on the canvas, you need to request a context. This is done by calling getContext(type) on the canvas object. The only supported type right now is "2d".

See the list of functions in the implementation section. Note that some are slightly different from the Canvas specification, or are completely new. This is to adjust to differences in what is possible in a browser and in DesktopX.

Canvas Controller Widget

Preview I’ve made a little widget to make testing easier. It loads a list of scripts from a user-defined folder and allows you to switch between them. It support scripts written in both JScript and VBScript.

It basically associate the script to an object having the DXCanvas plugin as a capability.

Two functions are required for the scripts to work: Object_OnScriptEnter() and Object_OnScriptExit().

The canvas size is reset its default size of 300×150 when switching between scripts, so make sure to set it to the required size if needed by your script.

To add a new script to the list, create a new .js or .vbs file in a folder and select this folder in the widget preferences. A few test scripts are included in the Script folder.

It also support subfolders (only 1 folder deep), so you can organize your scripts in subfolders.

How to help

Download the Canvas Controller widget and start creating scripts!

What to look for

  • strange behavior: colors are not right, context is not saved or restored correctly, etc.
  • the output from a script is different in Firefox or Safari
  • crashes or memory leaks (there are a least a few :P)

What is broken/not working properly

  • Drawing still flicker (not as badly as before)
  • This is a DEBUG build, so it’s going to be slower than normal

Links

Changelog

1.0 Build 225:

  • Fixed large canvas objects taking a lot of CPU
  • Log is always enabled

1.0 Build 217

  • Fixed drawing being incomplete in some cases
  • Added workaround for pink color drawing transparent. DesktopX always use pink to draw transparent surfaces, even in per-pixel mode. rgb(255, 0, 255) will be changed to rgb(255, 1, 255)

1.0 Build 214

  • Added per-object log files
  • Added more log info when creating a new context object

1.0 Build 211

  • Added support for % in rgb/rgba colors
  • Added "transparent" color (equivalent to "rgba(0,0,0,0)")
  • Added SVG colors "darkgrey", "darkslategrey", "dimgrey", "grey", "lightgray", "lightslategrey" and "slategrey"
  • Zero size canvas is allowed
  • Properly share canvas state (context style stack was not properly shared before)
  • DrawImage and DrawImageRegion check for negative width and height and adjust the coordinates
  • Only match full color strings
  • Accept rgb values outside [0;255] and clamp the value properly
  • Clamp alpha and use premultiplied color values when painting with alpha (still somewhat wrong)
  • Fixed leak and crash with CanvasImageData & CanvasPixelArray
  • Fixed crash with invalid parameters in createImageData and getImageData
  • Zero-length line gradients should paint nothing
  • Radial gradients with the same start and end circle should paint nothing
  • Image data now accepts negative width and height (you get the untransformed data for the resulting rectangle)
  • arc() with zero radius draws a line to the start point.
  • arcTo() has no effect if the context has no subpaths or if P0 = P1
  • arcTo() draws a straight line to P1 if P1 = P2 or if radius = 0
  • bezierCurveTo() has no effect if the context has no subpaths
  • lineTo() has no effect if the context has no subpaths
  • quadraticCurveTo() has no effect if the context has no subpaths
  • Updated cairo, pixman and pango libraries

1.0 Build 201

  • Added hsl/hsla color parsing
  • Added some logging (DXCanvas.log in object directory)
  • Fixed text stroking always drawing at position (0,0)
  • Fixed text baseline being off by the text height

1.0 Build 191

  • Added redraw calls buffering (less flickering)
  • Added debugMode attribute to canvas. In debug mode, passing invalid parameters will result in an error being raised instead of the invalid value being silently ignored.
  • No longer returns errors when passing invalid parameters to a lot of functions (as specified in Canvas specification)
  • CanvasPixelArray.XXX6(index, value) now takes an int instead of a char and will clamp that value to [0;255]

1.0 Build 180

  • Implemented toImage
  • Implemented createImageData, getImageData and putImageData
  • Added canvas support to createPattern, drawImage and drawImageRegion
  • Fixed createPattern, drawImage and drawImageRegion not working in VBScript
  • Fixed createPattern, drawImage and drawImageRegion not making a copy of the source image or canvas
  • Fixed drawImageRegion using wrong default values for dw and dh
  • Fixed drawImageRegion not creating a new path, resulting in image "corruption"

1.0 Build 168

  • Implemented font attribute setter/getter
  • Implemented fillText, strokeText and measureText (using Pango)
  • Implemented arcTo (using patch from Behdad Esfahbod)
  • Fixed image loading (SD_LOAD_IMAGE seems to be corrupting some images…)

1.0 Build 159

  • Implemented textAlign and textBaseline attributes setters/getters  (not used yet)
  • Implemented createPattern, loadImage, drawImage and drawImageRegion
  • Update to cairo 1.7.4 (better support for text)
  • Statically linked to cairo lib (no need for cairo.dll anymore)

1.0 Build 149

  • First test version

Download

You can download a test version here. It only includes the Canvas Controller widget for now. Please do not use the DXCanvas plugin in your own objects and widgets yet. This version of the plugin will expire on the 10/01/2008.

Implementation

Under the hood, it’s using Cairo, a 2D vector graphics library that also powers the Mozilla and Yahoo Widgets implementations. Right now, the Cairo library is dynamically loaded at runtime, but I hope to have it statically linked into the plugin for the final version.

Here is a list classes with their attributes and functions and the state of their implementation

Canvas

Name Implemented Comment
width YES  
height YES  
debugMode YES Invalid input will raise an error instead of being ignored.
getContext(type) YES  
toImage(path) YES Saves to a PNG file (replaces toDataURL)

 

CanvasRenderingContext2D

Name Implemented Comment
globalAlpha YES  
globalCompositeOperation YES  
strokeStyle YES  
fillStyle YES  
lineWidth YES  
lineCap YES  
lineJoin YES  
miterLimit YES  
shadowOffsetX YES Shadows are not implemented yet.
shadowOffsetY YES Shadows are not implemented yet.
shadowBlur YES Shadows are not implemented yet.
shadowColor YES Shadows are not implemented yet.
font YES  
textAlign YES  
textBaseLine YES Hanging and ideographic baselines are treated as alphabetic.
canvas YES  
save YES  
restore YES  
scale(x, y) YES  
rotate(angle) YES  
translate(x, y) YES  
transform(m11, m12, m21, m22, dx, dy) YES  
setTransform(m11, m12, m21, m22, dx, dy) YES  
createLinearGradient(x0, y0, x1, y1) YES  
createRadialGradient(x0, y0, r0, x1, y1, r1) YES  
createPattern(input, repeat) YES  
clearRect(x, y, w, h) YES  
fillRect(x, y, w, h) YES  
strokeRect(x, y, w, h) YES  
beginPath YES  
closePath YES  
moveTo(x, y) YES  
lineTo(x, y) YES  
quadraticCurveTo(cpx, cpy, x, y) YES  
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) YES  
arcTo(x1, y1, x2, y2, radius) YES  
rect(x, y, width, height) YES  
arc(x, y, radius, startAngle, endAngle, anticlockwise) YES  
fill() YES  
stroke() YES  
clip() YES  
isPointInPath(x, y) YES  
fillText(text, x, y) YES  
strokeText(text, x, y) YES  
measureText(text) YES  
loadImage(path) YES  
drawImage(input, dx, dy, dw, dh) YES  
drawImageRegion(input, sx, sy, sw, sh, dx, dy, dz, dh) YES  
createImageData(sw, sh) YES  
getImageData(sx, sy, sw, sh) YES image data uses the BGRA format
putImageData(imageData, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight) YES  

 

Gradient

Name Implemented Comment
addColorStop(offset, color) YES  

 

ImageData

Name Implemented Comment
width YES  
height YES  
data YES  

 

PixelArray

Name Implemented Comment
length YES  
XXX5(index) YES  
XXX6(index, value) YES  

 

TextMetrics

Name Implemented Comment
width YES  

TestDream Application

Posted by Julien on July 30th, 2008

Progress !

WaterColorOvals 

WaterDreamBouncingBox

Still some bugs with the Bouncing Box sample, but it’s getting there. Now let’s proxy some dlls :D

Flurry Update (1.3.1)

Posted by Julien on July 10th, 2008

Flurry EditorThe biggest new feature is the furry editor. It allows you to design your own flurries and easily share them with your friends.

I’ve also added an UI for assigning per-monitor flurries. You can now have a different flurry on each of your monitors.

It has an updated configuration UI that exposes some existing options: an FPS indicator, the possibility to use a "Block Mode" or a "Whiteout Mode" and a way to shrink the flurry window to use only a percentage of the fullscreen window.

Under the hood, there has been quite a few changes with some heavy refactoring to prepare for the flurry editor.

Download from Wincustomize or Download from this site

Full changelog:

Version 1.3.1 Build 41 (07/21/08)
    - Added per-monitor flurries
        * Separated global preset and per-monitor preset
        * Simple UI for assigning flurries to monitors
    - Added flurry editor
        * Presets are saved directly after creation/modification. Deletion is effective when closing the main dialog.
    - Bug fixed
        * Preset names were not stored correctly in registry
        * Fixed deletion of preset (UI was not updated correctly)
        * Crash if Flurry wasn't installed before on the computer
Version 1.3.0 Build 26 (08/10/08)
   - UI Changes
     * Moved credits to About window
     * Added UI for shrink percentage & FPS indicator
       (only in single-buffer mode)
     * Added UI for Block & Whiteout modes
   - Editor
     * Added new/edit/delete buttons
     * Added Editor dialog (not yet functional)
   - Refactoring of code
     * separated settings in a class (preparing for per-monitor flurries)
     * Removed some global variables
     * cleanup/rename: all classes are now in the Flurry namespace
     * Updated Spec class (copy constructor, misc. updates) in preparation
       for editor
   - Bug fixed
     * Preview was not showing the selected preset correctly	 

Valentine Dream released!

Posted by Julien on February 8th, 2008

Valentine Heart You can download it either from Wincustomize or directly from here.

Changes from the previous version:

  • New “Heart” particle texture
  • Blur is disabled by default (only for first time install)
  • Toned down the blurring   
  • Fixed configuration window (no more reloading of the Dream on configuration change)
  • Fixed reloading of textures
  • Fixed behavior on higher quality settings
  • Fixed crash in update when the dream was not starting correctly

Valentine’s Dynamic Dream Progress

Posted by Julien on February 5th, 2008

Valentine Dream Configuration Window

Since the last update, most of the work has been directed towards the configuration UI. Loading and saving settings is now fully implemented. I also added a slider to modify the size of the particles.

What’s not working correctly yet:

  • Applying a new configuration is causing the dream to reset.
  • The colorize shader still needs some work to make it use the particle color (the color is hard-coded right now).
  • More particle textures are needed
  • The colors need to be tweaked
  • The "scaling" code (to adapt to the different quality settings) is not working properly.
  • A few potential bugs in the config code :)

You can download a zip file containing the dll files and the resources, as well as a test program named TestDream that will load the dream inside it’s own window. Simply open a command prompt and launch it with "TestDream.exe Valentine32.dll".

There is also a .Dream file inside, but remember that it hasn’t be tested extensively, so use it with caution (make sure to take a look at the readme file).

Download: Valentine Dream Test Build

Valentine Red Valentine Rose

First look at the Valentine Dream

Posted by Julien on February 2nd, 2008

Configure Valentine DreamHere we go: a very crude version of the configuration UI and two screenshots of the dream (with and without a background).

The configuration is loaded from the registry at startup (and initialized if the dream is started for the first time). You can tweak it by changing the registry keys as the UI is not functional at the moment.

Once I have the config UI working I will make a test build available (probably not a .Dream at first) so that you can play with it a little :)

(Background picture is Valentine Favorites by craftilyeverafter - Particle tutorial by Almar Joling was a great help)

 

Preview Preview2

Valentine Day Dynamic Dream

Posted by Julien on February 1st, 2008

Sketch DreamFor valentine day, I decided to create a new dynamic dream: it will be an "animated" heart using particles. Time is limited, so I’m doing something simple. You will be able to tweak some settings such as change the color & background, but most things will be hard-coded.

It will use some particle system to create the heart itself. You will be able to change the color and texture used for the particles. The background will be chosen among a few different pictures, with a shader applied for blur & coloration.

Things to do:

  • load/save configuration
  • configuration UI
  • Particle "engine"
  • Background, with pixel shader for color & blur

Sketch ConfigThe plan is to get a first test build as soon as possible to get some feedback, with a pre-release build on February 8 for final tweaking. I expect to make a final release on February 12.

I need to find a few nice backgrounds (flick is my friend here :D). Color selection for the heart will probably be limited to magenta and blue, with 2/3 different particle textures.

As you can see from the two pictures, I’m not really good at sketching :) I will try to get some screenshots of the real UI soon, so you can get a better idea of how it will look like.

BTW, for people wanting to create dynamic dreams, I can’t really release any source code right now, but you can start by downloading the December 2006 Microsoft DirectX SDK (the version is important!). Creating dynamic dreams is a lot like creating screensavers: get the CD3DScreensaver class that is part of DXUtil and start hacking on it. Converting that work to a dynamic dream should be relatively straightforward once the Dream SDK is released.

Dynamic Dreams (in construction)

Posted by Julien on January 22nd, 2008

PlaneStateAfter a few weeks building some tools to help me develop and debug dynamic dreams more easily, I’m back to  working on the dreams themselves. I have six dynamic dreams about to go into testing. There is still quite a lot of work to do before a public release, but they are kind of usable and shouldn’t crash explorer randomly :)

The most visible thing lacking is a proper configuration UI. Most of the settings are currently either hard-coded or read from a XML file (instead of the registry).

Those dreams are ports of XboxMediaCenter screensavers. Those are licensed under the GPL, so all source code will be available with the public release.

There are other screensavers in the collection, but they are not yet ready for testing. I will probably not release all of them (some do not make good dreams or are too hard to port).

Here is a description of the Dreams:MatrixTrails

  • Asteroids: a simple asteroids game simulation (note: the IA is not really good at the game…).
  • BioGenesis: this dream implements a ‘game of life’ simulation. Not spectacular, but kind of mesmerizing to look at :)
  • MatrixTrails: the famous matrix letter effect. Really nice one!
  • PingPong: the pong game (without score)
  • PlaneState: this one is an adaptation of the PlaneState Screensaver. The different configurations are hard-coded and chosen randomly on startup.
  • Stars: moving through a star field. A great demo, but probably not recommended for everyday use.
BioGenesis Asteroids
PingPong Stars

Don’t hold you breath though, they probably won’t be released publicly until Stardock makes the Dream SDK available.

DreamBuilder - A command-line Dream builder

Posted by Julien on January 21st, 2008

If you have tried to make Dreams in the past, you have been using DreamMaker. This application allows you to take a video file (or several of them in case of a trigger-based Dream) and "compile" it into a .Dream file. This Dream file also contains other information such as the name of the author, a website URL, copyright and permissions info, and a preview image.

MatrixTrails.xml - Notepad2One of the current limitations of DreamMaker is the lack of a save/load mechanism, requiring you to retype everything each time you want to create a new Dream (or update an existing one). While this might not be a big deal with video and trigger-based Dreams, it begins to be a real pain the moment you start creating dynamic Dreams (even more so when you have 8 or 10 of them in development/testing at the same time).

Enter DreamBuilder: a command line tool to build Dreams. It uses a simple XML configuration file to load the info needed to build a Dream file. No more re-typing ! Now you can have the Dream creation cleanly integrated into you build process.

DreamBuilder is using the DreamMaker.dll file (part of the DreamMaker distribution) under the hood to create the Dream file, so the Dream files created will be the same that DreamMaker would have created. Error messages that DreamMaker normally shows are redirected to the console.

Pre-requisites:

Usage:

DREAMBUILDER inputFile [/O<outputDirectory>] [/D<variable>=<value>]

    inputFile             Path the dream definition file
    /O<outputDirectory>   Path to the output directory
    /D<variable>=<value>  Defines a variable to be replaced in the XML configuration file.
                          Several such variables can be defined. 

By default, the Dream file will be created in the current directory, but you can specify an output directory (such as the default Dream directory in "My Documents/Stardock/Dreams")

Configuration file:

Here is the example configuration file (included in the distribution).

<?xml version="1.0" encoding="utf-8" ?>
<dream>
    <!-- Dream name - max size: 100 characters -->
    <name></name>
    <!-- Dream description - max size: 600 characters -->
    <description></description>
    <!-- Author name - max size: 100 characters -->
    <author></author>
    <!-- Author url - max size: 200 characters -->
    <url></url>
    <!-- Dream copyright information (optional) - max size: unknown -->
    <copyright></copyright>
    <!-- Dream permissions information (optional) - max size: unknown -->
    <permissions></permissions>

    <!-- full/relative path to preview file - max size: 256x256 - BMP, JPG, JPEG or PNG only -->
    <preview></preview>

    <!-- 3 possibilities: video / trigger / dynamic (if more than one is defined, the first one found is used, others are ignored) -->
    <data>

        <!-- Video dream - full/relative path to video file - max size: 150MB - AVI, MPG, MPEG or WMV only -->
        <video></video>

        <!-- Triggered video dream - type: only "time" is allowed at the moment-->
        <triggers type="time">
            <!-- Trigger definition - at least two different triggers need to be defined -->
            <trigger>
                <!-- Time to trigger the video - in hh:mm:ss format  -->
                <time></time>
                <!-- full/relative path to the file - max size: 150MB - AVI, MPG or WMV only -->
                <path></path>
            </trigger>
        </triggers>

        <!-- Dynamic Dream -->
        <dynamic>
            <!-- Path to 32-bit dynamic dream dll -->
            <dll32></dll32>
            <!-- Path to 64-bit dynamic dream dll -->
            <dll64></dll64>
            <!-- Additional content (optional) - max number of files: 150 -->
            <resources>
                <resource>
                    <!-- full/relative path to the file -->
                    <file></file>
                    <!-- target path (relative to the root dream folder) -->
                    <path></path>
                </resource>
            </resources>
        </dynamic>

    </data>

</dream>

DreamBuilder is checking the XML configuration file against an XML Schema, so it will tell you if there is an error in your configuration (but the message might be a bit cryptic).

Visual Studio 2005 Command PromptDreamBuilder allows you to use relative paths when defining the files to use. By default, it will look for the files relative to the current directory.

This might be a problem if you are executing it from another folder that the one containing the files. This is why I introduced variable replacement: it provides a way to dynamically replace content in the configuration file. I use it for path handling, but you can also use it for other things such as adding a version number to the dream name.

The replacement step is happening before the file is parsed, so you can go crazy if you want, and generate the resource list at compile time for example.

You can have as many variables as you want (simply by adding another variable definition to the command line). To define a variable "name" with the value "Julien", you use the following define: "/Dname=Julien". You can then add a new variable to the XML configuration file: $name$. DreamBuilder will warn you if a variable exists without a substitution.

Example:

As an example, here is the config file I use for the MatrixTrails dynamic Dream:

<?xml version="1.0" encoding="utf-8" ?>
<dream>
    <name>MatrixTrails</name>
    <description>Matrix Trails Dream</description>
    <author>Julien Templier</author>
    <url>http://julien.wincustomize.com/</url>
    <copyright>Copyright (c) 2008, Julien Templier[...]</copyright>
    <permissions>This program is free software; you can redistribute it and/or [...]</permissions>

    <preview>$resdir$/MatrixTrails.png</preview>

    <data>
        <dynamic>
            <dll32>$builddir$/MatrixTrails32.dll</dll32>
            <dll64>$builddir$/MatrixTrails64.dll</dll64>

            <resources>
                <resource>
                    <file>$resdir$/MatrixTrails.tga</file>
                    <path>resources</path>
                </resource>
            </resources>
        </dynamic>
    </data>

</dream>

You can see all the files have a variable at the beginning of the path. Those will be replaced when the Dream is built.

In Visual Studio, I then added a post-build step calling DreamBuilder that takes care of defining the right variables:

DreamBuilder $(ProjectDir)/Resources/$(ProjectName).xml /O$(TargetDir) /Dresdir=$(ProjectDir)/Resources /Dbuilddir=$(TargetDir)

That way, each time a build succeeds, a Dream is generated that can be easily tested & distributed.

Download:

DreamBuilder is currently available as a zipped file (to be extracted to the directory of you choice). You might want to add it to your path to be able to call it from anywhere.

DreamBuilder (ZIP)

A MSI file is planned that will take care of adding the installation folder to the path.