| 13 | |
| 14 | |
| 15 | class Sprite(base.ProjectSubcomponent, base.JSONExtractable): |
| 16 | _local_globals: list[base.NamedIDComponent] |
| 17 | asset_data: list[asset.AssetFile] |
| 18 | |
| 19 | def __init__( # noqa: C901 |
| 20 | self, |
| 21 | is_stage: bool = False, |
| 22 | name: str = "", |
| 23 | _current_costume: int = 1, |
| 24 | _layer_order: Optional[int] = None, |
| 25 | _volume: int = 100, |
| 26 | _broadcasts: Optional[list[vlb.Broadcast]] = None, |
| 27 | _variables: Optional[list[vlb.Variable]] = None, |
| 28 | _lists: Optional[list[vlb.List]] = None, |
| 29 | _costumes: Optional[list[asset.Costume]] = None, |
| 30 | _sounds: Optional[list[asset.Sound]] = None, |
| 31 | _comments: Optional[list[comment.Comment]] = None, |
| 32 | _prims: Optional[dict[str, prim.Prim]] = None, |
| 33 | _blocks: Optional[dict[str, block.Block]] = None, |
| 34 | # Stage only: |
| 35 | _tempo: int | float = 60, |
| 36 | _video_state: str = "off", |
| 37 | _video_transparency: int | float = 50, |
| 38 | _text_to_speech_language: str = "en", |
| 39 | _visible: bool = True, |
| 40 | # Sprite only: |
| 41 | _x: int | float = 0, |
| 42 | _y: int | float = 0, |
| 43 | _size: int | float = 100, |
| 44 | _direction: int | float = 90, |
| 45 | _draggable: bool = False, |
| 46 | _rotation_style: str = "all around", |
| 47 | *, |
| 48 | _project: Optional[project.Project] = None, |
| 49 | ): |
| 50 | """ |
| 51 | Represents a sprite or the stage (known internally as a Target) |
| 52 | https://en.scratch-wiki.info/wiki/Scratch_File_Format#Targets |
| 53 | """ |
| 54 | # Defaulting for list parameters |
| 55 | if _broadcasts is None: |
| 56 | _broadcasts = [] |
| 57 | if _variables is None: |
| 58 | _variables = [] |
| 59 | if _lists is None: |
| 60 | _lists = [] |
| 61 | if _costumes is None: |
| 62 | _costumes = [] |
| 63 | if _sounds is None: |
| 64 | _sounds = [] |
| 65 | if _comments is None: |
| 66 | _comments = [] |
| 67 | if _prims is None: |
| 68 | _prims = {} |
| 69 | if _blocks is None: |
| 70 | _blocks = {} |
| 71 | |
| 72 | self.is_stage = is_stage |