-
-
Notifications
You must be signed in to change notification settings - Fork 272
Extension: "SVG" #2005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Extension: "SVG" #2005
Conversation
🖼 NEW EXTENSION IMAGES
!format |
// Name: SVG | ||
// ID: WRsvg | ||
// Description: Create SVG elements. | ||
// By: WAYLIVES <https://scratch.mit.edu/users/WAYLIVES/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)))
menus: { | ||
LINECAPmenu: { | ||
acceptReporters: true, | ||
items: [ | ||
{ | ||
text: Scratch.translate("round"), | ||
value: "round", | ||
}, | ||
{ | ||
text: Scratch.translate("butt"), | ||
value: "butt", | ||
}, | ||
{ | ||
text: Scratch.translate("square"), | ||
value: "square", | ||
}, | ||
], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve of the new menus, but what is butt
supposed to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check it out now xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.mozilla.org/ru/docs/Web/SVG/Tutorial/Fills_and_Strokes
Ah, that makes sense now. You might want to clarify that in the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I want to make documentation on this topic, because many people don't understand it.
@WAYLIVES |
The fact is that with the help of my extension, you can create a simple SVG code, but this code will not be displayed anywhere, it will be like a variable. |
But with the help of additional extensions, such as "Skins", "Looks+", you can display them on the stage by inserting, so to speak, a variable with an svg code into a specific cell... |
@Brackets-Coder Thank you so much for your help, for your time spent on me. I am very grateful to you! |
You're very welcome |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i may be tough with this review, but your PR has alot of flaws and boilerplate code
docs/WAYLIVES/SVG.md
Outdated
There was a problem hiding this comment.
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 😭🙏
extensions/WAYLIVES/SVG/1.0.1.js
Outdated
"use strict"; | ||
|
||
if (!Scratch.extensions.unsandboxed) { | ||
throw new Error("This example must run unsandboxed"); |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
extensions/WAYLIVES/SVG/1.0.1.js
Outdated
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", | ||
}, | ||
}, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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)
- why are there so many arguments bro 💀
- the opcodes are too generic and aren't releted to the context of the extension at all.
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 + '"'))))))))))))))))))) + "/>" | ||
); | ||
} | ||
|
||
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"] + '"'))))))))))))))))))))) + "/>" | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
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😭 🙏
images/WAYLIVES/SVG.svg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is pretty nice
images/WAYLIVES/Window Settings.svg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this should not exist because it's in another PR of yours.
@hammouda101010 Thank you, very mutch! |
!format |
Extension: "SVG"
With this extension, you can create simple vector images:
Image: