言語ゲーム

とあるエンジニアが嘘ばかり書く日記

Twitter: @propella

Tweak で processing

Tweak でも processing のような事が出来るかやってみた。これくらいの事ならモーフでやっても殆ど変わらないのですが、ソースを読めるでしょうか? だいたい processing で書いたのと同じようにしたつもりです。結果は。。。滅茶苦茶遅い。4fps描けてません。やはり、駄目なのか Squeak

CPlayer subclass: #RectSmooth
    instanceVariableNames: 'strokemousepmouse'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'FakeProcessing'!


!RectSmooth methodsFor: 'initialize' stamp: 'tak 2/10/2005 14:52'!
initialize
    self extent: 100 @ 100.
    self color: Color white.
    self graphicForm: (Form extent: 100 @ 100 depth: 16) fillWhite.
    stroke := Color h: 120 s: 0.5 v: 1.0! !

!RectSmooth methodsFor: 'events' stamp: 'tak 2/10/2005 14:56'!
loop
    | speed form pcolor |
    
    pmouse := mouse
                ifNil: [hand position - topLeft].
    mouse := hand position - topLeft.
    speed := (pmouse - mouse) r + 10.
    form := self graphicForm form.
    0 to: form width - 1 do: [:px |
        0 to: form height - 1 do: [:py | 
                    pcolor := form colorAt: px @ py.
                    form
                        colorAt: px @ py
                        put: (Color
                                h: pcolor hue + 30 \\ 360
                                s: pcolor saturation - 0.1
                                v: pcolor brightness + 0.03)] ].
    self graphicForm form
        border: (mouse extent: speed @ speed)
        width: 1
        fillColor: stroke.
    self invalidate! !