Skip to content
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
d8d4660
Merge pull request #1 from TurboWarp/master
WAYLIVES Feb 25, 2025
950a9de
Create 1.0.0.js
WAYLIVES Feb 28, 2025
3d09c90
[Automated] Format code
DangoCat Feb 28, 2025
a1a7359
Update 1.0.0.js
WAYLIVES Feb 28, 2025
e7b0867
Update 1.0.0.js
WAYLIVES Feb 28, 2025
a33d0b2
[Automated] Format code
DangoCat Feb 28, 2025
ea8e1e5
Update 1.0.0.js
WAYLIVES Feb 28, 2025
e01604f
Update 1.0.0.js
WAYLIVES Feb 28, 2025
1188bb5
Update 1.0.0.js
WAYLIVES Feb 28, 2025
a2c43fb
Update 1.0.0.js
WAYLIVES Feb 28, 2025
537c8c7
Update 1.0.0.js
WAYLIVES Feb 28, 2025
5f6b77d
Update 1.0.0.js
WAYLIVES Feb 28, 2025
77c3421
Create Window Settings.svg
WAYLIVES Feb 28, 2025
4e77dc8
Update 1.0.0.js
WAYLIVES Feb 28, 2025
02ebdfd
Rename 1.0.0.js to 1.0.0.js
WAYLIVES Feb 28, 2025
e4e2c9f
Rename Window Settings.svg to Window Settings.svg
WAYLIVES Feb 28, 2025
db656c4
Update and rename 1.0.0.js to 2.0.0.js
WAYLIVES Mar 1, 2025
2411fe3
Update 2.0.0.js
WAYLIVES Mar 1, 2025
46abee7
Create 1.0.1.js
WAYLIVES Mar 2, 2025
1ff413f
Delete extensions/WAYLIVES/SVG directory
WAYLIVES Mar 2, 2025
568253c
Create 1.0.1.js
WAYLIVES Mar 2, 2025
8331ebd
Delete extensions/WAYLIVES/Window Settings/SVG directory
WAYLIVES Mar 2, 2025
bf6a38f
Create 1.0.1.js
WAYLIVES Mar 2, 2025
e198545
[Automated] Format code
DangoCat Mar 2, 2025
90d23ab
Update 1.0.1.js
WAYLIVES Mar 3, 2025
36f60c6
[Automated] Format code
DangoCat Mar 3, 2025
0831d51
Update 1.0.1.js
WAYLIVES Mar 3, 2025
4bfba54
Update 1.0.1.js
WAYLIVES Mar 3, 2025
d618b30
Update 1.0.1.js
WAYLIVES Mar 3, 2025
c66d90c
Update 1.0.1.js
WAYLIVES Mar 3, 2025
926a0b3
Update 1.0.1.js
WAYLIVES Mar 3, 2025
70d66d4
Update 1.0.1.js
WAYLIVES Mar 3, 2025
487e7ad
[Automated] Format code
DangoCat Mar 3, 2025
e3e9b88
Create SVG.svg
WAYLIVES Mar 3, 2025
a803ef6
Update 1.0.1.js
WAYLIVES Mar 3, 2025
38c8a1f
[Automated] Format code
DangoCat Mar 3, 2025
acecb61
Update 1.0.1.js
WAYLIVES Mar 4, 2025
669d9bd
Update 1.0.1.js
WAYLIVES Mar 4, 2025
b178019
Update 1.0.1.js
WAYLIVES Mar 4, 2025
ea6a2b2
Update 1.0.1.js
WAYLIVES Mar 4, 2025
dad2315
[Automated] Format code
DangoCat Mar 4, 2025
acd5f75
Update 1.0.1.js
WAYLIVES Mar 4, 2025
ae3eed2
Update 1.0.1.js
WAYLIVES Mar 4, 2025
618e2a0
Update 1.0.1.js
WAYLIVES Mar 4, 2025
4a4f4f3
Update 1.0.1.js
WAYLIVES Mar 4, 2025
f2f0f5a
[Automated] Format code
DangoCat Mar 4, 2025
147f340
Delete extensions/WAYLIVES/Window Settings directory
WAYLIVES Mar 4, 2025
fdd49ac
Update extensions.json
WAYLIVES Mar 4, 2025
eaa65e7
Create SVG.md
WAYLIVES Mar 5, 2025
9fb195b
Update SVG.md
WAYLIVES Mar 5, 2025
808a8b5
Update SVG.md
WAYLIVES Mar 5, 2025
d06fcd9
Update SVG.md
WAYLIVES Mar 5, 2025
7afe800
Update SVG.md
WAYLIVES Mar 5, 2025
385cc0f
Update SVG.md
WAYLIVES Mar 5, 2025
4fdd134
Update 1.0.1.js
WAYLIVES Mar 5, 2025
41ea579
Update 1.0.1.js
WAYLIVES Mar 5, 2025
d9f1c7a
Delete images/WAYLIVES/Window Settings.svg
WAYLIVES Mar 5, 2025
50a3324
Update SVG.md
WAYLIVES Mar 5, 2025
2645267
Update SVG.md
WAYLIVES Mar 5, 2025
0955787
Add files via upload
WAYLIVES Mar 5, 2025
a51e001
Update SVG.md
WAYLIVES Mar 5, 2025
a9fa4e1
Delete samples/SVG.sb3
WAYLIVES Mar 5, 2025
40cac2a
Update 1.0.1.js
WAYLIVES Mar 7, 2025
5b3ee0a
[Automated] Format code
DangoCat Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docs/WAYLIVES/SVG.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bro wth are the docs in russian 😭🙏

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SVG

SVG - это XML язык, который преднозначен для рисования векторых изображений. Изображения бывают двух видов: растровыми и векторными, так вот с помощью SVG можно рисовать именно векторную графику.

Пример векторного и растрового изображения:

<img src="https://github.com/WAYLIVES/my-extensions/blob/main/extensions/SVG/doc/11.png">
&emsp;<i>- Данное изображение принадлежит @WAYLIVES</i>

##

С помощью расширения "SVG" Вы сможете создавать код простых SVG изображений, где будут доступны такие элементы:
- линия
- прямоугольник
- круг

## Блоки
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still a Russian heading here...

### SVG-frame:
```scratch
(SVG-frame // width:[100] height:[100] elements in svg:[...] :: #9823FF)
```
<img src="https://github.com/WAYLIVES/my-extensions/blob/main/extensions/SVG/doc/s1.svg">

Без этого блока ничего не будет работать, он задаёт начало и конец векторным изображениям.

(width) - здесь вы задаёте ширину формата SVG

(height) - здесь вы задаёте высоту формата SVG

(elements in svg) - сюда вы можете вставлять SVG элементы, с помощью которых будете рисовать изображения

### Line:

```scratch
(LINE // x1, y1:[4][4] x2, y2:[96][96] width:[8] color:[#FF0000] opacity:[100]% dash, gap:[0][0] linecap:[round v] :: #9823FF)
```
<img src="https://github.com/WAYLIVES/my-extensions/blob/main/extensions/SVG/doc/s2.svg">

### Rect:

```scratch
(RECT // x, y:[4][4] width:[92] height:[92] radius:[20] fill color:[#FF0000] fill opacity:[100]% stroke width:[8] stroke color[#000000] stroke opacity:[100]% dash, gap:[0][0] stroke linecap:[round v] :: #9823FF)
```
<img src="https://github.com/WAYLIVES/my-extensions/blob/main/extensions/SVG/doc/s3.svg">

### Ellipse:

```scratch
(ELLIPSE // cx, cy:[50][50] width:[92] height:[92] fill color:[#FF0000] fill opacity:[100]% stroke width:[8] stroke color[#000000] stroke opacity:[100]% dash, gap:[0][0] stroke linecap:[round v] :: #9823FF)
```
<img src="https://github.com/WAYLIVES/my-extensions/blob/main/extensions/SVG/doc/s4.svg">

