That looks nice! Thank you :)
- Bert -
On 25.10.2012, at 05:57, commits@source.squeak.org wrote:
Karl Ramberg uploaded a new version of Morphic to project Etoys: http://source.squeak.org/etoys/Morphic-kfr.97.mcz
==================== Summary ====================
Name: Morphic-kfr.97 Author: kfr Time: 25 October 2012, 7:56:46 am UUID: 6d5a2911-44d6-824d-90f4-59b32c1c8a03 Ancestors: Morphic-kfr.96
Add Etoy interfaces to ScratchPlugin picture manipulation methods http://tracker.squeakland.org/browse/SQ-996
=============== Diff against Morphic-kfr.96 ===============
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: 'kfr. 11/7/2011 11:32' prior: 0!
- SketchMorph commentStamp: '<historical>' prior: 0!!
- The morph that results when the user draws a color bitmap using the PaintBox (SketchEditorMorph and PaintBoxMorph).
- !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.
- 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).
- 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.
- rotationStyle = normal (turns), leftRight, upDown, fixed.
When leftRight upDown or fixed, bit map has severe restrictions. !
Item was added:
- ----- Method: SketchMorph>>blur:form: (in category 'filters') -----
- blur: aWidth form: filteredForm
- | f fOut fWidth |
- aWidth = 0 ifTrue:[^ filteredForm].
- 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!
Item was added:
- ----- Method: SketchMorph>>brightnessShift:form: (in category 'filters') -----
- brightnessShift: aShift form: filteredForm
- | f fOut shift |
- aShift = 0 ifTrue:[^ filteredForm].
- shift := aShift min: 100 max: -100.
- f := filteredForm asFormOfDepth: 32.
- fOut := f deepCopy.
- ScratchPlugin
primShiftBrightness: 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]!
Item was added:
- ----- 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 added:
- ----- Method: SketchMorph>>fishEye:form: (in category 'filters') -----
- fishEye: aPower form: aForm
- | f fOut power |
- aPower = 0 ifTrue:[^aForm].
- power := (100 + (aPower * 10)) max:0.
- f := aForm asFormOfDepth: 32.
- fOut := f deepCopy.
- ScratchPlugin primFisheye: f bits into: fOut bits width: f width power: power.
- ^fOut asFormOfDepth: 16!
Item was changed: ----- Method: SketchMorph>>generateRotatedForm (in category 'drawing') ----- generateRotatedForm
- | scalePt smoothPix pair filteredForm |
- scalePoint
ifNil: [scalePoint := 1 @ 1].
- "Compute my rotatedForm and offsetWhenRotated."
- | scalePt smoothPix pair |
- 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]
smoothPix := 1.ifFalse: [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]].
- filteredForm := originalForm copy.
- filters
ifNotNil: [filters
do: [:filter | filteredForm := self
perform: filter first
withArguments: (filter allButFirst copyWith: filteredForm)]].
- rotatedForm := (scalePt = (1 @ 1)
and: [filters isNil])
- rotatedForm := scalePt = (1 @ 1) ifTrue: [originalForm]
ifFalse: [((rotationStyle == #normal
and: [self useInterpolation])
and: [filters isNil])
ifTrue: [^ self generateInterpolatedForm].
pair := WarpBlt current
rotate: filteredForm
ifFalse:
["ar 11/19/2001: I am uncertain what happens in the case of rotationStyle ~~ normal"
(rotationStyle == #normal and: [self useInterpolation])
ifTrue: [^self generateInterpolatedForm].
pair := WarpBlt current
rotate: originalForm degrees: 0 center: originalForm boundingBox center scaleBy: scalePt smoothing: smoothPix. pair first]!
Item was added:
- ----- Method: SketchMorph>>hueShift:form: (in category 'filters') -----
- hueShift: aShift form: filteredForm
- | f fOut shift |
- aShift = 0 ifTrue:[^ filteredForm].
- shift := aShift min: 180 max: -180.
- f := filteredForm asFormOfDepth: 32.
- fOut := f deepCopy.
- ScratchPlugin
primShiftHue: f bits
into: fOut bits
byDegrees: shift.
- ^ fOut asFormOfDepth: 16!
Item was added:
- ----- Method: SketchMorph>>removeFilters (in category 'filters') -----
- removeFilters
- filters := nil.
- self layoutChanged!
Item was added:
- ----- Method: SketchMorph>>saturationShift:form: (in category 'filters') -----
- saturationShift: aShift form: filteredForm
- | f fOut shift |
- aShift = 0 ifTrue:[^ filteredForm].
- shift := aShift min: 100 max: -100.
- f := filteredForm asFormOfDepth: 32.
- fOut := f deepCopy.
- ScratchPlugin
primShiftSaturation: f bits
into: fOut bits
by: shift.
- ^ fOut asFormOfDepth: 16!
Item was added:
- ----- Method: SketchMorph>>whirl:form: (in category 'filters') -----
- whirl: anAngle form: aForm
- | f fOut |
- anAngle = 0 ifTrue:[^aForm].
- f := aForm asFormOfDepth: 32.
- fOut := f deepCopy.
- ScratchPlugin primWhirl: f bits into: fOut bits width: f width angle: anAngle.
- ^fOut asFormOfDepth: 16!
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
Hi
I found a issue with the filter implementation that I'm looking for a solution for.
Once a filter is added in a ScriptEditor it will not remove it self from the SketchMorph before a removeFilter is sent. So if the filter is pulled out of the ScriptEditor it is still active.
Karl
On Thu, Oct 25, 2012 at 7:35 PM, Bert Freudenberg bert@freudenbergs.dewrote:
That looks nice! Thank you :)
- Bert -
On 25.10.2012, at 05:57, commits@source.squeak.org wrote:
Karl Ramberg uploaded a new version of Morphic to project Etoys: http://source.squeak.org/etoys/Morphic-kfr.97.mcz
==================== Summary ====================
Name: Morphic-kfr.97 Author: kfr Time: 25 October 2012, 7:56:46 am UUID: 6d5a2911-44d6-824d-90f4-59b32c1c8a03 Ancestors: Morphic-kfr.96
Add Etoy interfaces to ScratchPlugin picture manipulation methods http://tracker.squeakland.org/browse/SQ-996
=============== Diff against Morphic-kfr.96 ===============
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: 'kfr. 11/7/2011 11:32' prior: 0!
- SketchMorph commentStamp: '<historical>' prior: 0!!
- The morph that results when the user draws a color bitmap using the
PaintBox (SketchEditorMorph and PaintBoxMorph).
- !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.
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).
- 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.
- rotationStyle = normal (turns), leftRight, upDown, fixed.
When leftRight upDown or fixed, bit map has severe restrictions. !
Item was added:
- ----- Method: SketchMorph>>blur:form: (in category 'filters') -----
- blur: aWidth form: filteredForm
| f fOut fWidth |
aWidth = 0 ifTrue:[^ filteredForm].
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!
Item was added:
- ----- Method: SketchMorph>>brightnessShift:form: (in category
'filters') -----
- brightnessShift: aShift form: filteredForm
| f fOut shift |
aShift = 0 ifTrue:[^ filteredForm].
shift := aShift min: 100 max: -100.
f := filteredForm asFormOfDepth: 32.
fOut := f deepCopy.
ScratchPlugin
primShiftBrightness: 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]!
Item was added:
- ----- 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 added:
- ----- Method: SketchMorph>>fishEye:form: (in category 'filters') -----
- fishEye: aPower form: aForm
- | f fOut power |
aPower = 0 ifTrue:[^aForm].
power := (100 + (aPower * 10)) max:0.
f := aForm asFormOfDepth: 32.
fOut := f deepCopy.
ScratchPlugin primFisheye: f bits into: fOut bits width: f width
power: power.
^fOut asFormOfDepth: 16!
Item was changed: ----- Method: SketchMorph>>generateRotatedForm (in category 'drawing')
generateRotatedForm
| scalePt smoothPix pair filteredForm |
scalePoint
ifNil: [scalePoint := 1 @ 1].
"Compute my rotatedForm and offsetWhenRotated."
| scalePt smoothPix pair |
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]].
filteredForm := originalForm copy.
filters
ifNotNil: [filters
do: [:filter | filteredForm := self
perform:
filter first
withArguments: (filter allButFirst copyWith: filteredForm)]].
rotatedForm := (scalePt = (1 @ 1)
and: [filters isNil])
rotatedForm := scalePt = (1 @ 1) ifTrue: [originalForm]
ifFalse: [((rotationStyle == #normal
and: [self
useInterpolation])
and: [filters
isNil])
ifTrue: [^ self
generateInterpolatedForm].
pair := WarpBlt current
rotate:
filteredForm
ifFalse:
["ar 11/19/2001: I am uncertain
what happens in the case of rotationStyle ~~ normal"
(rotationStyle == #normal and:
[self useInterpolation])
ifTrue: [^self
generateInterpolatedForm].
pair := WarpBlt current
rotate:
originalForm
degrees: 0 center:
originalForm boundingBox center
scaleBy:
scalePt
smoothing:
smoothPix.
pair first]!
Item was added:
- ----- Method: SketchMorph>>hueShift:form: (in category 'filters') -----
- hueShift: aShift form: filteredForm
| f fOut shift |
aShift = 0 ifTrue:[^ filteredForm].
shift := aShift min: 180 max: -180.
f := filteredForm asFormOfDepth: 32.
fOut := f deepCopy.
ScratchPlugin
primShiftHue: f bits
into: fOut bits
byDegrees: shift.
^ fOut asFormOfDepth: 16!
Item was added:
- ----- Method: SketchMorph>>removeFilters (in category 'filters') -----
- removeFilters
filters := nil.
self layoutChanged!
Item was added:
- ----- Method: SketchMorph>>saturationShift:form: (in category
'filters') -----
- saturationShift: aShift form: filteredForm
| f fOut shift |
aShift = 0 ifTrue:[^ filteredForm].
shift := aShift min: 100 max: -100.
f := filteredForm asFormOfDepth: 32.
fOut := f deepCopy.
ScratchPlugin
primShiftSaturation: f bits
into: fOut bits
by: shift.
^ fOut asFormOfDepth: 16!
Item was added:
- ----- Method: SketchMorph>>whirl:form: (in category 'filters') -----
- whirl: anAngle form: aForm
| f fOut |
anAngle = 0 ifTrue:[^aForm].
f := aForm asFormOfDepth: 32.
fOut := f deepCopy.
ScratchPlugin primWhirl: f bits into: fOut bits width: f width
angle: anAngle.
^fOut asFormOfDepth: 16!
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
On 2012-12-04, at 13:48, karl ramberg karlramberg@gmail.com wrote:
Hi
I found a issue with the filter implementation that I'm looking for a solution for.
Once a filter is added in a ScriptEditor it will not remove it self from the SketchMorph before a removeFilter is sent. So if the filter is pulled out of the ScriptEditor it is still active.
Karl
Oh, I only now tried your code. From reading it I thought you had added 6 new slots. Instead you made the filters be commands, which is not as flexible.
Here's what I thought we would do: Give the player a new numeric slot, named blur, with default value 0. When setting its value to anything other than 0, a filter is added, when setting it back to 0, the filter gets removed. Similar for the 5 other filters.
That way we don't need a "removeFilters" command, and you can easily play with the filters in the viewer because they show the current amount.
Your SketchMorph code can be exactly the same, it's just how filters get added and removed that would change. An improvement would be however if you did not add an instance variable, but stored the filters in a property. Most of the SketchMorphs will not need filtering.
- Bert -
Like this, and like Bert's suggestion of slots.
David p.s. is Smalltalk on XO really so slow that these picture filters need the plugin?
These filters is more about using the filters allready provided with the Scratch plugin
On Tue, Dec 4, 2012 at 7:39 PM, David Corking lists@dcorking.com wrote:
Like this, and like Bert's suggestion of slots.
David p.s. is Smalltalk on XO really so slow that these picture filters need the plugin? _______________________________________________ etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
On 2012-12-04, at 15:18, Bert Freudenberg bert@freudenbergs.de wrote:
On 2012-12-04, at 13:48, karl ramberg karlramberg@gmail.com wrote:
Hi
I found a issue with the filter implementation that I'm looking for a solution for.
Once a filter is added in a ScriptEditor it will not remove it self from the SketchMorph before a removeFilter is sent. So if the filter is pulled out of the ScriptEditor it is still active.
Karl
Oh, I only now tried your code. From reading it I thought you had added 6 new slots. Instead you made the filters be commands, which is not as flexible.
Here's what I thought we would do: Give the player a new numeric slot, named blur, with default value 0. When setting its value to anything other than 0, a filter is added, when setting it back to 0, the filter gets removed. Similar for the 5 other filters.
That way we don't need a "removeFilters" command, and you can easily play with the filters in the viewer because they show the current amount.
Your SketchMorph code can be exactly the same, it's just how filters get added and removed that would change. An improvement would be however if you did not add an instance variable, but stored the filters in a property. Most of the SketchMorphs will not need filtering.
- Bert -
(new version)
Yes! Isn't that much more fun to play with? We don't even need a script! :)
You need to use "self costume renderedMorph" otherwise it breaks under rotation.
Also, it's a good idea to check for #isSketchMorph and return 0 in the getter / ignore the value in the setter otherwise. It can always happen that the messages are sent to a player whose costume is not a sketch.
- Bert -
Good suggestions. I think we must ensure that we send valid numbers to the primitives as well. Some do not like decimal values and it does not make sense to send extreme big or small values either.
Karl
On Tue, Dec 4, 2012 at 10:56 PM, Bert Freudenberg bert@freudenbergs.dewrote:
On 2012-12-04, at 15:18, Bert Freudenberg bert@freudenbergs.de wrote:
On 2012-12-04, at 13:48, karl ramberg karlramberg@gmail.com wrote:
Hi
I found a issue with the filter implementation that I'm looking for a
solution for.
Once a filter is added in a ScriptEditor it will not remove it self
from the SketchMorph before a removeFilter is sent.
So if the filter is pulled out of the ScriptEditor it is still active.
Karl
Oh, I only now tried your code. From reading it I thought you had added
6 new slots. Instead you made the filters be commands, which is not as flexible.
Here's what I thought we would do: Give the player a new numeric slot,
named blur, with default value 0. When setting its value to anything other than 0, a filter is added, when setting it back to 0, the filter gets removed. Similar for the 5 other filters.
That way we don't need a "removeFilters" command, and you can easily
play with the filters in the viewer because they show the current amount.
Your SketchMorph code can be exactly the same, it's just how filters get
added and removed that would change. An improvement would be however if you did not add an instance variable, but stored the filters in a property. Most of the SketchMorphs will not need filtering.
- Bert -
(new version)
Yes! Isn't that much more fun to play with? We don't even need a script! :)
You need to use "self costume renderedMorph" otherwise it breaks under rotation.
Also, it's a good idea to check for #isSketchMorph and return 0 in the getter / ignore the value in the setter otherwise. It can always happen that the messages are sent to a player whose costume is not a sketch.
- Bert -
etoys-dev mailing list etoys-dev@squeakland.org http://lists.squeakland.org/mailman/listinfo/etoys-dev
etoys-dev@lists.squeakfoundation.org