mirror of
https://github.com/Akomry/makeyourownapp-jam.git
synced 2025-12-06 08:43:54 +00:00
refactor: transformation de dupliqué en fonction
This commit is contained in:
parent
a464760998
commit
f923dba578
1 changed files with 12 additions and 23 deletions
|
|
@ -371,7 +371,7 @@ public class DrawController implements Initializable {
|
|||
|
||||
private void printLine(MouseEvent mouseEvent) {
|
||||
Canvas currentLayer = layerListView.getSelectionModel().getSelectedItem();
|
||||
if (mouseEvent.isPrimaryButtonDown()) {
|
||||
|
||||
GraphicsContext gc = currentLayer.getGraphicsContext2D();
|
||||
|
||||
if (posX == 0 || posY == 0) {
|
||||
|
|
@ -381,6 +381,8 @@ public class DrawController implements Initializable {
|
|||
|
||||
Stroke stroke = new Stroke(posX, posY, mouseEvent.getX(), mouseEvent.getY(), brushSizeSlider.getValue(), colorPicker.getValue());
|
||||
strokes.add(stroke);
|
||||
|
||||
if (mouseEvent.isPrimaryButtonDown()) {
|
||||
stroke.draw(gc, colorPicker.getValue());
|
||||
|
||||
posX = mouseEvent.getX();
|
||||
|
|
@ -388,15 +390,6 @@ public class DrawController implements Initializable {
|
|||
|
||||
|
||||
} else if (mouseEvent.isSecondaryButtonDown()) {
|
||||
GraphicsContext gc = currentLayer.getGraphicsContext2D();
|
||||
|
||||
if (posX == 0 || posY == 0) {
|
||||
posX = mouseEvent.getX();
|
||||
posY = mouseEvent.getY();
|
||||
}
|
||||
|
||||
Stroke stroke = new Stroke(posX, posY, mouseEvent.getX(), mouseEvent.getY(), brushSizeSlider.getValue(), colorPicker.getValue());
|
||||
strokes.add(stroke);
|
||||
stroke.draw(gc, Color.WHITE);
|
||||
|
||||
posX = mouseEvent.getX();
|
||||
|
|
@ -447,11 +440,7 @@ public class DrawController implements Initializable {
|
|||
lines.sort(new Comparator<Line>() {
|
||||
@Override
|
||||
public int compare(Line o1, Line o2) {
|
||||
if (o1.getTimestamp() < o2.getTimestamp()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return Integer.compare(o2.getTimestamp(), o1.getTimestamp());
|
||||
}
|
||||
});
|
||||
for (Line line: lines) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue