Etoys Inbox: Morphic-kfr.68.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Etoys Inbox: Morphic-kfr.68.mcz

commits-2
A new version of Morphic was added to project Etoys Inbox:
http://source.squeak.org/etoysinbox/Morphic-kfr.68.mcz

==================== Summary ====================

Name: Morphic-kfr.68
Author: kfr
Time: 30 October 2011, 5:19:22 pm
UUID: 351e1c8a-a323-2041-b6f2-bd68301dd600
Ancestors: Morphic-kfr.67

add filters to SketchMorph

=============== Diff against Morphic-kfr.67 ===============

Item was changed:
  Morph subclass: #SketchMorph
+ instanceVariableNames: 'originalForm rotationStyle scalePoint framesToDwell rotatedForm filters'
- instanceVariableNames: 'originalForm rotationStyle scalePoint framesToDwell rotatedForm'
  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 added:
+ ----- Method: SketchMorph>>blur: (in category 'filters') -----
+ blur: width
+
+ self filters.
+ filters add: { #filterBlur:form: .  width}
+
+
+ !

Item was added:
+ ----- Method: SketchMorph>>brightnessShift: (in category 'filters') -----
+ brightnessShift: shift
+
+ self filters.
+ filters add: { #filterBrightnessShift:form: .  shift}
+
+
+ !

Item was added:
+ ----- Method: SketchMorph>>filterBlur:form: (in category 'filters') -----
+ filterBlur: width form: filteredForm
+
+ | f fOut |
+ f _  filteredForm asFormOfDepth: 32.
+ fOut _ f deepCopy.
+ ScratchPlugin primBlur: f bits into: fOut bits width: width.
+      ^ fOut asFormOfDepth: 16.
+
+ !

Item was added:
+ ----- Method: SketchMorph>>filterBrightnessShift:form: (in category 'filters') -----
+ filterBrightnessShift: shift form: filteredForm
+
+ | f fOut |
+ f _  filteredForm asFormOfDepth: 32.
+ fOut _ f deepCopy.
+ ScratchPlugin primShiftBrightness: f bits into: fOut bits by: shift.
+      ^ fOut asFormOfDepth: 16.
+
+ !

Item was added:
+ ----- Method: SketchMorph>>filterHueShift:form: (in category 'filters') -----
+ filterHueShift: shift form: filteredForm
+
+ | f fOut |
+ f _  filteredForm asFormOfDepth: 32.
+ fOut _ f deepCopy.
+ ScratchPlugin primShiftHue: f bits into: fOut bits byDegrees: shift.
+      ^ fOut asFormOfDepth: 16.
+
+ !

Item was added:
+ ----- Method: SketchMorph>>filterSaturationShift:form: (in category 'filters') -----
+ filterSaturationShift: shift form: filteredForm
+
+ | f fOut |
+ f _  filteredForm asFormOfDepth: 32.
+ fOut _ f deepCopy.
+ ScratchPlugin primShiftSaturation: f bits into: fOut bits by: shift.
+      ^ fOut asFormOfDepth: 16.
+
+ !

Item was added:
+ ----- Method: SketchMorph>>filters (in category 'filters') -----
+ filters
+ filters ifNil:[filters := OrderedCollection new].
+ ^filters!

Item was changed:
  ----- Method: SketchMorph>>generateRotatedForm (in category 'drawing') -----
  generateRotatedForm
  "Compute my rotatedForm and offsetWhenRotated."
 
+ | scalePt smoothPix pair filteredForm |
- | scalePt smoothPix pair |
  scalePoint ifNil: [scalePoint := 1 @ 1].
  scalePt := scalePoint x abs @ scalePoint y abs.
  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
  ifTrue: [scalePt := scalePt x negated @ scalePt y]].
  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 with: filter second with: filteredForm.
+ ]].
+ filteredForm ifNil:[filteredForm := originalForm copy].
+ rotatedForm := (scalePt = (1 @ 1) and:[ filters isNil])
- rotatedForm := scalePt = (1 @ 1)
  ifTrue: [originalForm]
  ifFalse:
  ["ar 11/19/2001: I am uncertain what happens in the case of rotationStyle ~~ normal"
 
+ ((rotationStyle == #normal and: [self useInterpolation]) and:[filters isNil])
- (rotationStyle == #normal and: [self useInterpolation])
  ifTrue: [^self generateInterpolatedForm].
  pair := WarpBlt current
+ rotate: filteredForm
- rotate: originalForm
  degrees: 0
  center: originalForm boundingBox center
  scaleBy: scalePt
  smoothing: smoothPix.
  pair first]!

Item was added:
+ ----- Method: SketchMorph>>hueShift: (in category 'filters') -----
+ hueShift: shift
+
+ self filters.
+ filters add: { #filterHueShift:form: .  shift}
+
+
+ !

Item was added:
+ ----- Method: SketchMorph>>resetAllFilters (in category 'filters') -----
+ resetAllFilters
+ filters := nil.
+ !

Item was added:
+ ----- Method: SketchMorph>>saturationShift: (in category 'filters') -----
+ saturationShift: shift
+
+ self filters.
+ filters add: { #filterSaturationShift:form: .  shift}
+
+
+ !

_______________________________________________
etoys-dev mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/etoys-dev