File size: 5,124 Bytes
2a261b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/** How the new text is drawn. The server keeps the same names (text_fix/web.py, LOOK_DEFAULTS). */
export interface Look {
  font: string
  color: string
  ownColor: boolean
  size: number
  fill: number
  matchWeight: boolean
  weight: number
  uneven: number
  seed: number
  shading: number
  opacity: number
  soften: number
  shiftX: number
  shiftY: number
  /** A second color for the lower part of each line. */
  twoColors: boolean
  color2: string
  /** 0: the two colors meet at a sharp edge; 1: one runs into the other. */
  split: number
  /** Width of the outline, in letter heights; 0 for none. */
  outline: number
  outlineColor: string
  /** How dark the cast shadow is; 0 for none. */
  shadow: number
  shadowColor: string
  shadowX: number
  shadowY: number
  shadowBlur: number
  effect: Effect
  effectStrength: number
  /** How much the letters follow the folds of the surface. */
  relief: number
}

export type Effect = 'none' | 'embroidery' | 'stencil' | 'neon' | 'engraving'

/** The settings of the model pass that are kept between sessions. */
export interface Model {
  strength: number
  steps: number
  cfg: number
  sampler: string
  resolution: number
  padding: number
  /** How many passes, each with a seed of its own, to choose from. */
  variants: number
  /** Leave the tags that ask for text out of the prompt, and put "text" in the negative. */
  cleanPrompt: boolean
  /** The ControlNet model that guides the pass by the edges of the letters; empty for none. */
  guide: string
  guideWeight: number
}

/** The variants of the last model pass. */
export interface Variants {
  count: number
  chosen: number
  seeds: number[]
  /** The image version they belong to, for their addresses. */
  version: number
}

export type View = 'result' | 'image' | 'compare'

export type Point = [number, number]

/** How a selection was made: one of the found lines, or a click; and the clicks that extended it.

 * The server turns it back into the selection, on the same image, as often as it is asked. */
export interface Recipe {
  found?: number
  at?: Point
  reach?: number
  extend?: Point[]
  /** Several lines taken as one block. */
  join?: Recipe[]
  /** The place for the new text, set by hand with the handles. */
  shape?: { corners: Point[]; bend: number }
  /** Brush strokes: more to erase with the letters. */
  paint?: Stroke[]
  /** The new text written along this line, drawn by hand, instead of where the old text was. */
  path?: Point[]
  /** The new letters bent by hand: 3 rows x 4 columns of moves, in pixels. */
  warp?: Point[][]
}

export interface Stroke {
  points: Point[]
  radius: number
}

/** A selection as the page draws it. */
export interface Shape {
  outline: Point[]
  quad: Point[]
  /** Where the handles stand: the corners as the text reads, and how far the middle is lifted. */
  corners: Point[]
  bend: number
  color: string
  width: number
  height: number
  /** The new text follows a path drawn by hand: the corner handles do not apply. */
  path?: boolean
  /** Where the points of the hand warp stand before they are moved: 3 rows x 4 columns. */
  grid?: Point[][]
}

export interface FontMatch {
  name: string
  distance: number
}

/** One selected line and what it should say. */
export interface Item {
  key: string
  recipe: Recipe
  shape: Shape
  text: string
  /** The old letters go and nothing is written in their place. */
  erase?: boolean
}

export interface SessionInfo {
  session: string
  width: number
  height: number
  name: string
  found: Shape[]
  prompt: string
  negative: string
  history: number
  version: number
}

export interface Settings {
  look: Look
  model: Model
  reach: number
  showFound: boolean
  /** How the text is looked for: by looks, or with a detector ("auto": the light one when it is here). */
  search: Search
  /** Put what the old letters say into the text field of a new line. */
  readOld: boolean
}

export type Search = 'auto' | 'looks' | 'light' | 'full'

/** The detector's models on the server. */
export interface Models {
  onnx: boolean
  ready: { light: boolean; full: boolean }
  /** Bytes still to fetch for each detector. */
  missing: { light: number; full: number }
  download: { running: boolean; done: number; total: number; current: string; error: string }
  /** The search that actually runs now. */
  inUse: 'looks' | 'light' | 'full'
  folder: string
}

export interface Options {
  fonts: string[]
  samplers: string[]
  /** The ControlNet models the host has; empty when it has none. */
  controlnets?: string[]
  /** Looks saved under a name. */
  presets?: Record<string, Look>
  models?: Models
  canBlend: boolean
  host: 'a1111' | 'comfyui'
  settings: Settings
  defaults: { look: Look; model: Model }
}

export type Mode = 'new' | 'add' | 'extend' | 'brush' | 'path' | 'warp'

export interface Status {
  text: string
  tone: 'info' | 'success' | 'warning' | 'error'
}