Configurable canvas size

This commit is contained in:
ctrlcctrlv 2013-08-17 18:00:26 +00:00
parent 7c5222ffb5
commit e3600131fc
3 changed files with 16 additions and 12 deletions

View File

@ -642,15 +642,12 @@
// Allow unfiltered HTML in board subtitle. This is useful for placing icons and links.
$config['allow_subtitle_html'] = false;
/*
* Enable oekaki (お絵描き). This puts a drawing field on your board. You can either
* enable it globally or enable it on a per-board basis. Oekaki's color field
* can be greatly enhanced by installing jscolor from http://jscolor.com/ and installing it in js/
* If you enable oekaki, please remember to also enable its script with:
* $config['additional_javascript'][] = 'js/oekaki.js';
*/
// Oekaki - To enable oekaki, just enable its script with:
// $config['additional_javascript'][] = 'js/oekaki.js';
// $config['oekaki'] holds Oekaki options, which are currently just default canvas size.
$config['oekaki'] = false;
$config['oekaki']['height'] = 250;
$config['oekaki']['width'] = 500;
/*
* ====================

View File

@ -6,7 +6,7 @@ var oekaki_form = '\
Oekaki\
</th>\
<td>\
<canvas width="500" height="250" id="cvs" style="border:1px solid black;-webkit-user-select: none;-moz-user-select: none;">lol what you looking at the source for nerd</canvas>\
<canvas width="'+oekaki_options.width+'" height="'+oekaki_options.height+'" id="oekaki_canvas" style="border:1px solid black;-webkit-user-select: none;-moz-user-select: none;">lol what you looking at the source for nerd</canvas>\
<p><button type="button" id="brushsize">Brush size</button><input class="color" id="color" value="000000" placeholder="Color"/><button type="button" id="text">Set text</button><button type="button" id="clear">Clear</button><button type="button" id="save">Save</button><button type="button" id="load">Load</button><br/>\
<button type="button" id="eraser">Toggle eraser</button><button type="button" id="getcolor">Get color</button><button type="button" id="fill">Fill</button>\
</p><p><textarea id="savebox"></textarea><label><input id="confirm_oekaki" type="checkbox"/> Use oekaki instead of file?</label></p>\
@ -18,7 +18,7 @@ function enable_oekaki() {
// Add oekaki after the file input
$('input[type="file"]').parent().parent().after(oekaki_form);
// Init oekaki vars
canvas = $("#cvs");
canvas = $("#oekaki_canvas");
context = canvas[0].getContext("2d");
is_drawing = false;
text = "";
@ -98,7 +98,7 @@ function flood_fill(x, y, target){
var data = context.getImageData(n[0], n[1], 1, 1).data;
var d = [data[0], data[1], data[2], data[3]];
var t = [target[0], target[1], target[2], target[3]];
if (arraysEqual(d, t) && n[0] < 500 && n[1] < 250 && n[0] > -1 && n[1] > -1){
if (arraysEqual(d, t) && n[0] < canvas.width() && n[1] < canvas.height() && n[0] > -1 && n[1] > -1){
context.putImageData(pixel, n[0], n[1]);
queue.push([n[0], n[1]-1]);
queue.push([n[0], n[1]+1]);

View File

@ -265,7 +265,14 @@ function ready() {
onready(init);
{% endraw %}{% if config.google_analytics %}{% raw %}
{% endraw %}
var oekaki_options = {
width: {{config.oekaki.width}},
height: {{config.oekaki.height}},
};
{% if config.google_analytics %}{% raw %}
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %}