From 68bcbff7535aebda06601eadbbe3213800469e9a Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 21 Feb 2014 14:06:04 +0000 Subject: [PATCH] Rough and ready control over bitmap editor line width and colour Fixes #414 --- core/modules/widgets/edit-bitmap.js | 8 ++++++-- core/wiki/config/BitmapEditorColour.tid | 3 +++ core/wiki/config/BitmapEditorLineWidth.tid | 3 +++ .../tw5.com/tiddlers/widgets/EditBitmapWidget.tid | 14 +++++++++++--- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 core/wiki/config/BitmapEditorColour.tid create mode 100644 core/wiki/config/BitmapEditorLineWidth.tid diff --git a/core/modules/widgets/edit-bitmap.js b/core/modules/widgets/edit-bitmap.js index 40f0e81aa..fd80ef1a3 100644 --- a/core/modules/widgets/edit-bitmap.js +++ b/core/modules/widgets/edit-bitmap.js @@ -16,6 +16,10 @@ Edit-bitmap widget var DEFAULT_IMAGE_WIDTH = 300, DEFAULT_IMAGE_HEIGHT = 185; +// Configuration tiddlers +var LINE_WIDTH_TITLE = "$:/config/BitmapEditor/LineWidth", + LINE_COLOUR_TITLE = "$:/config/BitmapEditor/Colour"; + var Widget = require("$:/core/modules/widgets/widget.js").widget; var EditBitmapWidget = function(parseTreeNode,options) { @@ -258,8 +262,8 @@ EditBitmapWidget.prototype.strokeMove = function(x,y) { // Redraw the previous image ctx.drawImage(this.currCanvas,0,0); // Render the stroke - ctx.strokeStyle = "#ff0"; - ctx.lineWidth = 3; + ctx.strokeStyle = this.wiki.getTiddlerText(LINE_COLOUR_TITLE,"#ff0"); + ctx.lineWidth = parseInt(this.wiki.getTiddlerText(LINE_WIDTH_TITLE,"3"),10); ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.beginPath(); diff --git a/core/wiki/config/BitmapEditorColour.tid b/core/wiki/config/BitmapEditorColour.tid new file mode 100644 index 000000000..7c3902acb --- /dev/null +++ b/core/wiki/config/BitmapEditorColour.tid @@ -0,0 +1,3 @@ +title: $:/config/BitmapEditor/Colour + +#ff0 \ No newline at end of file diff --git a/core/wiki/config/BitmapEditorLineWidth.tid b/core/wiki/config/BitmapEditorLineWidth.tid new file mode 100644 index 000000000..ba51e732c --- /dev/null +++ b/core/wiki/config/BitmapEditorLineWidth.tid @@ -0,0 +1,3 @@ +title: $:/config/BitmapEditor/LineWidth + +3 \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/widgets/EditBitmapWidget.tid b/editions/tw5.com/tiddlers/widgets/EditBitmapWidget.tid index 8dd1988ce..ecc0d8217 100644 --- a/editions/tw5.com/tiddlers/widgets/EditBitmapWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/EditBitmapWidget.tid @@ -1,7 +1,8 @@ -title: EditBitmapWidget -created: 201310241419 -modified: 201310300837 +created: 20131024141900000 +modified: 20140221140151790 tags: widget +title: EditBitmapWidget +type: text/vnd.tiddlywiki ! Introduction @@ -13,3 +14,10 @@ The content of the `<$edit-bitmap>` widget is ignored. |!Attribute |!Description | |tiddler |The tiddler to edit (defaults to the [[WidgetVariable: currentTiddler]]) | + +! Configuration + +The edit bitmap widget can be configured with these system tiddlers: + +* [[$:/config/BitmapEditor/LineWidth]] determines the line width: <$edit-text tiddler="$:/config/BitmapEditor/LineWidth" tag="input"/> +* [[$:/config/BitmapEditor/Colour]] determines the line width: <$edit-text tiddler="$:/config/BitmapEditor/Colour" tag="input" type="color"/>