banner



To Execute The Art Of Scratching You Must

erase all  stamp  pen down  pen up  set pen color to (#FFFFFF)  change pen (color v) by ()  set pen (color v) to ()  change pen size by ()  set pen size to ()

Pen blocks.

The pen is a feature in Scratch that allows a sprite to draw shapes, plot colored pixels, and so forth on the screen with the pen blocks. Pen was introduced in Scratch 1.0. The pen is derived from Logo's turtle graphics, as are the motion blocks with which the pen is used.

Lines, dots, rectangles, and circles are the easiest shapes to draw, but with enough scripting, any shape can be created.

Pen Blocks

Main article: Pen Extension
  • erase all — Clears all pen marks on the screen
  • stamp — Draws a copy of the Sprite on the Stage
  • pen down — Turns the pen feature on inside a sprite; the sprite will leave pen marks on the screen wherever it moves until the pen is turned off
  • pen up — Turns the pen feature off, stopping a sprite from penning
  • set pen color to (#ffffff) — Sets the color of the pen to a predetermined color
  • change pen ( v) by () — Changes a property of the pen by a given input
  • set pen ( v) to () — Sets a property of the pen to a given input
  • change pen size by () — Changes the size of the pen by a chosen number
  • set pen size to () — Sets the size of the pen to a chosen number

Uses

The pen blocks are often used for:

  • Making Snake style games
  • Making a trail behind a sprite
  • Animating
  • Drawing objects in one sprite, one script projects
  • Drawing patterns
  • Creating graphs
  • Program graphics editors
  • Creating the platform in a Platformer game
  • 3D projects
  • Text Rendering

Transparent Pen

Pen Transparency can be changed using the set pen (transparency v) to () block. Alternatively, it is possible to use a RGBA color as an input to the Set Pen Color to () block, as described below.

Formula

The formula for ARGB is similar to that of RGB (red, green, and blue), but it has an additional value, Alpha (A) for opacity. Alpha is identified by a number 1-255, where 1 is completely transparent and 255 is opaque. The formula for RGB (without Alpha) is:

set pen color to ((((R) * (65536)) + ((G) * (256))) + (B)) // Be sure to use the pen color block with the color input (like the one below), or the colors will not function properly.  set pen color to [#0000FF]        

And the formula for ARGB is:

set pen color to ((((A) * (16777216)) + ((R) * (65536))) + (((G) * (256)) + (B)))        
Note Caution: Make sure the A, R, G, and B values are whole numbers (rounded) so they don't contribute to other colors' values. If any of these might be fractions, use the following code instead:
set pen color to ((((round (A)) * (16777216)) + ((round (R)) * (65536))) + (((round (G)) * (256)) + (round (B))))        

Use Of "Run Without Screen Refresh" Custom Block

Main article: Render Script

Run without screen refresh is a custom block operation that is used to speed up actions by refreshing the screen only after the operation has finished. When you create a custom block, select the checkbox labelled "run without screen refresh". A script that could use the custom block to draw a picture may look like this:

define draw set [repeater v] to (0) // Our variable keeps track of which item to pick on the color list set pen size to (2) // Set the size to 2 to avoid a Flash Player glitch go to x: (-240) y: (180) repeat (360) // Repeat y     repeat (480) // Repeat x         change [repeater v] by (1) // Change our variable by 1         set pen (color v) to (item (repeater) of [list v]) // Set the pen color to what it's meant to be from the list         pen down         pen up         change x by (1)     end     set x to (-240) // Back at the far left of the screen     change y by (-1) end        

or as a variable:

define draw set [repeater v] to (0) // Our variable keeps track of which item to pick on the color list set pen size to (2) // Set the size to 2 to avoid a Flash Player glitch go to x: (-240) y: (180) // Starting pos repeat (360) // Repeat y     repeat (480) // Repeat x         change [repeater v] by (3) // Change our variable by 3 (length of 200, the max color)         set [temporary v] to [] // A temporary variable creating the color from the variable         set [temporary v] to (letter ((repeater) - (2)) of (variable)         set [temporary v] to (join (temporary) (letter ((repeater) - (1)) of (variable))         set [temporary v] to (join (temporary) (letter (repeater) of (variable))         set pen (color v) to (temporary) // Set the pen color to what it's meant to be from the variable         pen down         pen up         change x by (1)     end     set x to (-240) // Back at the far left of the screen     change y by (-1) end        

Of course you are going to have to make a list or variable to contain all the colors, and it's going to have to be 172,800 colors long. However, lower resolution images can be created by tweaking the scripts, and it will require less items for the list. And a few scripts may create an image editor that can save the image you have drawn to a list.

See Also

  • Pen Art Examples
  • Render Script
  • Pen Extension

External Links

SandCastleIcon.png This section has links to websites or programs not trusted by Scratch or hosted by Wikipedia. Remember to stay safe while using the internet, as we cannot guarantee the safety of other websites.
  • Computer Science Logo Style, volume 1, "Turtle Geometry"

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

To Execute The Art Of Scratching You Must

Source: https://en.scratch-wiki.info/wiki/Pen

Posted by: poorewiced2001.blogspot.com

0 Response to "To Execute The Art Of Scratching You Must"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel