Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions data/icons/tool-arrow-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 28 additions & 3 deletions elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const StaticColor = {
RED: Clutter.Color.new(255, 0, 0, 255)
}

export const Shape = { NONE: 0, LINE: 1, ELLIPSE: 2, RECTANGLE: 3, TEXT: 4, POLYGON: 5, POLYLINE: 6, IMAGE: 7 };
export const Shape = { NONE: 0, LINE: 1, ELLIPSE: 2, RECTANGLE: 3, TEXT: 4, POLYGON: 5, POLYLINE: 6, IMAGE: 7, ARROW: 8 };
export const TextAlignment = { LEFT: 0, CENTER: 1, RIGHT: 2 };
export const Transformation = { TRANSLATION: 0, ROTATION: 1, SCALE_PRESERVE: 2, STRETCH: 3, REFLECTION: 4, INVERSION: 5, SMOOTH: 100 };

Expand Down Expand Up @@ -255,8 +255,7 @@ const _DrawingElement = GObject.registerClass({
cr.moveTo(points[0][0], points[0][1]);
for (let j = 1; j < points.length; j++) {
cr.lineTo(points[j][0], points[j][1]);
}

}
} else if (shape == Shape.ELLIPSE && points.length >= 2) {
let radius = Math.hypot(points[1][0] - points[0][0], points[1][1] - points[0][1]);
let ratio = 1;
Expand Down Expand Up @@ -284,6 +283,21 @@ const _DrawingElement = GObject.registerClass({
if (shape == Shape.POLYGON)
cr.closePath();

} else if (shape == Shape.ARROW && points.length >= 2) {
// Draw the main line
cr.moveTo(points[0][0], points[0][1]);
cr.lineTo(points[1][0], points[1][1]);

// Draw arrowhead
let angle = Math.atan2(points[1][1] - points[0][1], points[1][0] - points[0][0]);
let arrowSize = this.line.lineWidth * 5; // Adjust this multiplier to change arrow size

cr.moveTo(points[1][0], points[1][1]);
cr.lineTo(points[1][0] - arrowSize * Math.cos(angle - Math.PI/6),
points[1][1] - arrowSize * Math.sin(angle - Math.PI/6));
cr.moveTo(points[1][0], points[1][1]);
cr.lineTo(points[1][0] - arrowSize * Math.cos(angle + Math.PI/6),
points[1][1] - arrowSize * Math.sin(angle + Math.PI/6));
}
}

Expand Down Expand Up @@ -427,6 +441,17 @@ const _DrawingElement = GObject.registerClass({
row += ` ${points[i][0]},${points[i][1]}`;
row += `"${transAttribute}/>`;

} else if (this.shape == Shape.ARROW && points.length >= 2) {
let angle = Math.atan2(points[1][1] - points[0][1], points[1][0] - points[0][0]);
let arrowSize = this.line.lineWidth * 5; // Should match the Cairo version

row += `<path ${attributes} d="M${points[0][0]},${points[0][1]} `;
row += `L${points[1][0]},${points[1][1]} `;
row += `M${points[1][0]},${points[1][1]} `;
row += `L${points[1][0] - arrowSize * Math.cos(angle - Math.PI/6)},${points[1][1] - arrowSize * Math.sin(angle - Math.PI/6)} `;
row += `M${points[1][0]},${points[1][1]} `;
row += `L${points[1][0] - arrowSize * Math.cos(angle + Math.PI/6)},${points[1][1] - arrowSize * Math.sin(angle + Math.PI/6)}"`;
row += `${transAttribute}/>`;
}

return row;
Expand Down
2 changes: 1 addition & 1 deletion files.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Icons {
constructor(extension) {
const ICON_NAMES = [
'arc', 'color', 'dashed-line', 'document-export', 'fillrule-evenodd', 'fillrule-nonzero', 'fill', 'full-line', 'linecap', 'linejoin', 'palette', 'smooth', 'stroke',
'tool-ellipse', 'tool-line', 'tool-mirror', 'tool-move', 'tool-none', 'tool-polygon', 'tool-polyline', 'tool-rectangle', 'tool-resize',
'tool-ellipse', 'tool-line', 'tool-mirror', 'tool-move', 'tool-none', 'tool-polygon', 'tool-polyline', 'tool-rectangle', 'tool-resize', 'tool-arrow',
];
const ICON_DIR = extension.dir.get_child('data').get_child('icons');
const THEMED_ICON_NAMES = {
Expand Down
Binary file modified locale/de/LC_MESSAGES/draw-on-your-screen.mo
Binary file not shown.
7 changes: 7 additions & 0 deletions locale/de/LC_MESSAGES/draw-on-your-screen.po
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ msgctxt "drawing-tool"
msgid "Line"
msgstr "Linie"

msgctxt "drawing-tool"
msgid "Arrow"
msgstr "Pfeil"

msgctxt "drawing-tool"
msgid "Ellipse"
msgstr "Ellipse"
Expand Down Expand Up @@ -643,6 +647,9 @@ msgstr "Werkzeug Bild auswählen"
msgid "Select line tool"
msgstr "Werkzeug Linie auswählen"

msgid "Select arrow tool"
msgstr "Werkzeug Pfeil auswählen"

msgid "Select mirror tool"
msgstr "Werkzeug Spiegeln auswählen"

Expand Down
7 changes: 7 additions & 0 deletions locale/draw-on-your-screen.po
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ msgctxt "drawing-tool"
msgid "Line"
msgstr ""

msgctxt "drawing-tool"
msgid "Arrow"
msgstr ""

msgctxt "drawing-tool"
msgid "Ellipse"
msgstr ""
Expand Down Expand Up @@ -648,6 +652,9 @@ msgstr ""
msgid "Select line tool"
msgstr ""

msgid "Select arrow tool"
msgstr ""

msgid "Select mirror tool"
msgstr ""

Expand Down
Binary file added locale/es_ES/LC_MESSAGES/draw-on-your-screen.mo
Binary file not shown.
Loading