2015-07-17 17:57 GMT+02:00 Aliaksei Syrel <alex.syrel@gmail.com>:
Hi

Any ideas how one could blur an arbitrary shape using athens?

Cheers,
Alex


Not possible. Not with Athens and not with cairo. (There was a discussion on cairos ml about drop shadows (and filter functions?, I am not sure) but
I don't think there is something like that currently).
Inkscape a vector/svg editor and viewer uses cairo but implements the svg filter rendering on its own.
You can pre-render the cairo image and apply a filter function and use the result as a form paint.

And you can cheat, and just compose multiple shape drawings with different alpha values, but of course, this is slow:

������ | view star kernel s r root2pi |
������ s := 3.
������ r := 7.
������ root2pi := (2 * Float pi) sqrt.
������ kernel := (-1 * r to: r) collect: [ :i | 1 / (root2pi * s) * (-0.5 * (i / s) squared) exp ].
������ view := AthensSceneView new.
������ star := {32.0 @ 44.04868495317364.
������ 13.458980337503156 @ 57.519524250561204.
������ 20.541019662496844 @ 35.72324841040037.
������ 1.999999999999993 @ 22.252409113012813.
������ 24.917960675006306 @ 22.25240911301281.
������ 31.999999999999993 @ 0.4561332728519787.
������ 39.08203932499369 @ 22.252409113012803.
������ 62.0 @ 22.252409113012803.
������ 43.458980337503164 @ 35.72324841040037.
������ 50.54101966249685 @ 57.5195242505612}.
������ view
������ ������ scene: [ :canvas |
������ ������ ������ | path |
������ ������ ������ path := canvas
������ ������ ������ ������ createPath: [ :builder |
������ ������ ������ ������ ������ builder
������ ������ ������ ������ ������ ������ absolute;
������ ������ ������ ������ ������ ������ moveTo: star first.
������ ������ ������ ������ ������ star allButFirstDo: [ :p | builder lineTo: p ].
������ ������ ������ ������ ������ builder close ].
������ ������ ������ canvas surface clear: Color white.
������ ������ ������ canvas paintMode over.
������ ������ ������ r negated to: r do: [ :i |
������ ������ ������ ������ | a |
������ ������ ������ ������ a := kernel at: r + i + 1.
������ ������ ������ ������ r negated to: r do: [ :j |
������ ������ ������ ������ ������ | b |
������ ������ ������ ������ ������ b := a * kernel at: r + j + 1.
������ ������ ������ ������ ������ canvas setPaint: (Color black alpha: b).
������ ������ ������ ������ ������ canvas pathTransform
������ ������ ������ ������ ������ ������ restoreAfter: [
������ ������ ������ ������ ������ ������ ������ | sx sy |
������ ������ ������ ������ ������ ������ ������ sx := canvas pathTransform sx.
������ ������ ������ ������ ������ ������ ������ sy := canvas pathTransform sy.
������ ������ ������ ������ ������ ������ ������ canvas pathTransform translateBy: (i / sx) @ (j / sy).
������ ������ ������ ������ ������ ������ ������ canvas drawShape: path ] ] ].
������ ������ ������ canvas pathTransform
������ ������ ������ ������ restoreAfter: [
������ ������ ������ ������ ������ canvas pathTransform translateBy: (5 @ 5) negated.
������ ������ ������ ������ ������ canvas setPaint: Color red.
������ ������ ������ ������ ������ canvas drawShape: path ] ].
������ view openInWindow