28 Commits

Author SHA1 Message Date
7c444cb35d add support for Bitsy 7.10; turn dithering off by default; more help text 2021-11-06 11:15:34 +00:00
a2c92b1e12 move deprecated function call to replacement function 2021-07-03 11:31:06 +01:00
57b841ac3d add clipboard button 2021-07-03 11:29:59 +01:00
3bbf51e5f8 rename download to "done!" 2021-07-03 11:29:26 +01:00
7af54d938b things are ok 2021-07-03 11:28:52 +01:00
f224fe1e27 remove console log 2021-07-03 11:28:33 +01:00
e6fda7266e version update 2021-07-03 11:28:12 +01:00
f223e51195 version update 2021-07-03 11:27:58 +01:00
d72a4df55e remove unused image header 2021-07-03 11:27:27 +01:00
0f23b878b2 version update 2021-05-02 11:47:10 +01:00
23b99b8ea7 fix loading game from textarea (copy/paste) 2021-05-02 11:45:06 +01:00
c8b6c772ab remove debug 2021-04-25 18:49:00 +01:00
52728e601b remove unnecessary trailing semicolon 2021-04-25 17:47:39 +01:00
4bd6286cf0 replace to_string with into for brevity 2021-04-25 17:47:25 +01:00
d53244a884 this is no longer a special feature 2021-04-25 17:46:52 +01:00
f6678f28a9 fix this old broken test 2021-04-25 17:46:25 +01:00
b157007ff3 restrict file types and add help text about game data 2020-11-28 18:33:11 +00:00
704f710047 fix syntax 2020-11-28 15:57:19 +00:00
5c4259d222 better splash page for now 2020-11-28 15:15:40 +00:00
47a9bf5c79 explain 2020-11-09 17:48:26 +00:00
d100473542 try to check for webassembly in a different place 2020-11-09 11:55:11 +00:00
d0946d3ab5 readme; remove todo as it's now in the readme and on gitea 2020-11-09 11:54:45 +00:00
5ee1e908f1 link won't open in same iframe 2020-11-08 21:29:21 +00:00
5788baa0b8 new host for old version 2020-11-08 21:27:05 +00:00
f135e184e4 Merge branch 'Refactor3' 2020-11-08 21:19:10 +00:00
3e7d6eeaa5 include old version 2020-11-08 21:18:51 +00:00
f6308110be try again 2020-11-08 20:53:52 +00:00
21eb632d22 add old version 2020-11-07 19:30:20 +00:00
11 changed files with 134 additions and 45 deletions

View File

@@ -1,19 +1,19 @@
[package]
name = "pixsy"
version = "0.72.7"
version = "0.710.0"
description = "convert images to Bitsy rooms"
authors = ["Max Bradbury <max@tinybird.info>"]
edition = "2018"
license = "MIT"
repository = "https://tinybird.dev/max/image-to-bitsy"
repository = "https://tinybird.dev/max/pixsy"
[lib]
crate-type = ["cdylib"]
[dependencies]
base64 = "^0.12.3"
bitsy-parser = "^0.72.5"
bitsy-parser = "^0.710.0"
image = "^0.23.7"
json = "^0.12.4"
lazy_static = "^1.4.0"
wasm-bindgen = "=0.2.64" # newer versions are bugged...
wasm-bindgen = "^0.2.78"

View File

