Delete lots of now-unused code

This commit is contained in:
Alex Crichton
2018-08-29 18:32:47 -07:00
parent 923abc7d85
commit dd3dba9285
6 changed files with 52 additions and 424 deletions

View File

@ -8,4 +8,3 @@ crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = { path = "../.." }
web-sys = { path = "../../crates/web-sys" }

View File

@ -1,13 +1,18 @@
extern crate wasm_bindgen;
extern crate web_sys;
use wasm_bindgen::prelude::*;
use web_sys::{CanvasRenderingContext2D, ImageData};
mod fractal;
use fractal::get_julia_set;
use fractal::complex::Complex;
#[wasm_bindgen]
extern "C" {
pub type ImageData;
#[wasm_bindgen(constructor)]
pub fn new(arr: &Uint8ClampedArray, width: u32, height: u32) -> ImageData;
}
#[wasm_bindgen]
extern "C" {
pub type Uint8ClampedArray;
@ -16,13 +21,19 @@ extern "C" {
pub fn new(arr: &[u8]) -> Uint8ClampedArray;
}
#[wasm_bindgen]
extern "C" {
pub type CanvasRenderingContext2D;
#[wasm_bindgen(method, js_name = putImageData)]
pub fn put_image_data(this: &CanvasRenderingContext2D, image_data: &ImageData, p_1: i32, p_2: i32);
}
#[wasm_bindgen]
pub fn draw(ctx: &CanvasRenderingContext2D, width: u32, height: u32, real: f64, imaginary: f64) {
let c = Complex { real, imaginary };
let data = get_julia_set(width, height, c);
let uint8_array = Uint8ClampedArray::new(&data);
ctx.put_image_data(
&ImageData::with_data_and_sw_and_sh_with_sh(&data, width, height).unwrap(),
0.0, 0.0);
ctx.put_image_data(&ImageData::new(&uint8_array, width, height), 0, 0);
}