Reply To: Gradient fill

Home Forums Problems and solutions in GDL Object design Gradient fill Reply To: Gradient fill

#4511
Péter Baksa
Keymaster

Hi John,

The definition part is simple, the trick is in setting up the fill distortion. The transformation matrix used by poly2_b{3} is interpreted differently for gradient fills: the end coordinates of the axes should be given relative to the object origin, not the fill origin.

DEFINE LINEAR_GRADIENT_FILL "gradfill"
fill "gradfill"

! fill origin
OriginX = 0.5
OriginY = 0.5
! pattern angle
patternAngle = 30
! size
patternSize = 0.5               ! length of gradient from fill pen to background pen

poly2_b{3} 4,                   ! # of edges
        1 + 2 + 4 + 8,          ! contour + fill + close polygon + local fill orientation
        1, 0,                   ! fill pen, fill background pen

        OriginX,                                   OriginY,                                      ! fill origin
        OriginX + patternSize * cos(patternAngle), OriginX - patternSize * sin(patternAngle),    ! X of pattern axis X,   X of pattern axis Y
        OriginY + patternSize * sin(patternAngle), OriginY + patternSize * cos(patternAngle),    ! Y of pattern axis X,   Y of pattern axis Y

        0, 0, 1,                ! vertices
        0, 1, 1, 
        1, 1, 1, 
        1, 0, 1

Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE