[squeak-dev] The Trunk: Graphics-tfel.310.mcz

karl ramberg karlramberg at gmail.com
Fri Apr 17 12:41:34 UTC 2015


Cool

Karl

On Fri, Apr 17, 2015 at 2:37 PM, <commits at source.squeak.org> wrote:

> Tim Felgentreff uploaded a new version of Graphics to project The Trunk:
> http://source.squeak.org/trunk/Graphics-tfel.310.mcz
>
> ==================== Summary ====================
>
> Name: Graphics-tfel.310
> Author: tfel
> Time: 17 April 2015, 2:37:38.42 pm
> UUID: dcfe87bc-46ca-c04e-b99b-5a711f8a8c9e
> Ancestors: Graphics-tk.309
>
> add convolution to forms and some common kernels for blurring, sharpening
> and so on
>
> =============== Diff against Graphics-tk.309 ===============
>
> Item was added:
> + ----- Method: Form>>approxGaussianBlur (in category 'processing') -----
> + approxGaussianBlur
> +
> +       ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #(
> +                1 2 1
> +                2 4 2
> +                1 2 1
> +       ) *  0.0625)!
>
> Item was added:
> + ----- Method: Form>>edgeDetect (in category 'processing') -----
> + edgeDetect
> +
> +       ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #(
> +               -1 -1 -1
> +               -1  8 -1
> +               -1 -1 -1
> +       ))!
>
> Item was added:
> + ----- Method: Form>>emboss (in category 'processing') -----
> + emboss
> +
> +       ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #(
> +               -2 -1  0
> +               -1  1  1
> +                0  1  2
> +       ))!
>
> Item was added:
> + ----- Method: Form>>processUsingKernel: (in category 'processing') -----
> + processUsingKernel: filter
> +
> +       ^ self processUsingKernel: filter factor: 1.0 bias: 0.0!
>
> Item was added:
> + ----- Method: Form>>processUsingKernel:factor:bias: (in category
> 'processing') -----
> + processUsingKernel: filter factor: factor bias: bias
> +       | image result |
> +
> +       image := self.
> +       result := Form extent: image extent depth: image depth.
> +
> +       0 to: image height - 1 do: [:y |
> +               0 to: image width - 1 do: [:x |
> +                       | r g b |
> +                       r := g := b := 0.0.
> +
> +                       0 to: filter rowCount - 1 do: [:filterY |
> +                               0 to: filter columnCount - 1 do: [:filterX
> |
> +                                       | imageX imageY |
> +                                       imageX := (x - (filter columnCount
> // 2) + filterX + image width) \\
> +                                                               image
> width.
> +                                       imageY := (y - (filter rowCount //
> 2) + filterY + image height) \\
> +                                                               image
> height.
> +                                       r := r + ((image colorAt:
> imageX at imageY) red *
> +                                                               (filter
> at: filterY + 1 at: filterX + 1)).
> +                                       g := g + ((image colorAt:
> imageX at imageY) green *
> +                                                               (filter
> at: filterY + 1 at: filterX + 1)).
> +                                       b := b + ((image colorAt:
> imageX at imageY) blue *
> +                                                               (filter
> at: filterY + 1 at: filterX + 1))]].
> +
> +                       result colorAt: x at y put: (Color
> +                               r: ((factor * r + bias) min: 1.0 max: 0.0)
> +                               g: ((factor * g + bias) min: 1.0 max: 0.0)
> +                               b: ((factor * b + bias) min: 1.0 max:
> 0.0))]].
> +       ^ result
> + !
>
> Item was added:
> + ----- Method: Form>>sharpen (in category 'processing') -----
> + sharpen
> +
> +       ^ self processUsingKernel: (Matrix rows: 3 columns: 3 contents: #(
> +                0 -1  0
> +               -1  5 -1
> +                0 -1  0
> +       ))!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150417/dfa1d650/attachment.htm


More information about the Squeak-dev mailing list