On 15.04.2015, at 13:34, Nicolai Hess <nicolaihess@web.de> wrote:

|form canvas fill direction normal|
direction := 4@0.
normal := 0@2.
form := Form extent:300@300 depth:32.
canvas := form getCanvas.
fill := GradientFillStyle new colorRamp:{0 -> Color white . 0.5 -> Color green . 1 -> Color blue};origin:400@400;direction:direction;normal:normal;radial:true;yourself.
canvas fillRectangle: (0@0 extent:800@800) fillStyle: fill.
Display getCanvas drawImage: form at: 300@300

This uses a different value for direction and normal and the fill is defined for a larger area (800x800) -> CRASH

Maybe, this is a rare bug, because, normally you don't create a small gradient t o
fill a large area. But a vm crash is not nice, I would like to get this
fixed.

I am not sure what is the exact cause, but it may come from a signed integer overflwo,
It looks like Balloon uses fixed point arithmetik (binary scaling).
This fixed point representation (16.16 bit fixed point represented in a 32 integer) tend
to overflow, especially for operations like computing the squared length of a vector
x*x+y*y -> overflow -> result is a negative number.

Possible solutions:
downscale prior to the multiplication -> lost of precision
use a larger datatype for intermediate results.

It looks like B2D uses the first option (look at senders of
accurateLengthOfwith
and
squaredLenghtOfwith
Maybe there is something wrong with the other code that
multiplies the values, or the 16.16 bit fixed point is just not
large enough for some fills?


Any ideas?

No idea, but just as a datapoint:

The code works fine in SqueakJS (if you enlarge the form to actually show the ellipse centered at 400@400):


Also no idea why the gradient repeats after 260 pixels ...

- Bert -