Skip to content

Commit

Permalink
remove PIXI types from trellis types
Browse files Browse the repository at this point in the history
  • Loading branch information
mggower committed Nov 6, 2023
1 parent bc58739 commit 8d0520e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,4 @@ export const angle = (x0: number, y0: number, x1: number, y1: number) => {

// exports
export type { Stroke } from './types'
export type { LabelStyle, LabelBackgroundStyle, LabelPosition } from './renderers/webgl/objects/label'
export type { LabelStyle, LabelBackgroundStyle, LabelPosition, FontWeight, TextAlign } from './renderers/webgl/objects/label'
12 changes: 6 additions & 6 deletions src/renderers/webgl/objects/label/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import utils, { STYLE_DEFAULTS } from './utils'
import type { LabelPosition, LabelStyle, LabelBackgroundStyle } from './utils'
import type { LabelPosition, LabelStyle, LabelBackgroundStyle, TextAlign, FontWeight } from './utils'
import type { Stroke } from '../../../../types'
import { BitmapText, Container, Text, TextStyleAlign, TextStyleFill, TextStyleFontWeight } from 'pixi.js'
import { BitmapText, Container, Text } from 'pixi.js'
import { LabelBackground } from './background'

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ export class Label {
this.anchor = utils.getAnchorPoint(position)
}

private set align(align: TextStyleAlign) {
private set align(align: TextAlign) {
if (this.isBitmapText(this.text)) {
if (this.text.align !== align) {
this.dirty = true
Expand Down Expand Up @@ -221,7 +221,7 @@ export class Label {
}
}

private set color(color: TextStyleFill) {
private set color(color: string) {
if (!this.isBitmapText(this.text) && this.text.style.fill !== color) {
this.dirty = true
this.text.style.fill = color
Expand Down Expand Up @@ -254,7 +254,7 @@ export class Label {
}
}

private set fontWeight(fontWeight: TextStyleFontWeight) {
private set fontWeight(fontWeight: FontWeight) {
if (!this.isBitmapText(this.text) && this.text.style.fontWeight !== fontWeight) {
this.dirty = true
this.text.style.fontWeight = fontWeight
Expand Down Expand Up @@ -286,4 +286,4 @@ export class Label {
}

export { LabelBackground } from './background'
export type { LabelStyle, LabelBackgroundStyle, LabelPosition } from './utils'
export type { LabelStyle, LabelBackgroundStyle, LabelPosition, FontWeight, TextAlign } from './utils'
23 changes: 7 additions & 16 deletions src/renderers/webgl/objects/label/utils.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import { MIN_ZOOM } from '../..'
import type { Stroke } from '../../../../types'
import {
Text,
TextStyle,
TextStyleFill,
ITextStyle,
IBitmapTextStyle,
TextStyleAlign,
BitmapFont,
ColorSource,
TextStyleFontWeight,
LINE_JOIN
} from 'pixi.js'
import { Text, TextStyle, ITextStyle, IBitmapTextStyle, BitmapFont, LINE_JOIN } from 'pixi.js'

export type TextAlign = 'left' | 'center' | 'right' | 'justify'
export type FontWeight = 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
export type LabelPosition = 'bottom' | 'left' | 'top' | 'right'

export type LabelBackgroundStyle = {
color: ColorSource
color: string
opacity?: number
padding?: number | number[]
}
Expand All @@ -28,9 +19,9 @@ export type LabelStyle = Partial<{
wordWrap: number
letterSpacing: number
fontFamily: string
fontWeight: TextStyleFontWeight
fontWeight: FontWeight
stroke: Stroke
color: TextStyleFill
color: string
position: LabelPosition
background: LabelBackgroundStyle
}>
Expand Down Expand Up @@ -115,7 +106,7 @@ const isASCII = (str: string) => {
return true
}

const getTextAlign = (position: LabelPosition): TextStyleAlign => {
const getTextAlign = (position: LabelPosition): TextAlign => {
return position === 'left' || position === 'right' ? position : 'center'
}

Expand Down

0 comments on commit 8d0520e

Please sign in to comment.