[etoys-dev] Etoys Inbox: Morphic-kfr..72.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Nov 7 05:26:02 EST 2011
A new version of Morphic was added to project Etoys Inbox:
http://source.squeak.org/etoysinbox/Morphic-kfr..72.mcz
==================== Summary ====================
Name: Morphic-kfr..72
Author: kfr.
Time: 7 November 2011, 11:25:01 am
UUID: 8d210534-3550-9a41-a334-f6f594ad81b2
Ancestors: Morphic-kfr.71
Fixing up so more filters can be added
=============== Diff against Morphic-kfr.71 ===============
Item was changed:
Morph subclass: #SketchMorph
instanceVariableNames: 'originalForm rotationStyle scalePoint framesToDwell rotatedForm filters'
classVariableNames: ''
poolDictionaries: ''
category: 'Morphic-Basic'!
-
- !SketchMorph commentStamp: '<historical>' prior: 0!
- The morph that results when the user draws a color bitmap using the PaintBox (SketchEditorMorph and PaintBoxMorph).
-
- forwardDirection is the angle at which the object will go forward. When the rotationStyle is not #normal, then forwardDirection is any angle, while the rotation is highly restricted. If flexed, this is remembered by the Transform morph. For non-normal rotationStyle, it is rotationDegrees.
-
- setupAngle (a property) is where the user put the green arrow to indicate which direction on the picture is forward. When #normal, draw the morph initially at (0.0 - setupAngle). The enclosing TransformationMorph then rotates it to the true angle.
-
- rotationDegrees In a #normal object, rotationDegrees is constant an equal to setupAngle.
- For non-normal, it is the direction the object is going.
-
- When repainting, set it back to its original state. The green arrow is set to setupAngle, and the sketch is shown as drawn originally (rotationDegrees = 0).
-
- rotationStyle = normal (turns), leftRight, upDown, fixed.
- When leftRight upDown or fixed, bit map has severe restrictions.
- !
Item was changed:
----- Method: SketchMorph>>blur:form: (in category 'filters') -----
+ blur: aWidth form: filteredForm
- blur: aWidth form: filteredForm
-
| f fOut fWidth |
+ f := filteredForm asFormOfDepth: 32.
-
- f := filteredForm asFormOfDepth: 32.
fWidth := f width + (aWidth - 1) max: f width.
fOut := f deepCopy.
+ ScratchPlugin
+ primBlur: f bits
+ into: fOut bits
+ width: fWidth.
+ ^ fOut asFormOfDepth: 16!
- ScratchPlugin primBlur: f bits into: fOut bits width: fWidth.
- ^ fOut asFormOfDepth: 16.
-
- !
Item was changed:
----- Method: SketchMorph>>brightnessShift:form: (in category 'filters') -----
+ brightnessShift: aShift form: filteredForm
- brightnessShift: aShift form: filteredForm
-
| f fOut shift |
shift := aShift min: 100 max: -100.
+ f := filteredForm asFormOfDepth: 32.
- f := filteredForm asFormOfDepth: 32.
fOut := f deepCopy.
+ ScratchPlugin
+ primShiftBrightness: f bits
+ into: fOut bits
+ by: shift.
+ ^ fOut asFormOfDepth: 16!
- ScratchPlugin primShiftBrightness: f bits into: fOut bits by: shift.
- ^ fOut asFormOfDepth: 16.
-
- !
Item was changed:
----- Method: SketchMorph>>filters (in category 'filters') -----
filters
+ ^ filters
+ ifNil: [filters := OrderedCollection new]!
- ^filters ifNil:[filters := OrderedCollection new].
- !
Item was changed:
----- Method: SketchMorph>>filtersAdd: (in category 'filters') -----
filtersAdd: aFilterWithValue
-
self filters
do: [:i | (i includes: aFilterWithValue first)
ifTrue: [filters remove: i]].
filters add: aFilterWithValue.
self layoutChanged!
Item was changed:
----- Method: SketchMorph>>generateRotatedForm (in category 'drawing') -----
generateRotatedForm
- "Compute my rotatedForm and offsetWhenRotated."
-
| scalePt smoothPix pair filteredForm |
+ scalePoint
+ ifNil: [scalePoint := 1 @ 1].
- scalePoint ifNil: [scalePoint := 1 @ 1].
scalePt := scalePoint x abs @ scalePoint y abs.
+ rotationStyle == #none
+ ifTrue: [scalePt := 1 @ 1].
- rotationStyle == #none ifTrue: [scalePt := 1 @ 1].
- "smoothPix := (scalePt x < 1.0 or: [scalePt y < 1.0])
- ifTrue: [2]
- ifFalse: [1]."
smoothPix := 1.
+ rotationStyle = #leftRight
+ ifTrue: [self heading asSmallAngleDegrees < 0.0
- rotationStyle = #leftRight
- ifTrue:
- [self heading asSmallAngleDegrees < 0.0
ifTrue: [scalePt := scalePt x negated @ scalePt y]].
+ rotationStyle = #upDown
+ ifTrue: [self heading asSmallAngleDegrees abs > 90.0
- rotationStyle = #upDown
- ifTrue:
- [self heading asSmallAngleDegrees abs > 90.0
ifTrue: [scalePt := scalePt x @ scalePt y negated]].
+ filters
+ ifNotNil: [filteredForm := originalForm copy.
+ filters
+ do: [:filter | filteredForm := self
+ perform: filter first
+ withArguments: (filter allButFirst copyWith: filteredForm)]].
+ rotatedForm := (scalePt = (1 @ 1)
+ and: [filters isNil])
-
- filters ifNotNil:[ filteredForm := originalForm copy.
- filters do:[: filter | filteredForm := self perform: filter first with: filter second with: filteredForm.
- ]].
- filteredForm ifNil:[filteredForm := originalForm copy].
- rotatedForm := (scalePt = (1 @ 1) and:[ filters isNil])
ifTrue: [originalForm]
+ ifFalse: [((rotationStyle == #normal
+ and: [self useInterpolation])
+ and: [filters isNil])
+ ifTrue: [^ self generateInterpolatedForm].
+ pair := WarpBlt current
- ifFalse:
- ["ar 11/19/2001: I am uncertain what happens in the case of rotationStyle ~~ normal"
-
- ((rotationStyle == #normal and: [self useInterpolation]) and:[filters isNil])
- ifTrue: [^self generateInterpolatedForm].
- pair := WarpBlt current
rotate: filteredForm
degrees: 0
center: originalForm boundingBox center
scaleBy: scalePt
smoothing: smoothPix.
pair first]!
Item was changed:
----- Method: SketchMorph>>hueShift:form: (in category 'filters') -----
+ hueShift: aShift form: filteredForm
- hueShift: aShift form: filteredForm
-
| f fOut shift |
shift := aShift min: 180 max: -180.
+ f := filteredForm asFormOfDepth: 32.
- f := filteredForm asFormOfDepth: 32.
fOut := f deepCopy.
+ ScratchPlugin
+ primShiftHue: f bits
+ into: fOut bits
+ byDegrees: shift.
+ ^ fOut asFormOfDepth: 16!
- ScratchPlugin primShiftHue: f bits into: fOut bits byDegrees: shift.
- ^ fOut asFormOfDepth: 16.
-
- !
Item was changed:
----- Method: SketchMorph>>removeFilters (in category 'filters') -----
removeFilters
filters := nil.
+ self layoutChanged!
- self layoutChanged
- !
Item was changed:
----- Method: SketchMorph>>saturationShift:form: (in category 'filters') -----
+ saturationShift: aShift form: filteredForm
- saturationShift: aShift form: filteredForm
-
| f fOut shift |
shift := aShift min: 100 max: -100.
+ f := filteredForm asFormOfDepth: 32.
- f := filteredForm asFormOfDepth: 32.
fOut := f deepCopy.
+ ScratchPlugin
+ primShiftSaturation: f bits
+ into: fOut bits
+ by: shift.
+ ^ fOut asFormOfDepth: 16!
- ScratchPlugin primShiftSaturation: f bits into: fOut bits by: shift.
- ^ fOut asFormOfDepth: 16.
-
- !
More information about the etoys-dev
mailing list