Section 4

Next we do the vertical pieces.

renderLaserVerticalSplatter
    self
        renderLaserVerticalMask: LaserGameForms splatterBeamMask
        color: LaserGameColors laserBeamSplatterColor

renderLaserVerticalCenter
    self
        renderLaserVerticalMask: LaserGameForms centerBeamMask
        color: LaserGameColors laserBeamCenterColor

renderLaserVertical
    self renderLaserVerticalSplatter.
    self renderLaserVerticalCenter.

renderLaserVerticalMask: aMaskForm color: aColor
    | cellPosn scaledBeam scale trimmedBeam offset rotatedBeam masked |
    cellPosn := self offsetWithinGridForm.
    scale := CellRenderer cellExtent * 6.
    scaledBeam := aMaskForm scaledToSize: scale.
    trimmedBeam := Form extent: (CellRenderer cellExtent x)@(scaledBeam height) depth: scaledBeam depth.
    scaledBeam
        displayOn: trimmedBeam
        at: 0@0
        clippingBox: trimmedBeam boundingBox
        rule: Form paint
        fillColor: nil.
    rotatedBeam := trimmedBeam rotateBy: 90.
    offset := (0 + (CellRenderer cellExtent x - rotatedBeam width) // 2)@(3 + (CellRenderer cellExtent y // 2) negated).
    masked := self maskOffVerticalOn: rotatedBeam.
    masked
        displayOn: self targetForm
        at: (cellPosn + offset)
        clippingBox: self targetForm boundingBox
        rule: Form oldPaint
        fillColor: aColor

maskOffVerticalOn: aMask
    | newMask halfExtent halfRect offset |
    newMask := Form extent: aMask extent depth: aMask depth.
    newMask fillColor: Color white.
    halfExtent := (aMask width)@(aMask height // 2).
    (self cell activeSegments at: #south)
        ifTrue: [offset := halfExtent y]
        ifFalse: [offset := 0].
    halfRect := (0@offset) extent: halfExtent.
    aMask
        displayOn: newMask
        at: 0@0
        clippingBox: halfRect
        rule: Form paint
        fillColor: Color black.
    ^newMask

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels    stevewessels@me.com