Skip to content

Commit

Permalink
chore: small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Feb 6, 2024
1 parent d6d3dc0 commit e91bda4
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 15 deletions.
2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
},
"toolbar": {
"react": true,
"version": "0.5.1",
"version": "0.5.2",
"style": true,
"icon": false,
"test": true,
Expand Down
17 changes: 10 additions & 7 deletions src/painter/icon.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@font-face {
font-family: 'luna-painter-icon';
src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAe0AAsAAAAADIQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAJgAAADkIwYoDk9TLzIAAAGgAAAAQAAAAFZLyUk5Y21hcAAAAeAAAAEOAAAC/mx4Tu1nbHlmAAAC8AAAAmUAAAOcro6Bx2hlYWQAAAVYAAAANAAAADZzrb5AaGhlYQAABYwAAAAeAAAAJAGRAONobXR4AAAFrAAAABkAAABsBXn//WxvY2EAAAXIAAAAGgAAADgUehUsbWF4cAAABeQAAAAfAAAAIAEpAEluYW1lAAAGBAAAASkAAAIWm5e+CnBvc3QAAAcwAAAAgQAAALaYtVwdeJxNjrsOgjAYhb9ilYqCiojCYJyNA0/gZJwcndyYjAlx8jl8Zk9LNLb503PraTFAQsOR6HS+XMm69vWkxtIv7/9j0z3uLe7L5NlwOs1bOGPLgVtwDEPGap8wDTzSpErMhEbsGEhPWUjJWaohoWBFKWbll9ILuWvlnH60l+aotGulK6Vz9cc/xffEutlz/55T/5zNB71ACld4nGNgZDBhnMDAysDAUMfQAyRloHQCAyeDMQMDEwMrMwNWEJDmmsJwgEH3IzvDCSBXiOE0AwuQZgTJAQBj6AiQeJy10ktuwjAQBuDfJCSBvCAE8lh3VbX36DVoi1REC4iWDeseqCvu5RPAP/YsuqVSx/piZfyMYwBDA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rOrs4yo0prdjpywda5cjYaxeIHkcmRIoJBgbipDktoJNgjQwh71b3UK6YtKvq1VpggwPgqtWCqaJIhlcaGyTWOrBUOPG1K1zGt+FrO5KS5zGreJCMr/u+6t6MT0Q+wbaZKzDDiE1/kg+YO+T89EV6oAAAAeJxdxkkOgjAAQNF+ZFJxnhWPwKEYmtAALYF2w+mNGjf+zfvCE99+/pfiMcMnICQiZs6CJQkr1mzYsmPPgSMnzly4cuPOg5SnCIrBjXUoh3yUg1/nukr6XGmbFa5spA17qUvVRpMxXaZ0/NE467+HggHHSI0kR1PRo7BklDS0TBg6IV55xx9XAA==')
format('woff');
}

Expand All @@ -17,21 +17,24 @@
.icon-brush:before {
content: '\f101';
}
.icon-hand:before {
.icon-eraser:before {
content: '\f102';
}
.icon-paint-bucket:before {
.icon-hand:before {
content: '\f103';
}
.icon-pencil:before {
.icon-paint-bucket:before {
content: '\f104';
}
.icon-zoom-in:before {
.icon-pencil:before {
content: '\f105';
}
.icon-zoom-out:before {
.icon-zoom-in:before {
content: '\f106';
}
.icon-zoom:before {
.icon-zoom-out:before {
content: '\f107';
}
.icon-zoom:before {
content: '\f108';
}
6 changes: 6 additions & 0 deletions src/painter/icon/eraser.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/painter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import $ from 'licia/$'
import each from 'licia/each'
import ResizeSensor from 'licia/ResizeSensor'
import { exportCjs, drag } from '../share/util'
import { Brush, Pencil, Hand, Zoom, PaintBucket, Tool } from './tools'
import { Brush, Pencil, Hand, Zoom, PaintBucket, Eraser, Tool } from './tools'

const $document = $(document as any)

Expand Down Expand Up @@ -40,6 +40,7 @@ export default class Painter extends Component<IOptions> {
private hand: Hand
private zoom: Zoom
private paintBucket: PaintBucket
private eraser: Eraser
private activeLayer: Layer
private resizeSensor: ResizeSensor
private canvasResizeSenor: ResizeSensor
Expand Down Expand Up @@ -75,6 +76,7 @@ export default class Painter extends Component<IOptions> {
this.hand = new Hand(this)
this.zoom = new Zoom(this)
this.paintBucket = new PaintBucket(this)
this.eraser = new Eraser(this)

this.resetViewport()
this.hand.centerCanvas()
Expand Down Expand Up @@ -125,6 +127,8 @@ export default class Painter extends Component<IOptions> {
return this.zoom
case 'paintBucket':
return this.paintBucket
case 'eraser':
return this.eraser
}
}
getCanvas() {
Expand Down Expand Up @@ -152,6 +156,9 @@ export default class Painter extends Component<IOptions> {
<div class="tool" data-tool="pencil">
<span class="icon icon-pencil"></span>
</div>
<div class="tool" data-tool="eraser">
<span class="icon icon-eraser"></span>
</div>
<div class="tool" data-tool="paintBucket">
<span class="icon icon-paint-bucket"></span>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/painter/tools/Eraser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Tool from './Tool'

export default class Eraser extends Tool {}
12 changes: 8 additions & 4 deletions src/painter/tools/Hand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ export default class Hand extends Tool {
super.renderToolbar()

const { toolbar } = this
toolbar.appendButton('100%', () => {
const zoom = this.painter.getTool('zoom') as Zoom
zoom.zoomTo(1)
}, 'hover')
toolbar.appendButton(
'100%',
() => {
const zoom = this.painter.getTool('zoom') as Zoom
zoom.zoomTo(1)
},
'hover'
)
}
}
23 changes: 22 additions & 1 deletion src/painter/tools/PaintBucket.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
import Tool from './Tool'
import Painter from '../'

export default class PaintBucket extends Tool {}
export default class PaintBucket extends Tool {
constructor(painter: Painter) {
super(painter)

this.options = {
tolerance: 0,
}
}
protected renderToolbar() {
super.renderToolbar()

const { toolbar, options } = this

toolbar.appendText('Tolerance:')
toolbar.appendNumber('tolerance', options.tolerance, {
min: 0,
max: 255,
step: 1,
})
}
}
1 change: 1 addition & 0 deletions src/painter/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { default as Hand } from './Hand'
export { default as Zoom } from './Zoom'
export { default as Brush } from './Brush'
export { default as PaintBucket } from './PaintBucket'
export { default as Eraser } from './Eraser'
2 changes: 1 addition & 1 deletion src/toolbar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "toolbar",
"version": "0.5.1",
"version": "0.5.2",
"description": "Application toolbar",
"luna": {
"react": true
Expand Down
2 changes: 2 additions & 0 deletions src/toolbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
display: flex;
white-space: nowrap;
overflow-x: hidden;
font-size: #{$font-size-s-m}px;
border-bottom: 1px solid $color-border;
}

Expand All @@ -26,6 +27,7 @@
margin-top: 4px;
margin-bottom: 4px;
select {
font-size: #{$font-size-s-m}px;
max-width: 200px;
}
}
Expand Down

0 comments on commit e91bda4

Please sign in to comment.