{"id":17095623,"url":"https://github.com/meyfa/scratchlib","last_synced_at":"2026-06-18T20:31:23.702Z","repository":{"id":68200503,"uuid":"80340604","full_name":"meyfa/scratchlib","owner":"meyfa","description":"Java library for working with Scratch/BYOB stage files","archived":false,"fork":false,"pushed_at":"2020-08-02T10:44:21.000Z","size":226,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T17:49:01.199Z","etag":null,"topics":["binary","byob","generator","java","java-library","library","reader","scratch","scratch-extension"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meyfa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"meyfa"}},"created_at":"2017-01-29T10:41:20.000Z","updated_at":"2021-10-06T14:23:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"fda8386b-c133-4de4-8152-ff3645aad7c1","html_url":"https://github.com/meyfa/scratchlib","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/meyfa/scratchlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fscratchlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fscratchlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fscratchlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fscratchlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meyfa","download_url":"https://codeload.github.com/meyfa/scratchlib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meyfa%2Fscratchlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34507154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","byob","generator","java","java-library","library","reader","scratch","scratch-extension"],"created_at":"2024-10-14T14:43:22.309Z","updated_at":"2026-06-18T20:31:23.683Z","avatar_url":"https://github.com/meyfa.png","language":"Java","funding_links":["https://github.com/sponsors/meyfa"],"categories":[],"sub_categories":[],"readme":"# scratchlib\n\n[![Build Status](https://travis-ci.com/meyfa/scratchlib.svg?branch=master)](https://travis-ci.com/meyfa/scratchlib)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/2906ba15e9327520e462/test_coverage)](https://codeclimate.com/github/meyfa/scratchlib/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/2906ba15e9327520e462/maintainability)](https://codeclimate.com/github/meyfa/scratchlib/maintainability)\n\nThis is a Java library for working with\n[Scratch](https://scratch.mit.edu/scratch_1.4/) (up to v1.4) and\n[BYOB](http://snap.berkeley.edu/old-byob.html) project files. You can load\nprojects created in those applications or create them with code, change all\nobjects they contain, and also write them out to files.\n\n\n\n## Loading a project\n\n```java\nScratchReader r = new ScratchReader();\ntry {\n    ScratchProject scratchProject = r.read(new File(\"project.sb\"));\n    ScratchProject byobProject = r.read(new File(\"project.ypr\"));\n} catch (IOException e) {\n    e.printStackTrace();\n}\n```\n\n\n\n## Creating a project\n\n```java\nScratchProject project = new ScratchProject(ScratchVersion.SCRATCH14);\n// project is a fully working, albeit empty, Scratch project\n// the following actions are examples of what's possible\n\n// set metadata\nproject.setInfoProperty(ScratchProject.INFO_COMMENT, new ScratchObjectUtf8(\"My awesome project!\"));\n\n// get the stage\nScratchObjectStageMorph stage = project.getStage();\n\n// add a sprite\nScratchObjectSpriteMorph sprite = new ScratchObjectSpriteMorph();\nstage.addSprite(sprite);\n\n// ...\n```\n\n\n\n## Saving a project\n\n```java\nScratchProject project = new ScratchProject(ScratchVersion.SCRATCH14);\n// ... or load it from somewhere\n\nScratchWriter w = new ScratchWriter(new File(\"project.sb\"));\ntry {\n    w.write(project);\n} catch (IOException e) {\n    e.printStackTrace();\n}\n```\n\n\n\n## Image to form conversion\n\nSprite costumes and stage backgrounds require images to be given as \"forms\"\n(either `ScratchObjectForm` or `ScratchObjectColorForm`). Conversion to those\nformats is rather involved, which is why `ScratchFormEncoder` exists:\n\n```java\nBufferedImage img = /* obtain source image here */;\n// convert to form\nScratchObjectForm form = ScratchFormEncoder.encode(img);\n\n// create media object\nScratchObjectImageMedia cos = new ScratchObjectImageMedia();\ncos.setField(ScratchObjectMedia.FIELD_MEDIA_NAME, new ScratchObjectUtf8(\"costume name\"));\ncos.setField(ScratchObjectImageMedia.FIELD_FORM, form);\n\n// use media object - add to sprite, for example\nScratchObjectSpriteMorph sprite = new ScratchObjectSpriteMorph();\nsprite.setField(ScratchObjectSpriteMorph.FIELD_MEDIA, new ScratchObjectOrderedCollection(Arrays.asList(cos)));\nsprite.setField(ScratchObjectSpriteMorph.FIELD_COSTUME, cos);\n```\n\n\n\n## Classes\n\n### Inline: Constants\n\n|  ID | Package                   | Constant Name              |\n| --: | ------------------------- | -------------------------- |\n|   1 | scratchlib.objects        | ScratchObject.NIL          |\n|   2 | scratchlib.objects.inline | ScratchObjectBoolean.TRUE  |\n|   3 | scratchlib.objects.inline | ScratchObjectBoolean.FALSE |\n\n### Inline: Numbers\n\nPackage: `scratchlib.objects.inline`\n\nUse the general `ScratchObjectAbstractNumber` for access, the other classes for\ncreation.\n\n|  ID | Class Name                          | Use for                      |\n| --: | ----------------------------------- | ---------------------------- |\n|   4 | `ScratchObjectSmallInteger`         | `int` values                 |\n|   5 | `ScratchObjectSmallInteger16`       | `short` values               |\n|   6 | `ScratchObjectLargePositiveInteger` | positive `BigDecimal` values |\n|   7 | `ScratchObjectLargeNegativeInteger` | negative `BigDecimal` values |\n|   8 | `ScratchObjectFloat`                | `double` values              |\n\n----\n\n### Fixed format: data\n\nPackage: `scratchlib.objects.fixed.data`\n\nFor the string classes below, use the general `ScratchObjectAbstractString` for\naccess, the other classes for creation.\n\n|  ID | Class Name                 | Use for                        |\n| --: | -------------------------- | ------------------------------ |\n|   9 | `ScratchObjectString`      | ASCII strings                  |\n|  10 | `ScratchObjectSymbol`      | ASCII strings fixed by Scratch |\n|  11 | `ScratchObjectByteArray`   | `byte[]` data                  |\n|  12 | `ScratchObjectSoundBuffer` | sound data                     |\n|  13 | `ScratchObjectBitmap`      | image data                     |\n|  14 | `ScratchObjectUtf8`        | UTF-8 strings                  |\n\n### Fixed format: collections\n\nPackage: `scratchlib.objects.fixed.collections`\n\nFor array, ordered collection, set and identity set, use the general\n`ScratchObjectAbstractCollection` for access, the other classes for creation.\nFor dictionary and identity dictionary, use `ScratchObjectAbstractDictionary`.\n\n|  ID | Class Name                        | Use for                          |\n| --: | --------------------------------- | -------------------------------- |\n|  20 | `ScratchObjectArray`              | lists of objects                 |\n|  21 | `ScratchObjectOrderedCollection`  | lists of objects                 |\n|  22 | `ScratchObjectSet`                | lists of objects                 |\n|  23 | `ScratchObjectIdentitySet`        | lists of objects                 |\n|  24 | `ScratchObjectDictionary`         | maps of objects to other objects |\n|  25 | `ScratchObjectIdentityDictionary` | maps of objects to other objects |\n\n### Fixed format: colors\n\nPackage: `scratchlib.objects.fixed.colors`\n\n|  ID | Class Name                      | Use for                          |\n| --: | ------------------------------- | -------------------------------- |\n|  30 | `ScratchObjectColor`            | colors without transparency      |\n|  31 | `ScratchObjectTranslucentColor` | colors with transparency (alpha) |\n\n### Fixed format: dimensions\n\nPackage: `scratchlib.objects.fixed.dimensions`\n\n|  ID | Class Name               | Use for                             |\n| --: | ------------------------ | ----------------------------------- |\n|  32 | `ScratchObjectPoint`     | 2D points (x, y)                    |\n|  33 | `ScratchObjectRectangle` | 2D rectangles (x, y, width, height) |\n\n### Fixed format: forms\n\nPackage: `scratchlib.objects.fixed.forms`\n\n|  ID | Class Name               | Use for                  |\n| --: | ------------------------ | ------------------------ |\n|  34 | `ScratchObjectForm`      | images                   |\n|  35 | `ScratchObjectColorForm` | images with lookup table |\n\n----\n\n### User-class: morphs\n\nPackage: `scratchlib.objects.user.morphs`\n\n|  ID | Class Name                 | Description                            |\n| --: | -------------------------- | -------------------------------------- |\n| 100 | `ScratchObjectMorph`       | base class for all morphs              |\n| 124 | `ScratchObjectSpriteMorph` | sprites                                |\n| 125 | `ScratchObjectStageMorph`  | the stage                              |\n| 125 | `ScratchObjectListMorph`   | user-created list displayable on stage |\n\n### User-class: media\n\nPackage: `scratchlib.objects.user.media`\n\n|  ID | Class Name                  | Description                |\n| --: | --------------------------- | -------------------------- |\n| 109 | `ScratchObjectSampledSound` | a sound split into samples |\n| 162 | `ScratchObjectImageMedia`   | media container for images |\n| 164 | `ScratchObjectSoundMedia`   | media container for sounds |\n\n### User-class: UI\n\nPackage: `scratchlib.objects.user.morphs.ui`\n\n|  ID | Class Name                              | Description                  |\n| --: | --------------------------------------- | ---------------------------- |\n| 104 | `ScratchObjectAlignmentMorph`           | lays out other morphs stage  |\n| 105 | `ScratchObjectStringMorph`              | fixed string display         |\n| 106 | `ScratchObjectUpdatingStringMorph`      | dynamic string display       |\n| 107 | `ScratchObjectSimpleSliderMorph`        | slider                       |\n| 110 | `ScratchObjectImageMorph`               | slider knob                  |\n| 155 | `ScratchObjectWatcherMorph`             | variable watcher             |\n| 173 | `ScratchObjectWatcherReadoutFrameMorph` | variable watcher readout     |\n| 174 | `ScratchObjectWatcherSliderMorph`       | slider extension for watcher |\n\n### User-class: BYOB objects\n\nPackage: `scratchlib.objects.user`\n\n|  ID | Class Name                           | Description                   |\n| --: | ------------------------------------ | ----------------------------- |\n| 201 | `ScratchObjectCustomBlockDefinition` | BYOB's custom blocks          |\n| 205 | `ScratchObjectVariableFrame`         | required for script variables |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeyfa%2Fscratchlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeyfa%2Fscratchlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeyfa%2Fscratchlib/lists"}