## Пример-проект
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.


```scratch
(SVG-frame // width:(100) height:(100) elements in svg:(...))
```

<img src="https://github.com/WAYLIVES/my-extensions/blob/main/extensions/SVG/doc/12.png">
<img src="https://github.com/WAYLIVES/my-extensions/blob/main/extensions/SVG/doc/13.png">
271 changes: 271 additions & 0 deletions extensions/WAYLIVES/SVG/1.0.1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
// Name: SVG
// ID: WRsvg
// Description: Create SVG elements.
// By: WAYLIVES <https://scratch.mit.edu/users/WAYLIVES/>
// License: MIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you choose MIT out of personal preference?


// Version: 1.0.1

(function (Scratch) {
"use strict";

if (!Scratch.extensions.unsandboxed) {
throw new Error("This example must run unsandboxed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you should put the name of the extension instead

}

class svg {
getInfo() {
return {
id: "svg",
Comment on lines +16 to +19

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the extension ID and class name should match the ID in the given metadata

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id: "svg",
id: "WRsvg",

name: Scratch.translate("SVG"),
color1: "#9823FF",
color2: "#7C2DC1",
color3: "#2D3548",
blocks: [
{
opcode: "svg",
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate(
"SVG-frame // width: [WIDTH] height: [HEIGHT] elements in svg: [ELEMENTS]"
),
arguments: {
WIDTH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
HEIGHT: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
ELEMENTS: {
type: Scratch.ArgumentType.STRING,
defaultValue: "<path ... />",
},
},
},

"---",

{
opcode: "line",
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate(
"LINE // x1, y1: [XA][YA] x2, y2: [XB][YB] width: [WIDTH] color: [COLOR] opacity: [OPACITY]% dash, gap: [DASH][GAP] linecap: [LINECAP]"
),
arguments: {
XA: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "4",
},
YA: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "4",
},
XB: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "96",
},
YB: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "96",
},
WIDTH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "8",
},
COLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#ff0000",
},
OPACITY: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
DASH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
GAP: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
LINECAP: {
type: Scratch.ArgumentType.STRING,
menu: "LINECAPmenu",
},
},
},

{
opcode: "rect",
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate(
"RECT // x, y: [X][Y] width: [WIDTH] height: [HEIGHT] radius: [RADIUS] fill color: [FILLCOLOR] fill opacity: [FILLOPACITY]% stroke width: [STROKEWIDTH] stroke color: [STROKECOLOR] stroke opacity: [STROKEOPACITY]% dash, gap: [DASH][GAP] stroke linecap: [LINECAP]"
),
arguments: {
X: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "4",
},
Y: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "4",
},
WIDTH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "92",
},
HEIGHT: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "92",
},
RADIUS: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "20",
},
FILLCOLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#ff0000",
},
FILLOPACITY: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
STROKEWIDTH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "8",
},
STROKECOLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#000000",
},
STROKEOPACITY: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
DASH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
GAP: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
LINECAP: {
type: Scratch.ArgumentType.STRING,
menu: "LINECAPmenu",
},
},
},

{
opcode: "ellipse",
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate(
"ELLIPSE // cx, cy: [CX][CY] width: [WIDTH] height: [HEIGHT] fill color: [FILLCOLOR] fill opacity: [FILLOPACITY]% stroke width: [STROKEWIDTH] stroke color: [STROKECOLOR] stroke opacity: [STROKEOPACITY]% dash, gap: [DASH][GAP] stroke linecap: [LINECAP]"
),
arguments: {
CX: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "50",
},
CY: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "50",
},
WIDTH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "92",
},
HEIGHT: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "92",
},
FILLCOLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#ff0000",
},
FILLOPACITY: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
STROKEWIDTH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "8",
},
STROKECOLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#000000",
},
STROKEOPACITY: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
DASH: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
GAP: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
LINECAP: {
type: Scratch.ArgumentType.STRING,
menu: "LINECAPmenu",
},
},
},
],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. the blocks text are really, really bad and aren't following best practices (especialy if you use //, because that's how you would make comments on javascript)
  2. why are there so many arguments bro 💀
  3. the opcodes are too generic and aren't releted to the context of the extension at all.

