mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-23 16:31:20 +08:00
Add brush presets for pixel and smooth brush
Fix missing translations for brush shape
This commit is contained in:
parent
94ace21c13
commit
d2a1259114
@ -1374,9 +1374,48 @@ const Painter = {
|
||||
this.bitmap.data[idx + 3] = color.a*opacity
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
openBrushOptions() {
|
||||
new Dialog({
|
||||
id: 'brush_options',
|
||||
|
||||
}).show();
|
||||
},
|
||||
loadBrushPreset(preset) {
|
||||
if (preset.size) BarItems.slider_brush_size.setValue(preset.size);
|
||||
if (preset.softness) BarItems.slider_brush_softness.setValue(preset.softness);
|
||||
if (preset.opacity) BarItems.slider_brush_opacity.setValue(preset.opacity);
|
||||
if (preset.color) ColorPanel.set(preset.color);
|
||||
if (preset.shape) {
|
||||
BarItems.brush_shape.set(preset.shape);
|
||||
if (BarItems.brush_shape.onChange) {
|
||||
BarItems.brush_shape.onChange(BarItems.brush_shape);
|
||||
}
|
||||
}
|
||||
if (preset.blend_mode) {
|
||||
BarItems.blend_mode.set(preset.blend_mode);
|
||||
if (BarItems.blend_mode.onChange) {
|
||||
BarItems.blend_mode.onChange(BarItems.blend_modeis);
|
||||
}
|
||||
}
|
||||
},
|
||||
brush_presets: [
|
||||
{
|
||||
size: 1,
|
||||
softness: 0,
|
||||
shape: 'square',
|
||||
blend_mode: 'default'
|
||||
},
|
||||
{
|
||||
size: 5,
|
||||
softness: 70,
|
||||
shape: 'circle',
|
||||
blend_mode: 'default'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
StateMemory.init('brush_presets', 'array')
|
||||
|
||||
BARS.defineActions(function() {
|
||||
|
||||
@ -1438,6 +1477,14 @@ BARS.defineActions(function() {
|
||||
allowed_view_modes: ['textured'],
|
||||
keybind: new Keybind({key: 'b'}),
|
||||
modes: ['paint'],
|
||||
side_menu: new Menu('brush_tool', [
|
||||
{id: 'mode_edit', name: 'Pixel Brush', icon: 'mode_edit', click() {Painter.loadBrushPreset(Painter.brush_presets[0])}},
|
||||
{id: 'brush', name: 'Smooth Brush', icon: 'fa-paint-brush', click() {Painter.loadBrushPreset(Painter.brush_presets[1])}},
|
||||
/*'_',
|
||||
{id: 'brush_settings', name: 'Brush Options...', icon: 'tune', click() {
|
||||
Painter.openBrushOptions();
|
||||
}},*/
|
||||
]),
|
||||
onCanvasClick(data) {
|
||||
Painter.startPaintToolCanvas(data, data.event);
|
||||
},
|
||||
|
@ -894,6 +894,8 @@
|
||||
"action.slider_brush_softness": "Softness",
|
||||
"action.slider_brush_softness.desc": "Softness of the brush in percent",
|
||||
"action.brush_shape": "Brush Shape",
|
||||
"action.brush_shape.square": "Square",
|
||||
"action.brush_shape.circle": "Circle",
|
||||
"action.blend_mode": "Blend Mode",
|
||||
"action.blend_mode.default": "Default",
|
||||
"action.blend_mode.set_opacity": "Set Opacity",
|
||||
|
Loading…
Reference in New Issue
Block a user