Commit 159cef86 authored by Christian Winter's avatar Christian Winter

brush class introduced

parent a1e457cc
Pipeline #5143703 passed with stage
in 51 seconds
......@@ -12,6 +12,7 @@
<script src="scripts/Preferences.js"></script>
<script src="scripts/Cursor.js"></script>
<script src="scripts/Brush.js"></script>
<script src="scripts/objects/EObject.js"></script>
<script src="scripts/objects/Rectangle.js"></script>
......@@ -270,7 +271,7 @@
<tr title="Color">
<td>Color</td>
<td><input type="color" id="lineColor" name="color" onchange="Application.setCurrentLineColor(Color.hexToColor(value));"></td>
<td><input type="color" id="lineColor" name="color" onchange="Application.setApplication.currentBrush.lineColor(Color.hexToColor(value));"></td>
</tr>
<tr title="Alpha value of the line color">
......
......@@ -7,6 +7,7 @@
this._currentView;
this.cursor = new Cursor();
this.currentBrush = new Brush();
// logic
this.logic = new Logic();
......@@ -214,15 +215,17 @@
Application.redrawAllViews();
}
// TODO move to Brush class?
setCurrentLineAlpha(alpha) {
currentLineColor.a = alpha;
Application.currentBrush.lineColor.a = alpha;
this.useCurrentColorForSelection();
}
// TODO move to Brush class?
setCurrentLineColor(color) {
let alpha = currentLineColor.a;
currentLineColor = color;
currentLineColor.a = alpha;
let alpha = Application.currentBrush.lineColor.a;
Application.currentBrush.lineColor = color;
Application.currentBrush.lineColor.a = alpha;
GUI.lineColor.value = color.toHexString();
this.useCurrentColorForSelection();
......@@ -258,8 +261,8 @@
if (color != undefined)
currentLineColor = color.copy();
GUI.lineColor.value = currentLineColor.toHexString();
Application.currentBrush.lineColor = color.copy();
GUI.lineColor.value = Application.currentBrush.lineColor.toHexString();
if (thickness != undefined)
currentLineThickness = thickness;
......@@ -267,9 +270,9 @@
GUI.lineThickness.value = currentLineThickness;
if (alpha != undefined)
currentLineColor.a = alpha;
Application.currentBrush.lineColor.a = alpha;
GUI.lineAlpha.value = currentLineColor.a;
GUI.lineAlpha.value = Application.currentBrush.lineColor.a;
}
increaseCurrentLineThickness(delta) {
......@@ -294,7 +297,7 @@
useCurrentColorForSelection() {
for (let line of this.currentView.selection.data.lines.concat(this.currentView.selection.data.partialLines))
line.color = currentLineColor.copy();
line.color = Application.currentBrush.lineColor.copy();
Application.redrawAllViews();
}
......
class Brush {
constructor() {
this.lineColor = Color.black();
this.lineThickness = 1;
this.fillColor = Color.transparent();
}
}
......@@ -264,7 +264,7 @@ Utilities = new class {
end = end.addVector(direction.multiply(overshoot));
}
Application.file.currentLayer.data.lines.push(new Line(start, end, currentLineColor, currentLineThickness));
Application.file.currentLayer.data.lines.push(new Line(start, end, Application.currentBrush.lineColor, currentLineThickness));
}
Application.file.updateStats();
......
......@@ -4,14 +4,14 @@
this.start = new LineEnding(x1.x, x1.y, this);
this.end = new LineEnding(y1.x, y1.y, this);
this.color = (x2) ? x2: currentLineColor.copy();
this.color = (x2) ? x2: Application.currentBrush.lineColor.copy();
this._thickness = (y2) ? y2: currentLineThickness;
}
else {
this.start = new LineEnding(x1, y1, this);
this.end = new LineEnding(x2, y2, this);
this.color = (color) ? color : currentLineColor.copy();
this.color = (color) ? color : Application.currentBrush.lineColor.copy();
this._thickness = (_thickness) ? _thickness : currentLineThickness;
}
}
......
......@@ -6,7 +6,6 @@ var offscreenContext;
let toolbar;
let currentLineThickness = 1;
let currentLineColor = Color.black();
let drawPolyLine;
......
......@@ -616,7 +616,7 @@
if (this.view.logic.currentState instanceof DrawingState) {
let start = this.view.logic.currentState.startPos;
let end = Application.cursor.currentPosition;
this.drawLineFromTo(start, end, currentLineThickness, currentLineColor, false);
this.drawLineFromTo(start, end, currentLineThickness, Application.currentBrush.lineColor, false);
} else if (this.view.logic.currentState instanceof MeasureState) {
if (this.view.logic.currentState.startPosLMB && !this.view.logic.currentState.stoppedLMB) {
let start = this.view.logic.currentState.startPosLMB;
......@@ -638,7 +638,7 @@
}
this.drawRealCircle(Application.cursor.currentPosition, currentLineThickness * 0.5, 1, currentLineColor.toString(), false, true, true);
this.drawRealCircle(Application.cursor.currentPosition, currentLineThickness * 0.5, 1, Application.currentBrush.lineColor.toString(), false, true, true);
this.drawRealCircle(Application.cursor.position, Application.cursor.range, 2, Settings.selectionColor, false, true);
if (this.view.logic.currentState instanceof BrushSelectionState)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment