Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance. _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods" extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph" Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance. _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] On Behalf Of roger mpouma Sent: Saturday, August 20, 2016 1:51 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
How can i make this please ? I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
*From:* beginners-bounces@lists.squeakfoundation.org [mailto: beginners-bounces@lists.squeakfoundation.org] *On Behalf Of *roger mpouma *Sent:* Saturday, August 20, 2016 1:51 PM *To:* A friendly place to get answers to even the most basic questions about Squeak. *Subject:* Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
From: roger mpouma Sent: Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
[Ron Teitelbaum]
What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.
On your class add some instance variable called drawColor or something like that.
When the menu item Red is called you would do
drawColor := Color red.
Then in mouseDown:
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] On Behalf Of roger mpouma Sent: Saturday, August 20, 2016 1:51 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black. When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ? And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
*From:* roger mpouma *Sent:* Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
*[Ron Teitelbaum] *
*What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.*
*On your class add some instance variable called drawColor or something like that.*
*When the menu item Red is called you would do *
*drawColor := Color red.*
*Then in mouseDown:*
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
*From:* beginners-bounces@lists.squeakfoundation.org [mailto: beginners-bounces@lists.squeakfoundation.org] *On Behalf Of *roger mpouma *Sent:* Saturday, August 20, 2016 1:51 PM *To:* A friendly place to get answers to even the most basic questions about Squeak. *Subject:* Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Hi Roger!
That was a nice try!
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
[Ron Teitelbaum]
What this does is create a menu with one item clear and then it sets the drawColor to red yellow green and then blue. Since blue is the last color you end up with blue.
Try creating drawRed, drawYellow, drawGreen, and drawBlue methods
For example
drawRed
drawColor := Color red.
Now add to your menu properly.
aCustomMenu add: 'clear' action: #clear. aCustomMenu add: 'red' action: #drawRed.
Where add is what you see in your menu and action is what happens when you select the menu item. (it calls: self drawRed)
Do that with all your colors and you should be all set!
You can also add menu items to adjust the size of the brush. Maybe make small brush, medium brush and large brush menu items? Works the same way as changing color. You need a brushSize instance variable. And initialize brushSize := 2.
All the best,
Ron Teitelbaum
initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black.
When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ?
And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
From: roger mpouma Sent: Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
[Ron Teitelbaum]
What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.
On your class add some instance variable called drawColor or something like that.
When the menu item Red is called you would do
drawColor := Color red.
Then in mouseDown:
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] On Behalf Of roger mpouma Sent: Saturday, August 20, 2016 1:51 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Is //modification a new way of doing comments?
Sent from my iPhone
On Aug 22, 2016, at 11:45 AM, Ron Teitelbaum [via Smalltalk] ml-node+s1294792n4912223h62@n4.nabble.com wrote:
Hi Roger!
That was a nice try!
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
[Ron Teitelbaum]
What this does is create a menu with one item clear and then it sets the drawColor to red yellow green and then blue. Since blue is the last color you end up with blue.
Try creating drawRed, drawYellow, drawGreen, and drawBlue methods
For example
drawRed
drawColor := Color red.
Now add to your menu properly.
aCustomMenu add: 'clear' action: #clear. aCustomMenu add: 'red' action: #drawRed.
Where add is what you see in your menu and action is what happens when you select the menu item. (it calls: self drawRed)
Do that with all your colors and you should be all set!
You can also add menu items to adjust the size of the brush. Maybe make small brush, medium brush and large brush menu items? Works the same way as changing color. You need a brushSize instance variable. And initialize brushSize := 2.
All the best,
Ron Teitelbaum
initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black.
When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ?
And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum <[hidden email]>:
From: roger mpouma Sent: Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
[Ron Teitelbaum]
What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.
On your class add some instance variable called drawColor or something like that.
When the menu item Red is called you would do
drawColor := Color red.
Then in mouseDown:
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum <[hidden email]>:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
From: [hidden email] [mailto:[hidden email]] On Behalf Of roger mpouma Sent: Saturday, August 20, 2016 1:51 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg <[hidden email]>:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma <[hidden email]> wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
If you reply to this email, your message will be added to the discussion below: http://forum.world.st/Project-on-squeak-language-tp4912035p4912223.html To start a new topic under Squeak - Beginners, email ml-node+s1294792n107673h12@n4.nabble.com To unsubscribe from Squeak - Beginners, click here. NAML
-- View this message in context: http://forum.world.st/Project-on-squeak-language-tp4912035p4912226.html Sent from the Squeak - Beginners mailing list archive at Nabble.com.
From: Joseph Alotta Sent: Monday, August 22, 2016 1:50 PM
Is //modification a new way of doing comments?
[Ron Teitelbaum]
Good question Joe,
I assumed it was added to the email and not to code.
The comments would require quotes: " this is a comment "
All the best,
Ron Teitelbaum
Sent from my iPhone
On Aug 22, 2016, at 11:45 AM, Ron Teitelbaum [via Smalltalk] <[hidden email]> wrote:
Hi Roger!
That was a nice try!
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
[Ron Teitelbaum]
What this does is create a menu with one item clear and then it sets the drawColor to red yellow green and then blue. Since blue is the last color you end up with blue.
Try creating drawRed, drawYellow, drawGreen, and drawBlue methods
For example
drawRed
drawColor := Color red.
Now add to your menu properly.
aCustomMenu add: 'clear' action: #clear. aCustomMenu add: 'red' action: #drawRed.
Where add is what you see in your menu and action is what happens when you select the menu item. (it calls: self drawRed)
Do that with all your colors and you should be all set!
You can also add menu items to adjust the size of the brush. Maybe make small brush, medium brush and large brush menu items? Works the same way as changing color. You need a brushSize instance variable. And initialize brushSize := 2.
All the best,
Ron Teitelbaum
initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black.
When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ?
And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum <[hidden email]>:
From: roger mpouma Sent: Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
[Ron Teitelbaum]
What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.
On your class add some instance variable called drawColor or something like that.
When the menu item Red is called you would do
drawColor := Color red.
Then in mouseDown:
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum <[hidden email]>:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
From: [hidden email] [mailto:[hidden email]] On Behalf Of roger mpouma Sent: Saturday, August 20, 2016 1:51 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg <[hidden email]>:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma <[hidden email]> wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
_____
If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/Project-on-squeak-language-tp4912035p4912223.html
To start a new topic under Squeak - Beginners, email [hidden email] To unsubscribe from Squeak - Beginners, click here.
_____
View this message in context: Re: Project on squeak language http://forum.world.st/Project-on-squeak-language-tp4912035p4912226.html Sent from the Squeak - Beginners mailing list archive http://forum.world.st/Squeak-Beginners-f107673.html at Nabble.com.
Sorry it's an error from me, it's rather " "
2016-08-22 19:50 GMT+02:00 Joseph Alotta joseph.alotta@gmail.com:
Is //modification a new way of doing comments?
Sent from my iPhone
On Aug 22, 2016, at 11:45 AM, Ron Teitelbaum [via Smalltalk] <[hidden email] http:///user/SendEmail.jtp?type=node&node=4912226&i=0> wrote:
Hi Roger!
That was a nice try!
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
*[Ron Teitelbaum]*
*What this does is create a menu with one item clear and then it sets the drawColor to red yellow green and then blue. Since blue is the last color you end up with blue.*
*Try creating drawRed, drawYellow, drawGreen, and drawBlue methods*
*For example*
*drawRed*
drawColor := Color red.*
*Now add to your menu properly.*
aCustomMenu add: 'clear' action: #clear. aCustomMenu add: 'red' action: #drawRed.
*Where add is what you see in your menu and action is what happens when you select the menu item. (it calls: self drawRed)*
*Do that with all your colors and you should be all set!*
*You can also add menu items to adjust the size of the brush. Maybe make small brush, medium brush and large brush menu items? Works the same way as changing color. You need a brushSize instance variable. And initialize brushSize := 2.*
*All the best,*
*Ron Teitelbaum* initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black.
When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ?
And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum <[hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=0>:
*From:* roger mpouma *Sent:* Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
*[Ron Teitelbaum] *
*What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.*
*On your class add some instance variable called drawColor or something like that.*
*When the menu item Red is called you would do *
*drawColor := Color red.*
*Then in mouseDown:*
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum <[hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=1>:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
*From:* [hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=2 [mailto:[hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=3] *On Behalf Of *roger mpouma
*Sent:* Saturday, August 20, 2016 1:51 PM *To:* A friendly place to get answers to even the most basic questions about Squeak. *Subject:* Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg <[hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=4>:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma <[hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=5> wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
Beginners mailing list [hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=6 http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=7 http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=8 http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=9 http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list [hidden email] http:///user/SendEmail.jtp?type=node&node=4912223&i=10 http://lists.squeakfoundation.org/mailman/listinfo/beginners
If you reply to this email, your message will be added to the discussion below: http://forum.world.st/Project-on-squeak-language-tp4912035p4912223.html To start a new topic under Squeak - Beginners, email [hidden email] http:///user/SendEmail.jtp?type=node&node=4912226&i=1 To unsubscribe from Squeak - Beginners, click here. NAML http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
View this message in context: Re: Project on squeak language http://forum.world.st/Project-on-squeak-language-tp4912035p4912226.html Sent from the Squeak - Beginners mailing list archive http://forum.world.st/Squeak-Beginners-f107673.html at Nabble.com.
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Hi Ron,
I solved my problem, thank you for your help. I got one more question, how can i add the possibility to erase parts of what i have already drawn as item "clear" but just parts of the drawing ?
2016-08-22 18:45 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Hi Roger!
That was a nice try!
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
*[Ron Teitelbaum]*
*What this does is create a menu with one item clear and then it sets the drawColor to red yellow green and then blue. Since blue is the last color you end up with blue.*
*Try creating drawRed, drawYellow, drawGreen, and drawBlue methods*
*For example*
*drawRed*
drawColor := Color red.*
*Now add to your menu properly.*
aCustomMenu add: 'clear' action: #clear. aCustomMenu add: 'red' action: #drawRed.
*Where add is what you see in your menu and action is what happens when you select the menu item. (it calls: self drawRed)*
*Do that with all your colors and you should be all set!*
*You can also add menu items to adjust the size of the brush. Maybe make small brush, medium brush and large brush menu items? Works the same way as changing color. You need a brushSize instance variable. And initialize brushSize := 2.*
*All the best,*
*Ron Teitelbaum* initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black.
When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ?
And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
*From:* roger mpouma *Sent:* Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
*[Ron Teitelbaum] *
*What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.*
*On your class add some instance variable called drawColor or something like that.*
*When the menu item Red is called you would do *
*drawColor := Color red.*
*Then in mouseDown:*
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
*From:* beginners-bounces@lists.squeakfoundation.org [mailto: beginners-bounces@lists.squeakfoundation.org] *On Behalf Of *roger mpouma *Sent:* Saturday, August 20, 2016 1:51 PM *To:* A friendly place to get answers to even the most basic questions about Squeak. *Subject:* Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
From: roger mpouma Sent: Monday, August 22, 2016 2:42 PM
Hi Ron,
I solved my problem, thank you for your help.
I got one more question, how can i add the possibility to erase parts of what i have already drawn as item "clear" but just parts of the drawing ?
[Ron Teitelbaum] Of course everything is possible. Your clear is doing just that, it’s filling in the canvas area with your background color. There are number of ways to accomplish this. A number of programs hold onto the results of each drawing collection (clicking and moving until you let go of the mouse) as a single element of the drawing. Then you can ctrl –z to remove them in order. To do something like that you need an instance of a class, something like Drawing, which holds a collection of brush strokes, colors and line widths, and a collection on your canvas to apply the drawings in order to your canvas. An instance variable called drawings would work. You could also calculate the intersection of a line and the position of the mouse pointer in the drawing to find each draw element and remove them when clicked. You could also erase by simply overlaying the background color as another draw element, in other words, drawing a line with the background color on top of everything else is similar to erasing.
Everything is possible!
All the best,
Ron Teitelbaum
2016-08-22 18:45 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Hi Roger!
That was a nice try!
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
[Ron Teitelbaum]
What this does is create a menu with one item clear and then it sets the drawColor to red yellow green and then blue. Since blue is the last color you end up with blue.
Try creating drawRed, drawYellow, drawGreen, and drawBlue methods
For example
drawRed
drawColor := Color red.
Now add to your menu properly.
aCustomMenu add: 'clear' action: #clear. aCustomMenu add: 'red' action: #drawRed.
Where add is what you see in your menu and action is what happens when you select the menu item. (it calls: self drawRed)
Do that with all your colors and you should be all set!
You can also add menu items to adjust the size of the brush. Maybe make small brush, medium brush and large brush menu items? Works the same way as changing color. You need a brushSize instance variable. And initialize brushSize := 2.
All the best,
Ron Teitelbaum
initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black.
When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ?
And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
From: roger mpouma Sent: Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
[Ron Teitelbaum]
What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.
On your class add some instance variable called drawColor or something like that.
When the menu item Red is called you would do
drawColor := Color red.
Then in mouseDown:
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] On Behalf Of roger mpouma Sent: Saturday, August 20, 2016 1:51 PM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Thank you Ron, thank you very much for your help.
2016-08-22 20:54 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
*From:* roger mpouma *Sent:* Monday, August 22, 2016 2:42 PM
Hi Ron,
I solved my problem, thank you for your help.
I got one more question, how can i add the possibility to erase parts of what i have already drawn as item "clear" but just parts of the drawing ?
*[Ron Teitelbaum] Of course everything is possible. Your clear is doing just that, it’s filling in the canvas area with your background color. There are number of ways to accomplish this. A number of programs hold onto the results of each drawing collection (clicking and moving until you let go of the mouse) as a single element of the drawing. Then you can ctrl –z to remove them in order. To do something like that you need an instance of a class, something like Drawing, which holds a collection of brush strokes, colors and line widths, and a collection on your canvas to apply the drawings in order to your canvas. An instance variable called drawings would work. You could also calculate the intersection of a line and the position of the mouse pointer in the drawing to find each draw element and remove them when clicked. You could also erase by simply overlaying the background color as another draw element, in other words, drawing a line with the background color on top of everything else is similar to erasing. *
*Everything is possible!*
All the best,
Ron Teitelbaum
2016-08-22 18:45 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Hi Roger!
That was a nice try!
I modified methods:
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear. drawColor := Color red. //modification drawColor := Color yellow. //modification drawColor := Color green. //modification drawColor := Color blue. //modification
*[Ron Teitelbaum]*
*What this does is create a menu with one item clear and then it sets the drawColor to red yellow green and then blue. Since blue is the last color you end up with blue.*
*Try creating drawRed, drawYellow, drawGreen, and drawBlue methods*
*For example*
*drawRed*
drawColor := Color red.*
*Now add to your menu properly.*
aCustomMenu add: 'clear' action: #clear. aCustomMenu add: 'red' action: #drawRed.
*Where add is what you see in your menu and action is what happens when you select the menu item. (it calls: self drawRed)*
*Do that with all your colors and you should be all set!*
*You can also add menu items to adjust the size of the brush. Maybe make small brush, medium brush and large brush menu items? Works the same way as changing color. You need a brushSize instance variable. And initialize brushSize := 2.*
*All the best,*
*Ron Teitelbaum* initialize super initialize. self extent: 500@700. drawColor := Color black.
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 2. brush color: drawColor. //modification lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
The initial color is black.
When i click the command "change color" on the menu and i chose for example the green color, the result is the blue color. I don't understand why ?
And after the first choice, i must restart the program with the Workspace for change another color. So i can't make several choices at the same time.
How can I solve these problems ? and to change size of the brush ?
Thank you in advance.
2016-08-21 3:14 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
*From:* roger mpouma *Sent:* Saturday, August 20, 2016 2:42 PM
How can i make this please ?
I thought to add "color" and "size" commands as "clear" command in the custom menu code. After that, add "color" and "size" methods...
*[Ron Teitelbaum] *
*What I was thinking is making buttons on the panel. Color buttons with a highlight around it so you can see what is selected. You could instead add something like Red or Blue to the menu.*
*On your class add some instance variable called drawColor or something like that.*
*When the menu item Red is called you would do *
*drawColor := Color red.*
*Then in mouseDown:*
brush color: drawColor.
Initialize your color to something like black
Initialize
drawColor := Color black.
So that the user is not required to use the menu to get the default color (black).
Hope that helps,
Ron
2016-08-20 20:26 GMT+02:00 Ron Teitelbaum ron@usmedrec.com:
Have you considered having a menu bar with colors and line sizes. The users can select the color and line size which will change your program to use those settings.
All the best,
Ron Teitelbaum
*From:* beginners-bounces@lists.squeakfoundation.org [mailto: beginners-bounces@lists.squeakfoundation.org] *On Behalf Of *roger mpouma *Sent:* Saturday, August 20, 2016 1:51 PM *To:* A friendly place to get answers to even the most basic questions about Squeak. *Subject:* Re: [Newbies] Project on squeak language
I have already implemented the canvas on which we draw, the possibility of drawing with the brush but with only a single color and a single size, a capacity to erase what we have already drawn with the "Clear" command on the custom menu code. So, i'd like to add the possibility of changing the color and the size of the brush presenting the choices of color and brush size.
The differents methods are:
"Methods"
extent: aPoint | newForm | super extent: aPoint. newForm := Form extent: self extent depth: 16. newForm fillColor: Color veryLightGray. form ifNotNil: [form displayOn: newForm]. form := newForm.
initialize super initialize. self extent: 500@350.
drawOn: aCanvas aCanvas image: form at: bounds origin.
handlesMouseDown: evt ^ true
mouseDown: evt brush := Pen newOnForm: form. brush roundNib: 3. brush color: Color red. lastMouse := evt cursorPoint - bounds origin. brush drawFrom: lastMouse to: lastMouse. self invalidRect: ((lastMouse - brush sourceForm extent corner: lastMouse + brush sourceForm extent) translateBy: bounds origin).
mouseMove: evt | p | p := evt cursorPoint - bounds origin. p = lastMouse ifTrue: [^ self]. brush drawFrom: lastMouse to: p. self invalidRect: (( ((lastMouse min: p) - brush sourceForm extent) corner: ((lastMouse max: p) + brush sourceForm extent)) translateBy: bounds origin). lastMouse := p.
addCustomMenuItems: aCustomMenu hand: aHandMorph super addCustomMenuItems: aCustomMenu hand: aHandMorph. aCustomMenu add: 'clear' action: #clear.
clear form fillColor: Color veryLightGray. self changed.
"Class PaintMorph"
Morph subclass: #PaintMorph instanceVariableNames: 'form brush lastMouse' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Fun'
"Workspace" PaintMorph new openInWorld.
Thank you in advance.
2016-08-20 18:47 GMT+02:00 Bert Freudenberg bert@freudenbergs.de:
Sure. Just ask some specific questions - e.g. what you tried, what worked, what didn't etc.
- Bert -
On Sat, Aug 20, 2016 at 10:59 AM, roger mpouma rmpouma@gmail.com wrote:
Hello, I need help for a drawing project on Squeak. I'd like implement a canvas on which we draw with the possibility of drawing with brush changing the color and size of the brush. Is it possibile to have help ?
Thank you in advance.
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org