File size: 5,476 Bytes
55306cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/** Values of the look, as the server keeps them in user_settings.json. */
export type Settings = Record<string, string | number | boolean>

export interface Options {
  fonts: string[]
  sameFont: string
  palettes: string[]
  moods: string[]
  extras: string[]
  shapes: string[]
  themes: string[]
  tails: string[]
  placements: string[]
  symbols: string[]
  /** The same marks with their group and a mask of the shape the renderer draws. An older server does not send it. */
  marks?: { symbol: string; name: string; group: string; mask: string }[]
  defaults: Settings
  settings: Settings
  auto: { enabled: boolean; text: string; caption: string; sfx: string }
}

/** One thing the server drew, with its place in image pixels. */
export interface SceneItem {
  kind: 'bubble' | 'caption' | 'balloon' | 'sfx' | 'region' | 'path' | 'mark'
  text: string
  size: number
  bubble?: number
  box?: [number, number, number, number]
  x?: number
  y?: number
  nominal?: [number, number]
  /** Present on what can be moved by hand: "caption", "sfx:0", ... */
  id?: string
  cx?: number
  cy?: number
  /** Tilt in degrees, counter-clockwise. */
  rotation?: number
  reach?: number
  tall?: boolean
  /** On a sound effect that belongs to an area: the area's id. Its place is the area's. */
  region?: string | number
}

/** One stroke of the hand: an outline that is closed and filled, or a brush stroke. Points are image pixels. */
export type Shape =
  | { type: 'polygon'; points: [number, number][] }
  | { type: 'stroke'; points: [number, number][]; width: number }
  /** Rubs out what the shapes before it painted. */
  | { type: 'erase'; points: [number, number][]; width: number }

export type RegionKind = 'text' | 'sfx' | 'keepout' | 'censor' | 'mark' | 'tone' | 'lines' | 'frame'

/** How a censor area covers the art. */
export type CensorLook = 'bar' | 'white' | 'mosaic' | 'blur' | 'ghost'

/** How a painted area looks: a cover, a tone, lines or a frame. Each kind has its own. */
export type RegionLook = CensorLook | 'dots' | 'hatch' | 'cross' | 'fade' | 'focus' | 'speed' | 'tremor' | 'halo' | 'dashes' | 'border' | 'double' | 'dark' | 'xray'

/** An area drawn on the image: text or an effect is fitted into it, everything keeps out of it, it is

 * covered (censor), or one mark stands in it. */
export interface Region {
  id: string
  kind: RegionKind
  shapes: Shape[]
  text: string
  fill: 'none' | 'light' | 'dark' | 'black' | 'gray' | 'blue' | 'soft'
  /** Tilt in degrees, counter-clockwise; an effect is tilted at random while this is not set. */
  rotation?: number
  /** How large the text or effect is against what the area would give it; 1 when not set. */
  scale?: number
  /** The text runs along the brush stroke and bends with it. */
  follow?: boolean
  /** Along the stroke the other way round. */
  flip?: boolean
  /** Set on a bubble made from a template, so its shape and tail can still be changed. */
  template?: BubbleTemplate
  /** Censor, tone, lines and frame areas: how they look; the kind's first when not set. */
  look?: RegionLook
  /** Mark, tone, lines and frame areas: '#rrggbb', or none for white (a mark) or black. */
  color?: string
}

export type Tool = 'off' | 'bubble' | 'brush' | 'eraser'

export type BubbleShape = 'oval' | 'box' | 'cloud' | 'burst' | 'thought' | 'wavy' | 'jagged' | 'drip' | 'torn' | 'message' | 'soft' | 'label'
export type BubbleTail = 'none' | 'down-left' | 'down' | 'down-right' | 'left' | 'right' | 'up-left' | 'up' | 'up-right'

/** A bubble put on the image from a template: its outline is worked out from these. */
export interface BubbleTemplate {
  shape: BubbleShape
  tail: BubbleTail
  /** Where it stands, in image pixels: x0, y0, x1, y1 (before it is turned). */
  box: [number, number, number, number]
  /** How far it is turned about its middle, in degrees, clockwise. */
  angle?: number
}

/** What was set by hand for one item; the server decides whatever is left out. */
export interface Pin {
  cx?: number
  cy?: number
  size?: number
  rotation?: number
  reach?: number
  tall?: boolean
}

export interface RenderResult {
  version: number
  status: string
  warning: boolean
  empty: boolean
  items: SceneItem[]
  bubbles: [number, number, number, number][]
}

export type Source = 'generation' | 'own'
/** The parts of the side panel that fold. */
export type SectionId = 'bubbles' | 'caption' | 'sfx' | 'areas' | 'all' | 'auto'

/** An image being lettered and what the server last made of it. */
export interface Slot {
  session: string
  width: number
  height: number
  version: number
  empty: boolean
  items: SceneItem[]
  bubbles: [number, number, number, number][]
  /** The inputs of the last finished render, to skip a render that would change nothing. */
  applied: string
  /** What the server said about that render. */
  status: string
  warning: boolean
  /** Places, sizes and tilts set by hand, by item id. */
  pins: Record<string, Pin>
  /** Areas drawn by hand. */
  regions: Region[]
  /** Which image of which generation this is, when the host knows; an image opened again keeps its slot. */
  origin?: string
}

/** What the host page tells the editor about the image in its gallery. */
export interface HostImage {
  tab: string
  url: string | null
  index: number
  count: number
}