aftcast

reference

the syntax is simple:
parameters are defined in the form parameter = value; (don't forget the semicolon)
the value is an integer number except when dealing with colours
no parameter is mandatory and the order does not matter, as long as they are in the correct code block; you can see all the defaults in the arctic tetris (default) preset.
optional zone blocks (affecting select areas) start with [zone]
the global parameters must be defined before any zones
optional comments are in the form // comment follows the slashes; (the comment also needs to end with a semicolon)

global parameters:
refresh is the frequency to refresh the page, in seconds; it must be at least 2 (set it to 0 to disable refreshing)
height is the total height of the canvas, in pixels
width is the total width of the canvas, in pixels
top is the top margin, in pixels (does not affect the height)
left is the left margin, in pixels (does not affect the width)
rows is the number of blocks going along the y-axis
columns is the number of blocks going along the x-axis
blockheight is the height of each block, in pixels
blockwidth is the width of each block, in pixels
blockright is the right margin of each block, in pixels
blockbottom is the bottom margin of each block, in pixels
background is the background colour, defined in the colour format (see below), or set it to none for a transparent background

zone parameters; density and colour can also be set in the global block:
block coordinates start from 0
x1 is the x coordinate of the start corner of the zone, in blocks
y1 is the y coordinate of the start corner of the zone, in blocks
x2 is the x coordinate of the end corner of the zone, in blocks
y2 is the y coordinate of the end corner of the zone, in blocks
to clarify, imagine dragging out a rectangle from (x1, y1) to (x2, y2); zones are executed in the order they are defined, so if a block is inside multiple zones it will affected by the last one
density is the percentage chance, 0 to 100, of a space being filled with a block
colour is the block colour, defined in the colour format (see below)

colour:
the basic syntax for defining colour is (R, G, B)
each red/green/blue component can either be a number (from 0 to 255)
the letter can be a, b, or c (nothing else) for block colours, or x, y, or z (nothing else) for the background
by default, the letter represents a random number from 0 to 255
if the same letter is used more than once in the colour for a single block, its value does not change (for example, (a, a, a) would be a random and uniform shade of grey)
the letters can be redefined as a random number in a custom range, in the form letter = min - max (the separator is a hyphen-minus, but we'll pretend it's an en dash)

repository:
once you've got your code working the way you want (testing it on the main page), you can submit it to the repository. more detailed instructions coming soon.

tutorial

Let's have a look at the code that generates arctic tetris, the default aftcast you see on the main page.

refresh = 10;
height = 258;
width = 258;
top = 2;
left = 2;
rows = 16;
columns = 16;
blockheight = 14;
blockwidth = 14;
blockbottom = 2;
blockright = 2;
background = none;
density = 25;
colour = a, b, 255;
[zone]
// ice bar;
x1 = 0;
x2 = 15;
y1 = 14;
y2 = 15;
density = 100;
a = 195 - 223;
colour = a, a, a;
[zone]
// gap;
x1 = 0;
x2 = 15;
y1 = 13;
y2 = 13;
density = 0;

The first thing to note is that this example is more verbose than it needs to be. Every aftcast parameter has a default setting, and arctic tetris uses most of these defaults. You can try this by going to the main page and clearing and submitting the code textbox—you'll see what the default settings produce.

The first line is refresh = 10;, which means the image will refresh every 10 seconds. You can set this as high as 3600 seconds (but why would you?) and as low as 2 (which looks quite animated); setting it to 0 turns off refreshing altogether.

height/width, top/left, and rows/columns example
(height/width, top/left, and rows/columns example)

The next two lines are height = 258; and width = 258;. These simply set the size of the image canvas, in pixels. They don't affect the scaling of the image, so setting them really high will just give you a lot of blank space.

The next lines, top = 2; and left = 2;, set the top and left margins of the image. In this case, it means everything is going to be at least 2 pixels away from either border (you can control the bottom and right margins by changing the height and width).

The next two lines are rows = 16; and columns = 16;, which defines the number of available spaces that blocks can be put into. While height and width determine the size of the canvas, the rows and columns determine the size of the drawing itself.

example of block sizing
(block sizing and block margins at 2x enlargement)

There's more to the size of the drawing though, because we can also set the size of the blocks themselves. blockheight = 14; and blockheight = 14; set the size of each block in pixels. blockbottom = 2; and blockright = 2; determine the amount of space (in pixels) left at the right and bottom of each block; this space is added on to the blockheight and blockwidth, so in this example the top-left corner of every block will be 16 (14 + 2) pixels away from an adjacent block.

The next line, background = none;, means the image will not have a background (that is, it will be a fully transparent background). If you want to have a background, you can set its colour (more details on that coming in a minute).

The next line is density = 25;, and that means that there is a 25% chance of any space (any row + column location) being filled with a block.

RGB colours
(RGB colours)

Now we're going to talk about colour, because the next line is colour = a, b, 255;.


The tutorial is not yet finished!.