8 Commits

Author SHA1 Message Date
63bcf8532c wip 2020-11-17 10:10:07 +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
21eb632d22 add old version 2020-11-07 19:30:20 +00:00
5 changed files with 74 additions and 12 deletions

View File

@@ -1,3 +1,57 @@
# pixsy # 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

@@ -14,7 +14,7 @@ html(lang="en-gb")
p. p.
convert images to Bitsy rooms convert images to Bitsy rooms
| |
#[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="mailto:max@tinybird.info") email]
| |
@@ -78,6 +78,11 @@ html(lang="en-gb")
| dither | dither
br br
label
input#filter(type="checkbox")
| filter
br
button.pagination.prev#back-to-image previous button.pagination.prev#back-to-image previous
button.pagination.next#room-next add room button.pagination.next#room-next add room
.page.download .page.download

View File

@@ -8,14 +8,11 @@ import init, {
output, output,
set_brightness, set_brightness,
set_dither, set_dither,
set_filter,
set_palette, set_palette,
set_room_name, set_room_name,
} from './pkg/pixsy.js'; } 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 // 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) { function download(filename, text) {
let element = document.createElement('a'); let element = document.createElement('a');
@@ -60,6 +57,10 @@ function readFile(input, callback, type = "text") {
} }
async function run() { async function run() {
if (typeof WebAssembly !== "object") {
window.location = "http://tinybird.info/image-to-bitsy/old/"
}
await init(); await init();
const buttonAddImage = el("add"); const buttonAddImage = el("add");

View File

@@ -33,6 +33,7 @@ struct State {
room_name: Option<String>, room_name: Option<String>,
palette: SelectedPalette, palette: SelectedPalette,
dither: bool, dither: bool,
filter: bool,
brightness: i32, brightness: i32,
} }
@@ -44,6 +45,7 @@ lazy_static! {
room_name: None, room_name: None,
palette: SelectedPalette::None, palette: SelectedPalette::None,
dither: true, dither: true,
filter: false,
brightness: 0, brightness: 0,
} }
); );
@@ -131,6 +133,12 @@ pub fn set_dither(dither: bool) {
state.dither = dither; state.dither = dither;
} }
#[wasm_bindgen]
pub fn set_filter(filter: bool) {
let mut state = STATE.lock().unwrap();
state.filter = filter;
}
#[wasm_bindgen] #[wasm_bindgen]
pub fn set_palette(palette_id: &str, background: String, foreground: String) { pub fn set_palette(palette_id: &str, background: String, foreground: String) {
let mut state = STATE.lock().unwrap(); let mut state = STATE.lock().unwrap();