Skip to content

Commit 0d0658c

Browse files
authored
Merge pull request #2 from jaoafa/dev
feat: version 1.0
2 parents 6cd68ca + 862e6f0 commit 0d0658c

17 files changed

+1666
-1
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build
2+
.gradle
3+
.idea
4+
images
5+
map
6+
sandbox

README.md

Lines changed: 244 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,245 @@
11
# DynmapProcessor
2-
2+
3+
## Getting Started
4+
Download it from [GitHub Releases](https://github.com/jaoafa/DynmapProcessor/releases), or build it yourself: `./gradlew package`
5+
Then, `java -jar ./DynmapProcessor-1.0.jar --help` to view help.
6+
<details>
7+
<summary>Help output</summary>
8+
9+
```
10+
Usage: main [OPTIONS]
11+
12+
Welcome to Dynmap Processor.
13+
14+
For more detailed information, please refer to
15+
https://github.com/jaoafa/DynmapProcessor#readme
16+
17+
Options:
18+
-i, --input PATH The directory of tile images.
19+
-o, --output PATH The directory to output generated images and metadata.
20+
-c, --cache Whether to allow the use of cached basemap. (Skip
21+
basemap generation from scratch)
22+
-z, --zoom INT Specify the zoom level from 0 to 4 (4 by default)
23+
-g, --grid Whether to enable chunk grid.
24+
-e, --edit Whether to enable image editing.
25+
-m, --markers PATH The file path to the JSON file that configures markers.
26+
-t, --trim TEXT Trim to the specified area. Format: x1,y1,x2,y2
27+
-h, --height INT Height of the map image. Using this with the width
28+
option might cause distortion.
29+
-w, --width INT Width of the map image. Using this with the height
30+
option might cause distortion.
31+
-r, --resize FLOAT Scale up (or down) the output image to the specified
32+
scale rate. (0<x<1 to scale down, 1<x to scale up)
33+
--help Show this message and exit
34+
```
35+
</details>
36+
37+
## Options
38+
| Type | Name | Flags |
39+
|---------|-----------------------------------------------------|------------------|
40+
| `PATH` | [Input](#input--i-or---input) | `-i` `--input` |
41+
| `PATH` | [Output](#output--o-or---output) | `-o` `--output` |
42+
| `BOOL` | [Cache](#cache--c-or---cache) | `-c` `--cache` |
43+
| `INT` | [Zoom level](#zoom-level--z-or---zoom-4-by-default) | `-z` `--zoom` |
44+
| `BOOL` | [Grid](#grid--g-or---grid-false-by-default) | `-g` `--grid` |
45+
| `BOOL` | [Edit](#edit--e-or---edit-false-by-default) | `-e` `--edit` |
46+
| `PATH` | [Markers](#markers--m-or---markers) | `-m` `--markers` |
47+
| `TEXT` | [Trim](#trim--t-or---trim) | `-t` `--trim` |
48+
| `INT` | [Height](#height-and-width--h-w-or---height--width) | `-h` `--height` |
49+
| `INT` | [Width](#height-and-width--h-w-or---height--width) | `-w` `--width` |
50+
| `FLOAT` | [Resize](#resize--r-or---resize-1-by-default) | `-r` `--resize` |
51+
52+
### Input: `-i` or `--input`
53+
> Example: `-i ./input_images`
54+
55+
The directory of tile images.
56+
The directory structure should be the following:
57+
```
58+
input_images
59+
zoom-0
60+
1_-12.png
61+
...
62+
zoom-1
63+
...
64+
zoom-2
65+
...
66+
zoom-3
67+
...
68+
zoom-4
69+
...
70+
```
71+
72+
### Output: `-o` or `--output`
73+
> Example: `-o ./output_images`
74+
75+
The directory to output generated images and metadata.
76+
```
77+
output_images
78+
basemap.png
79+
map-2023-03-76-19-08-35.png
80+
map-2023-03-76-19-09-13.png
81+
metadata.json
82+
```
83+
`basemap.png` is the original unedited map image
84+
`map-{year}-{month}-{date}-{hour}-{minute}-{second}.png` is the edited image as you specified in [markers.json](#marker-file). How to edit image is [here](#edit--e-or---edit-false-by-default).
85+
`metadata.json` is the metadata file that stores resolution, central coordinate, and zoom level.
86+
87+
### Cache: `-c` or `--cache`
88+
> Example: `-c`
89+
90+
Whether to allow the use of cached basemap.
91+
If you use this option and basemap.png already exists, Dynmap Processor will skip the new basemap generation.
92+
93+
### Zoom level: `-z` or `--zoom` (4 by default)
94+
> Example: `-z 3`
95+
96+
Specify the zoom level from 0 to 4.
97+
**2~0 are super dangerous.**
98+
99+
### Grid: `-g` or `--grid` (`false` by default)
100+
> Example: `-g`
101+
102+
Whether to enable chunk grid.
103+
104+
### Edit: `-e` or `--edit` (`false` by default)
105+
> Example: `-e`
106+
107+
Whether to enable image editing.
108+
The edited image is output like [this](#output--o-or---output).
109+
**Note that if you forget to add this option, Dynmap Processor will NOT edit the image.**
110+
Edit options are all the following.
111+
[Markers](#markers--m-or---markers), [Trim](#trim--t-or---trim), [Height](#height-and-width--h-w-or---height--width), [Width](#height-and-width--h-w-or---height--width), and [Resize](#resize--r-or---resize-1-by-default).
112+
Note that the final image will be processed in the following order:
113+
1. draw markers `-m`
114+
2. trim to a specified area `-t`
115+
3. scale width and height `-h,-w`
116+
4. resize the image by the provided rate `-r`
117+
118+
### Markers: `-m` or `--markers`
119+
> Example: `-m ./markers.json`
120+
121+
The file path to the JSON file configures markers.
122+
See [Marker file](#marker-file)
123+
124+
### Trim: `-t` or `--trim`
125+
> Example: `-t 1000,1000,-1000,-1000`
126+
127+
Trim to the specified area.
128+
Format: `x1,y1,x2,y2`
129+
130+
### Height and width: `-h`,`-w` or `--height`,`--width`
131+
> Example: `-w 1000` / `-h 500`
132+
133+
Height or width of the map image.
134+
Using both option at the same time might cause distortion.
135+
136+
### Resize: `-r` or `--resize` (`1` by default)
137+
> Example: `-r 0.8`
138+
139+
Scale up (or down) the output image to the specified scale rate.
140+
`0<x<1` to scale down, `1<x` to scale up.
141+
142+
## Marker file
143+
JSON Schema: `` //todo url
144+
<details>
145+
<summary>Sample file</summary>
146+
147+
```json
148+
{
149+
"markers": [
150+
{
151+
"type": "Area",
152+
"name": "yuuaCity",
153+
"coordinates": [
154+
{
155+
"x": 1070,
156+
"y": -1873
157+
},
158+
{
159+
"x": 1070,
160+
"y": -1764
161+
},
162+
{
163+
"x": 704,
164+
"y": -1764
165+
},
166+
{
167+
"x": 704,
168+
"y": -1430
169+
},
170+
{
171+
"x": 1362,
172+
"y": -1873
173+
},
174+
{
175+
"x": 1362,
176+
"y": -1430
177+
}
178+
],
179+
"color": {
180+
"r": 231,
181+
"g": 214,
182+
"b": 243
183+
},
184+
"overlay": {
185+
"r": 231,
186+
"g": 214,
187+
"b": 243,
188+
"a": 100
189+
}
190+
},
191+
{
192+
"type": "Line",
193+
"name": "Sample Line",
194+
"coordinates": [
195+
{
196+
"x": 511,
197+
"y": -511
198+
},
199+
{
200+
"x": -511,
201+
"y": 511
202+
}
203+
],
204+
"color": {
205+
"r": 255,
206+
"g": 161,
207+
"b": 38
208+
},
209+
"overlay": {
210+
"r": 255,
211+
"g": 161,
212+
"b": 38,
213+
"a": 100
214+
}
215+
},
216+
{
217+
"type": "Circle",
218+
"name": "Sample Circle",
219+
"radius": 100,
220+
"coordinates": [
221+
{
222+
"x": 0,
223+
"y": 31
224+
}
225+
],
226+
"color": {
227+
"r": 187,
228+
"g": 200,
229+
"b": 230
230+
},
231+
"overlay": {
232+
"r": 187,
233+
"g": 200,
234+
"b": 230,
235+
"a": 100
236+
}
237+
}
238+
]
239+
}
240+
```
241+
</details>
242+
243+
244+
## Example
245+
`java -jar ./DynmapProcessor-1.0.jar -i ./images -o ./output -z 4 -e -m ./markers.json`

build.gradle.kts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
kotlin("jvm") version "1.7.21"
5+
kotlin("plugin.serialization") version "1.8.0"
6+
distribution
7+
application
8+
}
9+
10+
group = "com.jaoafa"
11+
version = "1.0"
12+
13+
repositories {
14+
mavenCentral()
15+
}
16+
17+
dependencies {
18+
implementation("com.sksamuel.scrimage:scrimage-core:4.0.32")
19+
implementation("com.github.ajalt.mordant:mordant:2.0.0-beta10")
20+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
21+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
22+
implementation("com.github.ajalt.clikt:clikt:3.5.1")
23+
}
24+
25+
tasks.withType<KotlinCompile> {
26+
kotlinOptions.jvmTarget = "17"
27+
}
28+
29+
application {
30+
mainClass.set("MainKt")
31+
}
32+
33+
val `package` = task("package", type = Jar::class) {
34+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
35+
archiveBaseName.set("DynmapProcessor")
36+
manifest {
37+
attributes["Main-Class"] = "MainKt"
38+
}
39+
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
40+
with(tasks.jar.get() as CopySpec)
41+
}
42+
43+
tasks {
44+
`package`
45+
46+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kotlin.code.style=official

gradle/wrapper/gradle-wrapper.jar

58.4 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)