Skip to content
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

version 3.3.0.1 #54

Merged
merged 4 commits into from
Jun 12, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
#53 - input data validation. Possible issues - changing size with key…
…board does not work properly.
  • Loading branch information
viliusle committed Jun 12, 2017
commit 064d947f87c7509d0f1335f8c70ac7f2a3e36c41
33 changes: 16 additions & 17 deletions js/draw_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,26 +779,25 @@ function DRAW_TOOLS_CLASS() {
return true;
var brush_type = GUI.action_data().attributes.type;
var color_rgb = HELPER.hex2rgb(COLOR);
var size = GUI.action_data().attributes.size;
var original_size = GUI.action_data().attributes.size;

var size = parseInt(GUI.action_data().attributes.size);

if (type == 'click')
EDIT.save_state();

if (brush_type == 'Brush') {
if (type == 'click') {
//init settings
canvas_active().beginPath();
canvas_active().strokeStyle = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_active().lineWidth = GUI.action_data().attributes.size;
canvas_active().lineWidth = size;
canvas_active().lineCap = 'round';
canvas_active().lineJoin = 'round';

canvas_front.clearRect(0, 0, WIDTH, HEIGHT);
if (ALPHA < 255) {
canvas_front.beginPath();
canvas_front.strokeStyle = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_front.lineWidth = GUI.action_data().attributes.size;
canvas_front.lineWidth = size;
canvas_front.lineCap = 'round';
canvas_front.lineJoin = 'round';
}
Expand All @@ -807,7 +806,7 @@ function DRAW_TOOLS_CLASS() {
canvas_active().shadowBlur = 0;
if (GUI.action_data().attributes.anti_aliasing == true) {
canvas_active().shadowColor = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_active().shadowBlur = Math.round(GUI.action_data().attributes.size);
canvas_active().shadowBlur = Math.round(size);
}
}
else if (type == 'drag' && mouse.last_x != false && mouse.last_y != false) {
Expand All @@ -816,8 +815,8 @@ function DRAW_TOOLS_CLASS() {
var max_speed = 20;
var power = 0.7; //max 1, how much speed reduce size, 1 means reduce to 0

var new_size = original_size - original_size / max_speed * mouse.speed_average * power;
new_size = Math.max(new_size, original_size/4);
var new_size = size - size / max_speed * mouse.speed_average * power;
new_size = Math.max(new_size, size/4);
new_size = Math.round(new_size);
canvas_front.lineWidth = new_size;
canvas_active().lineWidth = new_size;
Expand Down Expand Up @@ -855,7 +854,7 @@ function DRAW_TOOLS_CLASS() {
//if mouse was not moved
if (mouse.click_x == mouse.x && mouse.click_y == mouse.y) {
canvas_active().beginPath();
canvas_active().arc(mouse.x, mouse.y, GUI.action_data().attributes.size / 2, 0, 2 * Math.PI, false);
canvas_active().arc(mouse.x, mouse.y, size / 2, 0, 2 * Math.PI, false);
canvas_active().fillStyle = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_active().fill();
}
Expand All @@ -875,7 +874,7 @@ function DRAW_TOOLS_CLASS() {
canvas_active().strokeStyle = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_active().lineWidth = 0.5;

BezierCurveBrush.draw(canvas_active(), color_rgb, mouse.x, mouse.y, GUI.action_data().attributes.size);
BezierCurveBrush.draw(canvas_active(), color_rgb, mouse.x, mouse.y, size);
}
}
else if (brush_type == 'Chrome') {
Expand All @@ -888,7 +887,7 @@ function DRAW_TOOLS_CLASS() {
canvas_active().strokeStyle = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_active().lineWidth = 1;

chrome_brush.stroke(color_rgb, mouse.x, mouse.y, GUI.action_data().attributes.size);
chrome_brush.stroke(color_rgb, mouse.x, mouse.y, size);
}
}
else if (brush_type == 'Fur') {
Expand All @@ -915,7 +914,7 @@ function DRAW_TOOLS_CLASS() {
b = points[e][0] - points[count][0];
a = points[e][1] - points[count][1];
g = b * b + a * a;
var g_size = Math.round(400 * GUI.action_data().attributes.size);
var g_size = Math.round(400 * size);
if (g < g_size && Math.random() > g / g_size) {
canvas_active().beginPath();
canvas_active().moveTo(f + (b * 0.5), c + (a * 0.5));
Expand All @@ -929,7 +928,7 @@ function DRAW_TOOLS_CLASS() {
}
}
else if (brush_type == 'Grouped') {
groups_n = GUI.action_data().attributes.size;
groups_n = size;
gsize = 10;
random_power = 5;

Expand Down Expand Up @@ -979,7 +978,7 @@ function DRAW_TOOLS_CLASS() {
canvas_active().strokeStyle = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_active().lineWidth = 1;

shaded_brush.stroke(color_rgb, mouse.x, mouse.y, GUI.action_data().attributes.size);
shaded_brush.stroke(color_rgb, mouse.x, mouse.y, size);
}
}
else if (brush_type == 'Sketchy') {
Expand All @@ -992,7 +991,7 @@ function DRAW_TOOLS_CLASS() {
canvas_active().strokeStyle = "rgba(" + color_rgb.r + ", " + color_rgb.g + ", " + color_rgb.b + ", " + ALPHA / 255 + ")";
canvas_active().lineWidth = 1;

sketchy_brush.stroke(color_rgb, mouse.x, mouse.y, GUI.action_data().attributes.size);
sketchy_brush.stroke(color_rgb, mouse.x, mouse.y, size);
}
}
};
Expand Down Expand Up @@ -1111,7 +1110,7 @@ function DRAW_TOOLS_CLASS() {
EL.circle(canvas_front, mouse.x, mouse.y, size);
}
else if (type == 'drag') {
var param1 = GUI.action_data().attributes.power;
var param1 = parseInt(GUI.action_data().attributes.power);
var imageData = canvas_active().getImageData(xx, yy, size, size);
var filtered = ImageFilters.StackBlur(imageData, param1); //add effect
EL.image_round(canvas_active(), mouse.x, mouse.y, size, filtered, document.getElementById("canvas_front"));
Expand Down