Skip to content

Commit 65eb438

Browse files
committed
update dep
1 parent 701a651 commit 65eb438

11 files changed

Lines changed: 45 additions & 35 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ishape_wasm"
3-
version = "2.2.0"
3+
version = "2.3.0"
44
authors = ["Nail Sharipov <nailxsharipov@gmail.com>"]
55
edition = "2021"
66
description = "Triangulation and Boolean Operations for 2D Polygons. Supported operations: intersection, union, difference, XOR, and self-intersections for all polygon varieties."
@@ -16,14 +16,14 @@ codegen-units = 1
1616
crate-type = ["cdylib"]
1717

1818
[dependencies]
19-
i_triangle = "~0.31"
20-
#i_triangle = { path = "../iTriangle/iTriangle" }
19+
i_triangle = { version = "~0.33", features = ["serde"] }
20+
#i_triangle = { path = "../iTriangle/iTriangle", features = ["serde"] }
2121
log = "0.4.22"
2222
console_log = "^1.0.0"
2323
console_error_panic_hook = "^0"
2424

2525

2626
wasm-bindgen = "^0.2"
27-
serde = { version = "^1.0", features = ["derive"] }
27+
serde = { version = "^1.0", default-features = false, features = ["derive", "alloc"] }
2828
serde-wasm-bindgen = "^0.6"
2929

-120 KB
Binary file not shown.
-120 KB
Binary file not shown.

pkg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<p align="center">
44
<img src="readme/balloons.svg" width="250"/>
55
</p>
6-
2D geometry library for triangulation and poly-bool operations such as union, intersection, difference and xor.
6+
A fast 2D geometry library in WebAssembly for JavaScript and TypeScript. Supports polygon boolean operations, buffering, and triangulation.
77

88
## [Demo](https://ishape-rust.github.io/iShape-js/overlay/stars_demo.html)
99
Try out iShape with an interactive demo.

pkg/ishape_wasm_bg.wasm

-120 KB
Binary file not shown.

pkg/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Nail Sharipov <nailxsharipov@gmail.com>"
66
],
77
"description": "Triangulation and Boolean Operations for 2D Polygons. Supported operations: intersection, union, difference, XOR, and self-intersections for all polygon varieties.",
8-
"version": "2.2.0",
8+
"version": "2.3.0",
99
"license": "MIT",
1010
"repository": {
1111
"type": "git",

src/bool/overlay.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloc::vec::Vec;
12
use crate::data::{NestedData, VectorsData};
23
use crate::bool::fill_rule::FillRule;
34
use crate::bool::overlay_rule::OverlayRule;
@@ -56,7 +57,7 @@ impl Overlay {
5657
}
5758

5859
#[wasm_bindgen]
59-
pub fn overlay(self, overlay_rule: OverlayRule, fill_rule: FillRule) -> JsValue {
60+
pub fn overlay(mut self, overlay_rule: OverlayRule, fill_rule: FillRule) -> JsValue {
6061
let overlay_rule = RustOverlayRule::from(overlay_rule);
6162
let fill_rule = RustFillRule::from(fill_rule);
6263

@@ -66,11 +67,16 @@ impl Overlay {
6667
}
6768

6869
#[wasm_bindgen]
69-
pub fn separate_vectors(self, fill_rule: FillRule) -> JsValue {
70+
pub fn separate_vectors(mut self, fill_rule: FillRule) -> JsValue {
7071
let fill_rule = RustFillRule::from(fill_rule);
71-
let float_graph = self.overlay.into_graph(fill_rule);
72-
let vectors = float_graph.graph.extract_separate_vectors();
73-
let data = VectorsData::create(vectors, &float_graph.adapter);
72+
let data = if let Some(float_graph) = self.overlay.build_graph_view(fill_rule) {
73+
let vectors = float_graph.graph.extract_separate_vectors();
74+
VectorsData::create(vectors, &float_graph.adapter)
75+
} else {
76+
VectorsData {
77+
vectors: Vec::new()
78+
}
79+
};
7480
serde_wasm_bindgen::to_value(&data).unwrap()
7581
}
7682
}

src/data.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
use alloc::vec::Vec;
12
use i_triangle::i_overlay::i_float::adapter::FloatPointAdapter;
23
use i_triangle::i_overlay::vector::edge::VectorEdge;
3-
use serde::{Deserialize, Serialize};
4-
use std::fmt;
4+
use core::fmt;
55
use wasm_bindgen::JsValue;
66

77
pub type ShapesData = Vec<ShapeData>;
88
pub type ShapeData = Vec<ContourData>;
99
pub type ContourData = Vec<[f64; 2]>;
1010

11-
#[derive(Deserialize)]
11+
#[derive(serde::Deserialize)]
1212
#[serde(untagged)]
1313
pub(super) enum NestedData {
1414
Contour(ContourData),
@@ -27,7 +27,7 @@ impl NestedData {
2727
}
2828
}
2929

30-
#[derive(Serialize, Deserialize)]
30+
#[derive(serde::Serialize, serde::Deserialize)]
3131
pub struct VectorData {
3232
pub ax: f64,
3333
pub ay: f64,
@@ -36,7 +36,7 @@ pub struct VectorData {
3636
pub fill: u8,
3737
}
3838

39-
#[derive(Serialize, Deserialize)]
39+
#[derive(serde::Serialize, serde::Deserialize)]
4040
pub struct VectorsData {
4141
pub vectors: Vec<VectorData>,
4242
}

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![no_std]
2+
extern crate alloc;
3+
14
pub mod data;
25
pub mod triangle;
36
pub mod bool;

src/logger.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
use std::panic;
2-
use std::sync::Once;
3-
// use log::info;
4-
5-
pub(crate) struct Logger {}
6-
7-
static INIT_LOGGER: Once = Once::new();
8-
9-
impl Logger {
10-
pub(crate) fn prepare() {
11-
panic::set_hook(Box::new(console_error_panic_hook::hook));
12-
INIT_LOGGER.call_once(|| {
13-
console_log::init_with_level(log::Level::Debug).expect("error initializing log");
14-
});
15-
}
16-
}
1+
// use std::panic;
2+
// use std::sync::Once;
3+
// // use log::info;
4+
//
5+
// pub(crate) struct Logger {}
6+
//
7+
// static INIT_LOGGER: Once = Once::new();
8+
//
9+
// impl Logger {
10+
// pub(crate) fn prepare() {
11+
// panic::set_hook(Box::new(console_error_panic_hook::hook));
12+
// INIT_LOGGER.call_once(|| {
13+
// console_log::init_with_level(log::Level::Debug).expect("error initializing log");
14+
// });
15+
// }
16+
// }

0 commit comments

Comments
 (0)