All Projects → scratchblocks → Scratchblocks

scratchblocks / Scratchblocks

Licence: other
Make pictures of Scratch blocks from text.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Scratchblocks

sb-edit
Javascript library for manipulating Scratch project files
Stars: ✭ 33 (-87.16%)
Mutual labels:  scratch
gobo.icu
URL Shortener For Scratch
Stars: ✭ 14 (-94.55%)
Mutual labels:  scratch
codes-scratch-crawler
读书笔记《自己动手写网络爬虫》,自己敲的代码。主要记录了网络爬虫的基本实现,网页去重的算法,网页指纹算法,文本信息挖掘
Stars: ✭ 44 (-82.88%)
Mutual labels:  scratch
lessons
CoderDojo Toronto lessons, worksheets, and exercises. Printable or view online.
Stars: ✭ 23 (-91.05%)
Mutual labels:  scratch
unkillable-scratch
Disallow the *scratch* buffer from being killed
Stars: ✭ 13 (-94.94%)
Mutual labels:  scratch
SRScratchView
A mask imageView class which can be used a scratchView.
Stars: ✭ 52 (-79.77%)
Mutual labels:  scratch
ScratchRadio
Educational software for use with the LimeSDR platform
Stars: ✭ 64 (-75.1%)
Mutual labels:  scratch
Vtracer
Raster to Vector Graphics Converter
Stars: ✭ 257 (+0%)
Mutual labels:  svg
teaching-open
Scratch少儿编程教学平台,集成Scratch、ScratchJr、Python教学工具。包含课程、班级、作业、权限、赛事、社区等。
Stars: ✭ 202 (-21.4%)
Mutual labels:  scratch
desktop
TurboWarp as a desktop app
Stars: ✭ 69 (-73.15%)
Mutual labels:  scratch
books
A collection of online books for data science, computer science and coding!
Stars: ✭ 29 (-88.72%)
Mutual labels:  scratch
ScratchVerifier
Verify Scratch accounts as genuine, for use in authorization or identification.
Stars: ✭ 17 (-93.39%)
Mutual labels:  scratch
first-neural-network
Simple neural network implemented from scratch in C++.
Stars: ✭ 17 (-93.39%)
Mutual labels:  scratch
caddy-scratch
Caddy server 2.0.0 / 1.0.5 on Docker Scratch, all in 18MB / 35MB
Stars: ✭ 32 (-87.55%)
Mutual labels:  scratch
scratch-asset-utils
scratch2和scratch3素材库爬虫和处理工具
Stars: ✭ 29 (-88.72%)
Mutual labels:  scratch
scratching-forth
A compiler from Forth to Scratch
Stars: ✭ 19 (-92.61%)
Mutual labels:  scratch
vue-scratchable
A Vue.js wrapper component that turns everything into fun scratch cards.
Stars: ✭ 42 (-83.66%)
Mutual labels:  scratch
Canvg
Javascript SVG parser and renderer on Canvas
Stars: ✭ 2,963 (+1052.92%)
Mutual labels:  svg
Php Svg
Vector graphics (SVG) library for PHP
Stars: ✭ 256 (-0.39%)
Mutual labels:  svg
ScratchImage
A scratchable UIImageView
Stars: ✭ 31 (-87.94%)
Mutual labels:  scratch

Make pictures of Scratch blocks from text.

Screenshot

Try it out!


scratchblocks is used to write Scratch scripts:

It's MIT licensed, so you can use it in your projects. (But do send me a link on Twitter!)

For the full guide to the syntax, see the wiki.

Usage

MediaWiki

Use the MediaWiki plugin. (This is what the Scratch Wiki uses.)

WordPress

I found a WordPress plugin. It might work for you; I haven't tried it.

Pandoc

Code Club use their own lesson_format tool to generate the PDF versions of their project guides. It uses the pandoc_scratchblocks plugin they wrote to make pictures of Scratch scripts.

This would probably be a good way to write a Scratch book.

HTML

Include a copy of the scratchblocks JS file on your webpage.

<script src="scratchblocks-v3.4-min.js"></script>

The convention is to write scratchblocks inside pre tags with the class blocks:

<pre class="blocks">
when flag clicked
move (10) steps
</pre>

You then need to call scratchblocks.renderMatching after the page has loaded. Make sure this appears at the end of the page (just before the closing </body> tag):

<script>
scratchblocks.renderMatching('pre.blocks', {
  style:     'scratch3',   // Optional, defaults to 'scratch2'.
  languages: ['en', 'de'], // Optional, defaults to ['en'].
});
</script>

The renderMatching() function takes a CSS-style selector for the elements that contain scratchblocks code: we use pre.blocks to target pre tags with the class blocks.

The style option controls how the blocks appear, either the Scratch 2 or Scratch 3 style is supported.

Inline blocks

You might also want to use blocks "inline", inside a paragraph:

I'm rather fond of the <code class="b">stamp</code> block in Scratch.

To allow this, make a second call to renderMatching using the inline argument.

<script>
scratchblocks.renderMatching("pre.blocks", ...)

scratchblocks.renderMatching("code.b", {
  inline: true,
  // Repeat `style` and `languages` options here.
});
</script>

This time we use code.b to target code blocks with the class b.

Translations

You can also include the translations JS file if you want to include non-English blocks, but since that's quite large (nearly 600K?) it's recommended you build your own file with just the locales you need.

For example, a translation file that just loads the German language (ISO code de) would look something like this:

window.scratchblocks.loadLanguages({
    de: <contents of locales/de.json>
})

If you're using a JavaScript bundler you should be able to build your own translations file by calling require() with the path to the locale JSON file. This requires your bundler to allow importing JSON files as JavaScript.

window.scratchblocks.loadLanguages({
    de: require('scratchblocks/locales/de.json'),
})

Browserify

You can use scratchblocks with browserify, if you're into that sort of thing.

Once you've got browserify set up to build a client-side bundle from your app code, you can just add scratchblocks to your dependencies, and everything should Just Work™.

var scratchblocks = require('scratchblocks');
scratchblocks.renderMatching('pre.blocks');

Languages

To update the translations:

npm upgrade scratch-l10n
npm run locales

Adding a language

Each language requires some additional words which aren't in Scratch itself (mainly the words used for the flag and arrow images). I'd be happy to accept pull requests for those! You'll need to rebuild the translations with npm run locales after editing the aliases.

Development

This should set you up and start a http-server for development:

npm install
npm start

Then open http://localhost:8000/ :-)

For more details, see CONTRIBUTING.md.

Credits

Many, many thanks to the contributors!

  • Authored by tjvr
  • Icons derived from Scratch Blocks (Apache License 2.0)
  • Scratch 2 SVG proof-of-concept, shapes & filters by as-com
  • Anna helped with a formula, and pointed out that I can't read graphs
  • JSO designed the syntax and wrote the original Block Plugin
  • Help with translation code from joooni
  • Block translations from the Scratch translation server
  • Ported to node by arve0
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].