如何将图像插入PolygonMorph?

我需要在PolygonMorph中获得纹理,但这些似乎需要InfiniteForm作为颜色/填充。 InfiniteForm没有解决方案,因为我需要稍后旋转PolygonMorph并且移动PolygonMorph周围也会对显示的纹理产生副作用。 如果可以缩放插入的纹理,那将非常有用。 如果不替换现有的PolygonMorph(或者至少保留PolygonMorph的形状),你会怎么做?     
已邀请:
这是你的问题的另一个想法。 该解决方案包括两个阶段。 阶段1:(drawTextures)我们使用BitBlt用我们的纹理贴片填充Form。表单存储在名为texturing的实例变量中。此表单将在第2阶段中删除 阶段2:(clipTextures)现在我们生成一个形状,其形状像我们的多边形,多边形填充形式。然后我们从一个完整的黑色形式中减去它。现在我们有一个负面的多边形形状。通过这个我们剪辑纹理。现在我们可以创建一个Image Morph并将其添加到多边形或我们想要用它做什么。 不幸的是,fillForm实现无法处理对流形状。所以要小心多边形的样子。 此解决方案非常快,也可以在运行时应用。我们每10毫秒更改一次多边形的形状,渲染效果很好。
!PgiTexturedMorph methodsFor: 'graphics' stamp: 'pre 2/12/2011 13:30:15.156'!
    drawTexture
        | textureForm aTexture aBitBlt |

        textureForm := Form extent: (self shape extent) depth: 32.
        aTexture := self baseImage deepCopy .
        textureForm := Form extent: (self shape extent) depth: 32.
        (0 to: ((textureForm extent x) / (aTexture extent x))) do: [ :eachX | 
            (0 to: ((textureForm extent y) / (aTexture extent y))) do: [ :eachY |
                aBitBlt := BitBlt   destForm: textureForm 
                                sourceForm: aTexture 
                                fillColor: nil
                                combinationRule: 7 
                                destOrigin: (eachX * (aTexture extent x))@(eachY *(aTexture extent y)) 
                                sourceOrigin: 0@0 
                                extent: (aTexture extent) 
                                clipRect: (textureForm computeBoundingBox).
                aBitBlt copyBits.
            ]].

        self texturing: textureForm.! !

    !PgiTexturedMorph methodsFor: 'graphics' stamp: 'pre!
    clipTextures
        | clippingForm aBitBlt |

        clippingForm := (Form extent: (self shape extent + (1@0))) fillBlack.
        aBitBlt := BitBlt   destForm: clippingForm 
                        sourceForm: (self shape filledForm) 
                        fillColor: nil
                        combinationRule: 6 
                        destOrigin: 0@0
                        sourceOrigin: 0@0 
                        extent: (self shape extent) 
                        clipRect: (clippingForm computeBoundingBox).
        aBitBlt copyBits.
        aBitBlt := BitBlt   destForm: (self texturing) 
                        sourceForm: (clippingForm ) 
                        fillColor: nil
                        combinationRule: 17 
                        destOrigin: 0@0
                        sourceOrigin: 0@0 
                        extent: (clippingForm  extent) 
                        clipRect: (self texturing computeBoundingBox).
        aBitBlt copyBits.

        self texturePart image: (self texturing).
        self texturePart changed.! !
    

要回复问题请先登录注册