A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-ms.407.mcz ==================== Summary ==================== Name: Graphics-ms.407 Author: ms Time: 20 March 2019, 1:51:42.768596 pm UUID: 40a66bd7-815f-43f7-bbd0-31dc8da3a483 Ancestors: Graphics-mt.406 Adds a preview morph for results of all BitBlt rules. When first using BitBlt, it wasn't easy to understand the effects of the possible rules on pixel combinating for me. I implemented two example methods which preview the effects of rule 0 to 41 (these are all, I believe) on quadratic existing forms with colors and 1 bit alpha channel (previewAllBitBltRules uses ToolIcons flag/collection) plus Forms with more alpha values (previewAllBitBltRulesWithAlpha uses ToolIcons flag and a Color red + 0.4 alpha preview). They generate a combined morph for all rules applied on these forms (scaled, because icons are small) and opens it in your hand. Internally, this morph can be generated for any rule, forms and scale. Rules which throw exceptions are replaced with a fallback form. =============== Diff against Graphics-mt.406 =============== Item was added: + ----- Method: BitBlt class>>previewAllBitBltRules (in category 'examples') ----- + previewAllBitBltRules + + (self previewBitBltRules: (0 to: 41) + on: ToolIcons flag + and: ToolIcons collection + fallback: ToolIcons exception + scaledTo: 32) openInHand.! Item was added: + ----- Method: BitBlt class>>previewAllBitBltRulesWithAlpha (in category 'examples') ----- + previewAllBitBltRulesWithAlpha + + (self previewBitBltRules: (0 to: 41) + on: ToolIcons flag + and: ((Color red alpha: 0.4) iconOrThumbnailOfSize: 12) + fallback: ToolIcons exception + scaledTo: 32) openInHand.! Item was added: + ----- Method: BitBlt class>>previewBitBltRules:on:and:fallback:scaledTo: (in category 'examples') ----- + previewBitBltRules: rules on: aForm1 and: aForm2 fallback: fallbackForm scaledTo: aNumberOrPoint + "Returns a combined morph of the result of each rule applied on aForm1 combined with + aForm2 scaled to aNumberOrPoint. If the combination faild with a rule, fallbackForm is + shown instead. The number of each rule is appended at the bottom of each result." + + | resultMorph tileExtent | + tileExtent := aNumberOrPoint asPoint. + resultMorph := Morph new + color: Color transparent; + extent: (rules size * tileExtent x)@tileExtent y; + yourself. + + rules withIndexDo: [ :rule :index | | form formMorph numberLabel | + form := aForm1 copy. + [aForm2 copy displayOn: form at: 0@0 rule: rule] + on: Exception + do: [form := fallbackForm]. + formMorph := (form scaledToSize: tileExtent) asMorph + position: (index*tileExtent x)@0; + yourself. + resultMorph addMorph: formMorph. + + numberLabel := rule asString asMorph + center: ((index+0.5)*tileExtent x)@tileExtent y; + yourself. + resultMorph addMorph: numberLabel]. + + ^ resultMorph! |
Hi Maximilian,
This looks like a good addition. It is small and useful, and it aids understanding. I am not very knowledgeable about the BitBlt rules, so maybe someone else can look at it also? To me, this looks like a good contribution for trunk. Dave On Wed, Mar 20, 2019 at 12:51:46PM +0000, [hidden email] wrote: > A new version of Graphics was added to project The Inbox: > http://source.squeak.org/inbox/Graphics-ms.407.mcz > > ==================== Summary ==================== > > Name: Graphics-ms.407 > Author: ms > Time: 20 March 2019, 1:51:42.768596 pm > UUID: 40a66bd7-815f-43f7-bbd0-31dc8da3a483 > Ancestors: Graphics-mt.406 > > Adds a preview morph for results of all BitBlt rules. > > When first using BitBlt, it wasn't easy to understand the effects of the possible rules on pixel combinating for me. > I implemented two example methods which preview the effects of rule 0 to 41 (these are all, I believe) on quadratic existing forms with colors and 1 bit alpha channel (previewAllBitBltRules uses ToolIcons flag/collection) plus Forms with more alpha values (previewAllBitBltRulesWithAlpha uses ToolIcons flag and a Color red + 0.4 alpha preview). They generate a combined morph for all rules applied on these forms (scaled, because icons are small) and opens it in your hand. > Internally, this morph can be generated for any rule, forms and scale. Rules which throw exceptions are replaced with a fallback form. > > =============== Diff against Graphics-mt.406 =============== > > Item was added: > + ----- Method: BitBlt class>>previewAllBitBltRules (in category 'examples') ----- > + previewAllBitBltRules > + > + (self previewBitBltRules: (0 to: 41) > + on: ToolIcons flag > + and: ToolIcons collection > + fallback: ToolIcons exception > + scaledTo: 32) openInHand.! > > Item was added: > + ----- Method: BitBlt class>>previewAllBitBltRulesWithAlpha (in category 'examples') ----- > + previewAllBitBltRulesWithAlpha > + > + (self previewBitBltRules: (0 to: 41) > + on: ToolIcons flag > + and: ((Color red alpha: 0.4) iconOrThumbnailOfSize: 12) > + fallback: ToolIcons exception > + scaledTo: 32) openInHand.! > > Item was added: > + ----- Method: BitBlt class>>previewBitBltRules:on:and:fallback:scaledTo: (in category 'examples') ----- > + previewBitBltRules: rules on: aForm1 and: aForm2 fallback: fallbackForm scaledTo: aNumberOrPoint > + "Returns a combined morph of the result of each rule applied on aForm1 combined with > + aForm2 scaled to aNumberOrPoint. If the combination faild with a rule, fallbackForm is > + shown instead. The number of each rule is appended at the bottom of each result." > + > + | resultMorph tileExtent | > + tileExtent := aNumberOrPoint asPoint. > + resultMorph := Morph new > + color: Color transparent; > + extent: (rules size * tileExtent x)@tileExtent y; > + yourself. > + > + rules withIndexDo: [ :rule :index | | form formMorph numberLabel | > + form := aForm1 copy. > + [aForm2 copy displayOn: form at: 0@0 rule: rule] > + on: Exception > + do: [form := fallbackForm]. > + formMorph := (form scaledToSize: tileExtent) asMorph > + position: (index*tileExtent x)@0; > + yourself. > + resultMorph addMorph: formMorph. > + > + numberLabel := rule asString asMorph > + center: ((index+0.5)*tileExtent x)@tileExtent y; > + yourself. > + resultMorph addMorph: numberLabel]. > + > + ^ resultMorph! > > |
I haven't tried the code yet, but based on the commit message, this is a
great contribution. Perhaps it would be worth to create a complete tool showing the actual results. I think this code belongs to Morphic/MorphicExtras rather than Graphics. Graphics doesn't depend on Morphic, and it shouldn't, but these changes would introduce that dependency. Levente On Thu, 21 Mar 2019, David T. Lewis wrote: > Hi Maximilian, > > This looks like a good addition. It is small and useful, and it aids > understanding. > > I am not very knowledgeable about the BitBlt rules, so maybe someone > else can look at it also? To me, this looks like a good contribution > for trunk. > > Dave > > > On Wed, Mar 20, 2019 at 12:51:46PM +0000, [hidden email] wrote: >> A new version of Graphics was added to project The Inbox: >> http://source.squeak.org/inbox/Graphics-ms.407.mcz >> >> ==================== Summary ==================== >> >> Name: Graphics-ms.407 >> Author: ms >> Time: 20 March 2019, 1:51:42.768596 pm >> UUID: 40a66bd7-815f-43f7-bbd0-31dc8da3a483 >> Ancestors: Graphics-mt.406 >> >> Adds a preview morph for results of all BitBlt rules. >> >> When first using BitBlt, it wasn't easy to understand the effects of the possible rules on pixel combinating for me. >> I implemented two example methods which preview the effects of rule 0 to 41 (these are all, I believe) on quadratic existing forms with colors and 1 bit alpha channel (previewAllBitBltRules uses ToolIcons flag/collection) plus Forms with more alpha values (previewAllBitBltRulesWithAlpha uses ToolIcons flag and a Color red + 0.4 alpha preview). They generate a combined morph for all rules applied on these forms (scaled, because icons are small) and opens it in your hand. >> Internally, this morph can be generated for any rule, forms and scale. Rules which throw exceptions are replaced with a fallback form. >> >> =============== Diff against Graphics-mt.406 =============== >> >> Item was added: >> + ----- Method: BitBlt class>>previewAllBitBltRules (in category 'examples') ----- >> + previewAllBitBltRules >> + >> + (self previewBitBltRules: (0 to: 41) >> + on: ToolIcons flag >> + and: ToolIcons collection >> + fallback: ToolIcons exception >> + scaledTo: 32) openInHand.! >> >> Item was added: >> + ----- Method: BitBlt class>>previewAllBitBltRulesWithAlpha (in category 'examples') ----- >> + previewAllBitBltRulesWithAlpha >> + >> + (self previewBitBltRules: (0 to: 41) >> + on: ToolIcons flag >> + and: ((Color red alpha: 0.4) iconOrThumbnailOfSize: 12) >> + fallback: ToolIcons exception >> + scaledTo: 32) openInHand.! >> >> Item was added: >> + ----- Method: BitBlt class>>previewBitBltRules:on:and:fallback:scaledTo: (in category 'examples') ----- >> + previewBitBltRules: rules on: aForm1 and: aForm2 fallback: fallbackForm scaledTo: aNumberOrPoint >> + "Returns a combined morph of the result of each rule applied on aForm1 combined with >> + aForm2 scaled to aNumberOrPoint. If the combination faild with a rule, fallbackForm is >> + shown instead. The number of each rule is appended at the bottom of each result." >> + >> + | resultMorph tileExtent | >> + tileExtent := aNumberOrPoint asPoint. >> + resultMorph := Morph new >> + color: Color transparent; >> + extent: (rules size * tileExtent x)@tileExtent y; >> + yourself. >> + >> + rules withIndexDo: [ :rule :index | | form formMorph numberLabel | >> + form := aForm1 copy. >> + [aForm2 copy displayOn: form at: 0@0 rule: rule] >> + on: Exception >> + do: [form := fallbackForm]. >> + formMorph := (form scaledToSize: tileExtent) asMorph >> + position: (index*tileExtent x)@0; >> + yourself. >> + resultMorph addMorph: formMorph. >> + >> + numberLabel := rule asString asMorph >> + center: ((index+0.5)*tileExtent x)@tileExtent y; >> + yourself. >> + resultMorph addMorph: numberLabel]. >> + >> + ^ resultMorph! >> >> |
On Thu, Mar 21, 2019 at 9:22 AM Levente Uzonyi <[hidden email]> wrote: I haven't tried the code yet, but based on the commit message, this is a +1
_,,,^..^,,,_ best, Eliot |
There is a quite obscure paint tool, SpookyPaint, that one can experiment with and use the combination rules. On Thu, Mar 21, 2019 at 9:14 PM Eliot Miranda <[hidden email]> wrote:
|
In reply to this post by Levente Uzonyi
+1 Graphics must not depend on Morphic. Put it into an extension category such as "*MorphicExtras". Best, Marcel
|
Free forum by Nabble | Edit this page |