AKTIVE

gradient.tcl at trunk
Login

gradient.tcl at trunk

File etc/generator/virtual/gradient.tcl artifact 82a9733f5d on branch trunk


     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
## -*- mode: tcl ; fill-column: 90 -*-
# # ## ### ##### ######## ############# #####################
## Generators -- Virtual image - Computed pixels - Gradient across entire volume

operator image::gradient {
    section generator virtual

    note Returns image containing a linear gradient through all cells.

    example {width 256 height   1 depth 1 first 0 last 1 | height-times 32}
    example {width 128 height 128 depth 1 first 0 last 1}

    uint   width   Width of the returned image
    uint   height  Height of the returned image
    uint   depth   Depth of the returned image
    double first   First value
    double last    Last value

    state -fields {
	double delta;
    } -setup {
	aktive_geometry_set (domain, 0, 0, param->width, param->height, param->depth);

	state->delta = (param->last - param->first)
		     / (double) (aktive_geometry_get_size (domain) - 1);
    }

    blit gradient {
	{AH {y AY 1 up} {y SY 1 up}}
	{AW {x AX 1 up} {x SX 1 up}}
	{DD {z  0 1 up} {z  0 1 up}}
    } {pos {
	param->first + @ * istate->delta
    }}

    pixels {
	#define SD (idomain->depth)
	#define SH (idomain->height)
	#define SW (idomain->width)
	#define SX (request->x)
	#define SY (request->y)
	@@gradient@@
    }
}

##
# # ## ### ##### ######## ############# #####################
::return