@@ -1,3 +1,57 @@
# pixsy
convert images to rooms for use in Bitsy
a tool for [Bitsy Game Maker](http://bitsy.org).
upload any image and convert it into a room.
## credits
made by [Max Bradbury](http://tinybird.info/).
makes use of my own [bitsy parser](https://crates.io/crates/bitsy-parser) library.
uses the [Croppie](https://foliotek.github.io/Croppie/) image crop plugin
by [Foliotek](https://www.foliotek.com/)
uses [wasm-bindgen](https://crates.io/crates/wasm-bindgen) to automate WebAssembly bindings.
## thanks
to [Adam Le Doux](http://ledoux.io/) for creating the wonderful and inspiring Bitsy
to [Mark Wonnacott](https://kool.tools/) for their support, encouragement and inspiration
and to everyone in the bitsy community!
## contributing
forks and pull requests welcome!
### development prerequisites
* [rust/cargo](https://rustup.rs/)
* [pug](https://pugjs.org/)
* [less](http://lesscss.org/)
* a bash shell for the build script
## bugs
when importing images, some pixels have errors.
it seems to only happen for pixels surrounded at the top and left:
```
111 111
100 => 110
100 100
```
pixsy does not work in the Itch desktop program
because their bundled version of Chromium does not support WebAssembly.
## to do
* add alternative dithering options (Atkinson, Bayer 8×8)
* add a 'smoothing' (noise reduction?) stage to remove errant pixels
## could do
* reimplement tile reuse option
* add camera support so users can take a pic instead of uploading an image
* allow user to draw to canvas

View File

@@ -1,6 +0,0 @@
# todo
* tile reuse
* noise reduction (remove lonely pixels)
* implement Atkinson and Bayer dithering options
* fix weird problem with pixels flipping (see test::example)

View File

@@ -2,5 +2,5 @@
rm -rf dist
mkdir dist
cp -r README.md LICENSE index.html script.js pkg includes dist
cp -r README.md LICENSE index.html script.js pkg includes old dist
butler push dist ruin/pixsy:html

View File

@@ -22,6 +22,11 @@ button {
white-space: nowrap;
width: 100%;
&.half {
float: left;
width: 50%;
}
&.pagination:not(.normal) {
position: absolute;
bottom: 5vmin;

View File

@@ -8,25 +8,46 @@ html(lang="en-gb")
script(src="includes/croppie.min.js")
body
header
h1
| pixsy
//img(alt="pixsy" src="includes/pixsy.png")
h1 pixsy
p.
convert images to Bitsy rooms
version 0.710.0
|
#[a(href="./old/") old version]
#[a(href="http://tinybird.info/image-to-bitsy/old/" target="_blank") old version]
|
#[a(href="mailto:max@tinybird.info") email]
|
#[a(href="https://twitter.com/synth_ruiner") twitter]
.pages
.page#start
p.
#[b pixsy] is a tool for #[a(href="https://bitsy.org/") Bitsy Game Maker]
that allows you to generate a room from an image and add it to your game.
p.
this version is tested to be compatible with Bitsy version 7.10 and earlier.
later versions may also work fine, but make sure you have a backup of your game data.
p.
#[b pixsy] does not currently work via the Itch desktop program.
if pixsy does not work for you, please try the
#[a(href="http://tinybird.info/image-to-bitsy/old/") old version] instead.
p.
if your image is already the correct size for a bitsy room (128×128),
simply leave the zoom slider at the default setting.
you can draw your room in a pixel-art program and import it here.
p.
full instructions can be found on the
#[a(href="https://ruin.itch.io/pixsy/") itch.io page] -
scroll down to "how to use".
button.normal.pagination.next#new create a new bitsy game
button.normal.pagination.next#load load an existing bitsy game
.page.game-data
h2 game data
input#game(type="file" autocomplete="off")
p.
your game data is available from the #[i game data] window in bitsy,
under the #[i tools] dropdown.
input#game(type="file" accept=".bitsy,.txt" autocomplete="off")
br
textarea#game-data(
@@ -69,26 +90,27 @@ html(lang="en-gb")
#new-palette(style="display: none;")
.half
input#colour-background(type="color" value="#000")
input#colour-background(type="color" value="#000000")
.half
input#colour-foreground(type="color" value="#fff")
input#colour-foreground(type="color" value="#ffffff")
label
input#dither(type="checkbox" checked=true)
input#dither(type="checkbox")
| dither
p (approximates a greyscale effect)
br
button.pagination.prev#back-to-image previous
button.pagination.next#room-next add room
.page.download
h2 done!
p#added
h2 download
textarea#output(autocomplete="off")
br
button#download download
button#clipboard.half copy to clipboard
button#download.half download
button.pagination.prev#add add another image
button.pagination.start#reset start again

View File

@@ -12,10 +12,6 @@ import init, {
set_room_name,
} from './pkg/pixsy.js';
if (typeof WebAssembly !== "object") {
window.location = "./old/"
}
// stolen from https://ourcodeworld.com/articles/read/189/how-to-create-a-file-and-generate-a-download-with-javascript-in-the-browser-without-a-server
function download(filename, text) {
let element = document.createElement('a');
@@ -28,6 +24,18 @@ function download(filename, text) {
document.body.removeChild(element);
}
function copyToClipboard() {
const button = el("clipboard");
el("output").select();
document.execCommand("copy");
button.innerText = "copied!";
setTimeout(() => {
button.innerText = "copy to clipboard";
}, 2000);
}
function el(id) {
return document.getElementById(id);
}
@@ -60,10 +68,15 @@ function readFile(input, callback, type = "text") {
}
async function run() {
if (typeof WebAssembly !== "object") {
window.location = "http://tinybird.info/image-to-bitsy/old/"
}
await init();
const buttonAddImage = el("add");
const buttonBackToImage = el("back-to-image");
const buttonCopyToClipboard = el("clipboard")
const buttonDownload = el("download");
const buttonGameDataProceed = el("game-data-next");
const buttonImageProceed = el("image-next");
@@ -126,14 +139,12 @@ async function run() {
el("game").addEventListener("change", function() {
readFile(this, function (e) {
textareaGameDataInput.value = e.target.result;
console.log(load_game(e.target.result));
checkGameData();
}, "text");
});
function setPaletteDropdown() {
const palettes = JSON.parse(get_palettes());
console.debug(palettes);
selectPalette.innerHTML = "";
@@ -153,7 +164,9 @@ async function run() {
}
function checkGameData() {
if (textareaGameDataInput.value.length > 0) {
let result = load_game(textareaGameDataInput.value)
if (result === "Loaded game") {
buttonGameDataProceed.removeAttribute("disabled");
setPaletteDropdown();
} else {
@@ -241,6 +254,9 @@ async function run() {
download("output.bitsy", textareaGameDataOutput.value);
}
buttonCopyToClipboard.addEventListener("click", copyToClipboard);
buttonCopyToClipboard.addEventListener("touchend", copyToClipboard);
buttonDownload.addEventListener("click", handleDownload);
buttonDownload.addEventListener("touchend", handleDownload);
@@ -261,8 +277,8 @@ async function run() {
inputRoomName.value = "";
selectPalette.innerHTML = "";
divNewPalette.style.display = "none";
inputColourBackground.value = "#000";
inputColourForeground.value = "#fff";
inputColourBackground.value = "#000000";
inputColourForeground.value = "#ffffff";
checkboxDither.checked = true;
}

View File

@@ -1,5 +1,3 @@
#![feature(clamp)]
use bitsy_parser::game::Game;
use bitsy_parser::image::Image;
use bitsy_parser::tile::Tile;
@@ -43,7 +41,7 @@ lazy_static! {
image: None,
room_name: None,
palette: SelectedPalette::None,
dither: true,
dither: false,
brightness: 0,
}
);
@@ -201,7 +199,7 @@ fn palette_from(bg: &bitsy_parser::Colour, fg: &bitsy_parser::Colour) -> bitsy_p
}
fn render_preview(state: &State) -> DynamicImage {
let mut buffer = state.image.as_ref().unwrap().clone().into_rgba();
let mut buffer = state.image.as_ref().unwrap().clone().into_rgba8();
let palette = match &state.palette {
SelectedPalette::None => bitsy_parser::mock::game_default().palettes[0].clone(),
@@ -249,18 +247,18 @@ pub fn add_room() -> String {
let mut state = STATE.lock().expect("Couldn't lock application state");
if state.game.is_none() {
return "No game data loaded".to_string();
return "No game data loaded".into();
}
match &state.palette {
SelectedPalette::None => { return "No palette selected".to_string(); },
SelectedPalette::None => { return "No palette selected".into(); },
_ => {}
};
let mut game = state.game.clone().unwrap();
if state.image.is_none() {
return "No image loaded".to_string();
return "No image loaded".into();
}
let palette_id = Some(match &state.palette {
@@ -292,7 +290,7 @@ pub fn add_room() -> String {
fn colour_match(a: &image::Rgb<u8>, b: &bitsy_parser::Colour) -> u8 {
if a[0] == b.red && a[1] == b.green && a[2] == b.blue { 1 } else { 0 }
};
}
for y in (row * SD)..((row + 1) * SD) {
for x in (column * SD)..((column + 1) * SD) {
@@ -379,7 +377,7 @@ mod test {
load_default_game();
load_image(include_str!("test-resources/colour_input.png.base64").trim().to_string());
let output = get_preview();
let expected = include_str!("test-resources/colour_input.png.base64.greyscale").trim();
let expected = include_str!("test-resources/colour_input.png.base64.blueprint").trim();
assert_eq!(output, expected);
}

View File

@@ -0,0 +1 @@
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAIvUlEQVR4nO2YwbHsuBEEVzbJDvn0PZERskM27UYeMqKiAyA5Q3DAGTAv1dUAe9iPdXr/+vPfv//+62FZngAszhOAxXkCsDhPABbnCcDiPAFYnCcAi/MEYHGeACzOE4DFeQKwOE8AFucJwOI8AVicJwCL8wRgcZ4ALM4TgMV5ArA4TwAW5wnA4jwBWJwnAIvzBGBxngDs8Od////rz3/+3dVv5wlAg6Mf13vqN7JkAPxgqvR8TxN76rewVAB6H6f2q2/hHfVbWSoA4kdTped7mthTv4UlAuBHUSu1Xz0c7YF99c4sEYDEj6JKz6vS81W/hZ8OgB+jqux5qf3qv5mfDkCP/IBZg16Vnq/6bfx0APwoVSu9PuRZ1r/CTweghx9Shayheun1v5UlA9Dj1z7uEZYOwIofvLJ0AB6eACzPE4DFeQKwOE8AFucJwOI8AVicJwCL8wRgcZ4AFN7572B9pvo7s2QAWh8oe1lvUe9V/w0sEQA/jCpb3rqnsufvzs8GYOtD1LPq96j39SpkfWd+LgCtP7w9VXp+TyHrytbZ3fi5ALzDkQ/WumOvqlR/R54ABH6wnkLWLfbO78YTgDfwI/cUsr4zTwA6+AF7+issGwA+pLzzQXme53r6LSwfgL2PxT3uVE1avZFcOf8rAjD6D8C85NXZPM8z6jfzFQEYDR9O9j4gd7lTFahBPwrmjp7ZY8kAwCt/5FfunuWTvwXLBuAo+UGyvppP/dZXBOBTf4w7UHetfjS3CIBLVoWsZzDr9z/1u1MDsLXk1tkvU/eufjRTAlCX0quiV1eh7lv9SKYEQFqLtXrQ6/8Sdcfqr2BqAMRFVbBWVyJ3tlZHc4sAVFrLtnq/Rt2x+iuYGgAXrCp7/lepe1Y/kqkBaFGX3fO/gnupkDVUP4JpAXCZqpA1VL8aV+4/L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R3GbAFRYkr4q1Vc839MK/VEwn3mpSavXwntqQm8EtwkAC6VWal9f9SjeV4F6BM4T5tJTJb212sIzdBS3CUCFJe1nvYd397QFZyNwPvOsk15fPK9aoX+W6QFgMRZJlZ7v6SvkM9boCJiVMJeeKvqqPfKcegTTAwAuJSyXvep7eG9Pe3A+An6DWWiLrTPI86zFHnqW6QFgEWGhI76nR8n71ugomAfMpK6a2FNlzwO9s9wiACyCyp7v4b09lZYfRc6t8Dut81Y/e9apZ5kaAJZIWCh71YM9FbJ+B59HR+Cslib2VNnzQv8sUwMALMYiaI+t8zyzViFr0KsJvVHU2cJvHDnLWuylnmVqAFgiYSF6asW++gqtZ+yljoBZwky8Knq1hWdqhf5ZpgWAhVgAhazFnlrJfqtWRa9W6I+C+cxDk1YP7KstPEs9y7QAAEtUWKrVh9ZZq5dsnXuWOgrmJcw+0gP7VSv0zzItAC7EEtSq6FXRq6KvKnq1BWej8DeYaS21p1d75Dn1CKYFAFwmYbHab/Vk6wx65/ZTR+JMVPZ8kmdZgx49y7QAsACwBLUqPV9V9FVFr7bgbBT5G8w94tUe9Rx/likBYAleHq3UfvWVd8/tq0A9CmYyDwXqLbwH3MVXTeiNYEoAIBdimfRQe/qqkj7rZK+PjoJ5ySuz67MJc/Icf4YpAXABXt4aqodWL6nn6a1V0auCHwVzmae+g8+mJvTOMiUAkMuwiN5alfRZS6tX6d2xj46Cecm7s1tzsoc/w5QAuAAvb92j3kmfdZL9rMWeCtSjYfaoucxKmEsPPcOUAAAvLyyBr5q0emBflT3fgjujyN8aNZeZzEIFf4YpAWABXhzt4bkqejXZ61lv6UiYCaPmOg+YiUfPMCUAwMsDC1BXrbzSr73qW3BnJPweM1GgPguzmIMK/gxTApAL9GAx7qlSvdR+9WCvKlCP5orZzkzOzP8HNQ0vxIkGykwAAAAASUVORK5CYII=

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
Write your game's title here
# BITSY VERSION 7.2
# BITSY VERSION 7.5
! ROOM_FORMAT 1