• Author
Posts
• #4500
John Hyland
Participant

I notice the manual suggests gradient fills are possible [DEFINE LINEAR_GRADIENT_FILL]. But there are no explainations or examples how to implement. If any one has a simple example or tutorial it would be great.
John

• #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 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

• #4512
Barry Kelly
Participant

A few questions just for my understanding if I may.

1.) So there is no need to DEFINE the fill if you already have the gradient fill as an attribute?
Just SET FILL “Linear Gradient Fill”.

After all you are not really defining a pattern for the fill.
Every gradient fill you define is exactly the same as the others, just with a different name (and attribute number).
It is all about using the correct options in the POLY2_B[3] command and setting the required pen colours.

2.) Why can we not see the gradient and radial fills when a fill parameter is created in the parameter list?
But we can ‘SET FILL’ using those attributes by name in the script.
It would be nice to be able to choose solid, vectorial, symbolic, image and gradient fills from a parameter.

3.)Is there a tricky way to set up graphical hotspots to adjust the settings?
I can create hotspots to move the fill origin.

``````unID=1
!Stretchy x
HOTSPOT2 0, OriginY, unID, OriginX, 1+128 : unID=unID+1	!base
HOTSPOT2 -1, OriginY, unID, OriginX, 3 : unID=unID+1	!reference
HOTSPOT2 OriginX, OriginY, unID, OriginX, 2 : unID=unID+1	!moveable

!Stretchy y
HOTSPOT2 OriginX, 0, unID, OriginY, 1+128 : unID=unID+1	!base
HOTSPOT2 OriginX, -1, unID, OriginY, 3 : unID=unID+1	!reference
HOTSPOT2 OriginX, OriginY, unID, OriginY, 2 : unID=unID+1	!moveable``````

And I can add a hotspot to rotate the fill.

``````	!angle stretchy hotspot
HOTSPOT2 OriginX,OriginY,unID,patternAngle,6 : unID=unID+1																						!centre
HOTSPOT2 OriginX+(patternSize),OriginY,unID,patternAngle,4+128 : unID=unID+1																	!base
HOTSPOT2 OriginX+COS(patternAngle-symb_rotangle)*(patternSize),OriginY+SIN(patternAngle-symb_rotangle)*(patternSize),unID,patternAngle,5 : unID=unID+1	!stretchy hotspot
``````

But I can not make that rotational hotspot also stretch the pattern length.
If I comment out the above rotation hotspot and add this, I can stretch the pattern length.

``````ADD2 OriginX, OriginY
ROT2 patternAngle
HOTSPOT2 0, 0, unID, patternSize, 1+128 : unID=unID+1	!base
HOTSPOT2 0-1, 0, unID, patternSize, 3 : unID=unID+1	!reference
HOTSPOT2 0+patternSize, 0, unID, patternSize, 2 : unID=unID+1	!moveable
DEL 1
DEL 1``````

I guess what I am asking here, is there a way to combine the rotation hotspot with the pattern length?
So we can have a stretchy rotation.
Or will they have to be two separate hotspots?

Barry.

Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

• #4513
Péter Baksa
Keymaster

Hi Barry,

1, as long as you know the name of the fill, no need to define it. But the default name is localized.
2, I agree, it would be nice. But you would still have to do extra work in GDL to use them.
3, I didn’t try if a rotational and a moveable hotspot can be linked like two moveable hotspots can.
You could also try using a moveable hotspot for the origin, one moveable for the end of the radius, and doing the computations in the background with linked hidden parameters, showing angle/r instead of x/y in the tracker.

Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE

• #4514
Barry Kelly
Participant

Thanks Peter.
I don’t think a rotational and moveable hotspot can be linked which is why I was asking.
I will give your hidden calculations a go – I think that might be the only way.

Usually with something like this I would have one hotspot for the origin x & y, another for the length and a rotation one at half the length.

Barry.

Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

• #4526
John Hyland
Participant

Thanks Péter
and Barry keep us posted on progress.