1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Rough and ready control over bitmap editor line width and colour

Fixes #414
This commit is contained in:
Jermolene 2014-02-21 14:06:04 +00:00
parent d4baf515ed
commit 68bcbff753
4 changed files with 23 additions and 5 deletions

View File

@ -16,6 +16,10 @@ Edit-bitmap widget
var DEFAULT_IMAGE_WIDTH = 300, var DEFAULT_IMAGE_WIDTH = 300,
DEFAULT_IMAGE_HEIGHT = 185; 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 Widget = require("$:/core/modules/widgets/widget.js").widget;
var EditBitmapWidget = function(parseTreeNode,options) { var EditBitmapWidget = function(parseTreeNode,options) {
@ -258,8 +262,8 @@ EditBitmapWidget.prototype.strokeMove = function(x,y) {
// Redraw the previous image // Redraw the previous image
ctx.drawImage(this.currCanvas,0,0); ctx.drawImage(this.currCanvas,0,0);
// Render the stroke // Render the stroke
ctx.strokeStyle = "#ff0"; ctx.strokeStyle = this.wiki.getTiddlerText(LINE_COLOUR_TITLE,"#ff0");
ctx.lineWidth = 3; ctx.lineWidth = parseInt(this.wiki.getTiddlerText(LINE_WIDTH_TITLE,"3"),10);
ctx.lineCap = "round"; ctx.lineCap = "round";
ctx.lineJoin = "round"; ctx.lineJoin = "round";
ctx.beginPath(); ctx.beginPath();

View File

@ -0,0 +1,3 @@
title: $:/config/BitmapEditor/Colour
#ff0

View File

@ -0,0 +1,3 @@
title: $:/config/BitmapEditor/LineWidth
3

View File

@ -1,7 +1,8 @@
title: EditBitmapWidget created: 20131024141900000
created: 201310241419 modified: 20140221140151790
modified: 201310300837
tags: widget tags: widget
title: EditBitmapWidget
type: text/vnd.tiddlywiki
! Introduction ! Introduction
@ -13,3 +14,10 @@ The content of the `<$edit-bitmap>` widget is ignored.
|!Attribute |!Description | |!Attribute |!Description |
|tiddler |The tiddler to edit (defaults to the [[WidgetVariable: currentTiddler]]) | |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"/>