m (Fixed to fit S:STYLE)
(Now obsolete.)
Line 1: Line 1:
 +
{{obsolete feature}}
 
{{block
 
{{block
 
| name      = Change Pen Color by ()
 
| name      = Change Pen Color by ()
 
| image      = File:2.0 Change_Pen_Color_by_().png
 
| image      = File:2.0 Change_Pen_Color_by_().png
| category  = [[Pen Blocks|Pen]]
+
| category  = [[Pen Extension|Pen]]
 
| type      = [[Stack Block|Stack]]
 
| type      = [[Stack Block|Stack]]
 
| default    = 10
 
| default    = 10
 +
| removed    = 3.0
 
}}
 
}}
The '''Change Pen Color by ()''' [[Blocks|block]] is a [[Pen Blocks|Pen block]] and a [[Stack Block|Stack block]]. The block increments or decrements the [[Pen Color (value)|pen's color]] by the specified value. The color value holds 200 different values of colors (0 to 199, inclusive), so color 200 is the same as color 0. In other words, changing the pen color by 200 color will not change the appearance of the pen.
+
The '''Change Pen Color by ()''' [[Blocks|block]] is a [[Pen Extension|Pen block]] and a [[Stack Block|stack block]]. The block increments or decrements the [[Pen Color (value)|pen's color]] by the specified value. There are 200 possible colors (0 to 199, inclusive), so color 200 is the same as color 0. In other words, changing the pen color by 200 color will not change the appearance of the pen. In [[Scratch 3.0]], this block was replaced by {{b|Change Pen () by ()}}.
  
 
== Example Uses ==
 
== Example Uses ==
In [[project]]s that use the pen, the pen ''must'' have a certain color (no transparency allowed) {{-}} this block can change it.
+
In [[project]]s that use the pen, the pen ''must'' have a certain color {{-}} this block can change it.
 +
 
 +
Some common uses for the Change Pen Color by () block are:
  
Some common uses for the '''Change Pen Color by ()''' block are:
 
 
* Iterating through pen color values while the sprite is moved to create colorful art
 
* Iterating through pen color values while the sprite is moved to create colorful art
  
<scratchblocks>
+
<scratchblocks version="2.0">
 
forever  
 
forever  
if <((timer) mod (1)) = [0]> then
+
    if <((timer) mod (1)) = [0]> then
change pen color by (1)
+
        change pen color by (1)
 +
    end
 +
end
 
</scratchblocks>
 
</scratchblocks>
  
 
* Varying pen colors for an art program
 
* Varying pen colors for an art program
  
<scratchblocks>
+
<scratchblocks version="2.0">
 
forever
 
forever
change pen color by (loudness)
+
    change pen color by (loudness)
wait (2) secs
+
    wait (2) secs
 +
end
 
</scratchblocks>
 
</scratchblocks>
  
 
* In projects that "draw" objects with the pen, changing the color of the object(s)
 
* In projects that "draw" objects with the pen, changing the color of the object(s)
  
<scratchblocks>
+
<scratchblocks version="2.0">
 
repeat (360)
 
repeat (360)
move (1) steps
+
    move (1) steps
turn cw (1) degrees
+
    turn cw (1) degrees
change pen color by ((2) / (3.6))
+
    change pen color by ((2) / (3.6))
 
end
 
end
 
</scratchblocks>
 
</scratchblocks>
Line 43: Line 49:
 
However, if the block existed, the Change Pen Color by () block could be replaced with the following code:
 
However, if the block existed, the Change Pen Color by () block could be replaced with the following code:
  
<scratchblocks>
+
<scratchblocks version="2.0">
 
set pen color to ((pen color) + (amount))
 
set pen color to ((pen color) + (amount))
 
</scratchblocks>
 
</scratchblocks>
Line 51: Line 57:
 
One can use the workaround, though it requires a "pen color" [[variable]] and the following script:
 
One can use the workaround, though it requires a "pen color" [[variable]] and the following script:
  
<scratchblocks>
+
<scratchblocks version="2.0">
 
when gf clicked
 
when gf clicked
 
forever
 
forever
set pen color to (pen color)
+
  set pen color to (pen color)
 +
end
 
</scratchblocks>
 
</scratchblocks>
  
Line 63: Line 70:
 
* [[Pen Color (value)|Pen Color]]
 
* [[Pen Color (value)|Pen Color]]
  
{{Pen Blocks}}
+
{{Pen Extension}}
[[Category:Pen Blocks]]
+
{{Removed Blocks}}
 +
[[Category:Pen Extension]]
 
[[de:Ändere Stiftfarbe um () (Block)]]
 
[[de:Ändere Stiftfarbe um () (Block)]]
 
[[ja:ペンの色を () ずつ変える (ブロック)]]
 
[[ja:ペンの色を () ずつ変える (ブロック)]]
 
[[ru:Изменить цвет пера на ()]]
 
[[ru:Изменить цвет пера на ()]]

Revision as of 01:05, 22 June 2019

Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.
Change Pen Color by ()
2.0 Change Pen Color by ().png
Category Pen
Type Stack
Removed in 3.0

The Change Pen Color by () block is a Pen block and a stack block. The block increments or decrements the pen's color by the specified value. There are 200 possible colors (0 to 199, inclusive), so color 200 is the same as color 0. In other words, changing the pen color by 200 color will not change the appearance of the pen. In Scratch 3.0, this block was replaced by Change Pen () by ().

Example Uses

In projects that use the pen, the pen must have a certain color — this block can change it.

Some common uses for the Change Pen Color by () block are:

  • Iterating through pen color values while the sprite is moved to create colorful art
forever 
    if <((timer) mod (1)) = [0]> then
        change pen color by (1)
    end
end
  • Varying pen colors for an art program
forever
    change pen color by (loudness)
    wait (2) secs
end
  • In projects that "draw" objects with the pen, changing the color of the object(s)
repeat (360)
    move (1) steps
    turn cw (1) degrees
    change pen color by ((2) / (3.6))
end

Workaround

This block cannot be replicated with other Scratch blocks, due to the fact that there is no block that holds the pen color.

However, if the block existed, the Change Pen Color by () block could be replaced with the following code:

set pen color to ((pen color) + (amount))

(This is in fact how Scratch handles pen color internally.)

One can use the workaround, though it requires a "pen color" variable and the following script:

when gf clicked
forever
   set pen color to (pen color)
end

To set the pen color, use the Set () to () block; to change it, use the Change () by () block.

See Also