menus: {
LINECAPmenu: {
acceptReporters: true,
items: [
{
text: Scratch.translate("round"),
value: "round",
},
{
text: Scratch.translate("butt"),
value: "butt",
},
{
text: Scratch.translate("square"),
value: "square",
},
],
},
},
};
}

svg(args) {
// prettier-ignore
return (
'<svg width="' + (args["WIDTH"] + ('" height="' + (args["HEIGHT"] + ('" viewBox="' + ("0 0 " + (args["WIDTH"] + (" " + (args["HEIGHT"] + ('" fill="' + ("none" + ('" xmlns="' + ("http://www.w3.org/2000/svg" + ('">' + args["ELEMENTS"]))))))))))))) + "</svg>"
);
}

line(args) {
// prettier-ignore
return (
'<line x1="' + (args["XA"] + ('" y1="' + (args["YA"] + ('" x2="' + (args["XB"] + ('" y2="' + (args["YB"] + ('" stroke-width="' + (args["WIDTH"] + ('" stroke="' + (args["COLOR"] + ('" stroke-dasharray="' + (args["DASH"] + (" " + (args["GAP"] + ('" stroke-linecap="' + (args["LINECAP"] + ('" stroke-opacity="' + (args["OPACITY"] / 100 + '"'))))))))))))))))))) + "/>"
);
Comment on lines +254 to +263
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier still decided to format these even though you said ignore... ??

}

rect(args) {
// prettier-ignore
return (
'<rect x="' + (args["X"] + ('" y="' + (args["Y"] + ('" width="' + (args["WIDTH"] + ('" height="' + (args["HEIGHT"] + ('" rx="' + (args["RADIUS"] + ('" fill="' + (args["FILLCOLOR"] + ('" fill-opacity="' + (args["FILLOPACITY"] / 100 + ('" stroke-width="' + (args["STROKEWIDTH"] + ('" stroke="' + (args["STROKECOLOR"] + ('" stroke-opacity="' + (args["STROKEOPACITY"] / 100 + ('" stroke-dasharray="' + (args["DASH"] + (" " + args["GAP"]) + ('" stroke-linecap="' + (args["LINECAP"] + '"'))))))))))))))))))))))) + "/>"
);
}

ellipse(args) {
// prettier-ignore
return (
'<ellipse cx="' + (args["CX"] + ('" cy="' + (args["CY"] + ('" rx="' + (args["WIDTH"] / 2 + ('" ry="' + (args["HEIGHT"] / 2 + ('" fill="' + (args["FILLCOLOR"] + ('" fill-opacity="' + (args["FILLOPACITY"] / 100 + ('" stroke-width="' + (args["STROKEWIDTH"] + ('" stroke="' + (args["STROKECOLOR"] + ('" stroke-opacity="' + (args["STROKEOPACITY"] / 100 + ('" stroke-dasharray="' + (args["DASH"] + (" " + args["GAP"]) + ('" stroke-linecap="' + (args["LINECAP"] + '"'))))))))))))))))))))) + "/>"
);
}
}
Comment on lines +252 to +279

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is some nasty code out there, it almost looks like Pascal code😭 🙏


Scratch.extensions.register(new svg());
})(Scratch);
1 change: 1 addition & 0 deletions extensions/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"DNin/wake-lock",
"Skyhigh173/json",
"mbw/xml",
"WAYLIVES/SVG",
"numerical-encoding-2",
"cs2627883/numericalencoding",
"SharkPool/Camera",
Expand Down
Loading