mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-18 15:26:19 +08:00
Pixel perfect brush option
This commit is contained in:
parent
d26ae8d543
commit
9142c1a985
@ -902,7 +902,7 @@ const Painter = {
|
||||
interval = Math.sqrt(Math.pow(diff_x/diff_y, 2) + 1)
|
||||
}
|
||||
|
||||
if (Toolbox.selected.brush?.pixel_perfect && BarItems.slider_brush_size.get() == 1) {
|
||||
if (Toolbox.selected.brush?.pixel_perfect && BarItems.pixel_perfect_drawing.value && BarItems.slider_brush_size.get() == 1) {
|
||||
let direction = 0;
|
||||
if (length == 1 && diff_x && !diff_y) {direction = 1;}
|
||||
if (length == 1 && !diff_x && diff_y) {direction = 2;}
|
||||
@ -1572,6 +1572,7 @@ const Painter = {
|
||||
softness: preset.softness == null ? BarItems.slider_brush_softness.get() : preset.softness,
|
||||
use_opacity: preset.opacity !== null,
|
||||
opacity: preset.opacity == null ? BarItems.slider_brush_opacity.get() : preset.opacity,
|
||||
pixel_perfect: preset.pixel_perfect == null ? BarItems.pixel_perfect_drawing.value : preset.pixel_perfect,
|
||||
use_color: preset.color !== null,
|
||||
color: preset.color == null ? ColorPanel.get() : preset.color,
|
||||
shape: preset.shape ? preset.shape : 'unset',
|
||||
@ -1638,6 +1639,7 @@ const Painter = {
|
||||
opacity: {label: ' ', nocolon: true, description: 'action.slider_brush_opacity.desc', type: 'number', condition: form => form.use_opacity, value: 255, min: 0, max: 255},
|
||||
use_softness: {label: 'action.slider_brush_softness', description: 'action.slider_brush_softness.desc', type: 'checkbox'},
|
||||
softness: {label: ' ', nocolon: true, description: 'action.slider_brush_softness.desc', type: 'number', condition: form => form.use_softness, value: 0, min: 0, max: 100},
|
||||
pixel_perfect: {label: 'action.pixel_perfect_drawing', type: 'checkbox'},
|
||||
use_color: {label: 'data.color', type: 'checkbox'},
|
||||
color: {label: ' ', nocolon: true, description: 'action.brush_shape.desc', type: 'color', condition: form => form.use_color},
|
||||
actions: {type: 'buttons', buttons: ['generic.delete'], click() {
|
||||
@ -1697,6 +1699,7 @@ const Painter = {
|
||||
if (typeof preset.size == 'number') BarItems.slider_brush_size.setValue(preset.size);
|
||||
if (typeof preset.softness == 'number') BarItems.slider_brush_softness.setValue(preset.softness);
|
||||
if (typeof preset.opacity == 'number') BarItems.slider_brush_opacity.setValue(preset.opacity);
|
||||
if (preset.pixel_perfect != undefined) BarItems.pixel_perfect_drawing.set(preset.pixel_perfect);
|
||||
if (preset.color) ColorPanel.set(preset.color);
|
||||
if (preset.shape) {
|
||||
BarItems.brush_shape.set(preset.shape);
|
||||
@ -1717,6 +1720,16 @@ const Painter = {
|
||||
default: true,
|
||||
size: 1,
|
||||
softness: 0,
|
||||
pixel_perfect: false,
|
||||
shape: 'square',
|
||||
blend_mode: 'default'
|
||||
},
|
||||
{
|
||||
name: 'menu.brush_presets.pixel_perfect',
|
||||
default: true,
|
||||
size: 1,
|
||||
softness: 0,
|
||||
pixel_perfect: false,
|
||||
shape: 'square',
|
||||
blend_mode: 'default'
|
||||
},
|
||||
@ -1725,6 +1738,7 @@ const Painter = {
|
||||
default: true,
|
||||
size: 5,
|
||||
softness: 70,
|
||||
pixel_perfect: false,
|
||||
shape: 'circle',
|
||||
blend_mode: 'default'
|
||||
}
|
||||
@ -1799,10 +1813,14 @@ BARS.defineActions(function() {
|
||||
BarItems.brush_tool.select();
|
||||
Painter.loadBrushPreset(Painter.default_brush_presets[0])
|
||||
}},
|
||||
{name: 'menu.brush_presets.smooth_brush', icon: 'fa-paint-brush', click() {
|
||||
{name: 'menu.brush_presets.pixel_perfect_brush', icon: 'stylus_note', click() {
|
||||
BarItems.brush_tool.select();
|
||||
Painter.loadBrushPreset(Painter.default_brush_presets[1])
|
||||
}},
|
||||
{name: 'menu.brush_presets.smooth_brush', icon: 'fa-paint-brush', click() {
|
||||
BarItems.brush_tool.select();
|
||||
Painter.loadBrushPreset(Painter.default_brush_presets[2])
|
||||
}},
|
||||
];
|
||||
StateMemory.brush_presets.forEach((preset) => {
|
||||
let menu_entry = {
|
||||
@ -2418,4 +2436,9 @@ BARS.defineActions(function() {
|
||||
}
|
||||
}
|
||||
})
|
||||
new Toggle('pixel_perfect_drawing', {
|
||||
icon: 'stylus_laser_pointer',
|
||||
category: 'view',
|
||||
condition: () => Toolbox && Toolbox.selected.brush?.pixel_perfect == true,
|
||||
})
|
||||
})
|
||||
|
@ -1010,6 +1010,8 @@
|
||||
"action.slider_brush_opacity.desc": "Opacity of the brush from 0 to 255",
|
||||
"action.slider_brush_softness": "Softness",
|
||||
"action.slider_brush_softness.desc": "Softness of the brush in percent",
|
||||
"action.pixel_perfect_drawing": "Pixel Perfect Drawing",
|
||||
"action.pixel_perfect_drawing.desc": "Draw smooth pixel-art lines without double pixels at curves",
|
||||
"action.brush_shape": "Brush Shape",
|
||||
"action.brush_shape.square": "Square",
|
||||
"action.brush_shape.circle": "Circle",
|
||||
@ -1715,6 +1717,7 @@
|
||||
|
||||
"menu.brush_presets.dialog": "Brush Presets...",
|
||||
"menu.brush_presets.pixel_brush": "Pixel Brush",
|
||||
"menu.brush_presets.pixel_perfect": "Pixel-perfect Brush",
|
||||
"menu.brush_presets.smooth_brush": "Smooth Brush",
|
||||
|
||||
"menu.palette.load.default": "Default",
|
||||
|
Loading…
Reference in New Issue
Block a user