Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Release v1.0.0-alpha.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sadra1f committed Jun 7, 2021
1 parent 152781e commit 3b71033
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 15 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Customizable canvas drawing library.
Add scripts right before closing `</body>` tag:
```html
<script src="https://cdn.jsdelivr.net/npm/paper@0.12.15/dist/paper-full.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/drawgon@1.0.0-alpha.1/dist/drawgon.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/drawgon@1.0.0-alpha.3/dist/drawgon.min.js"></script>
```

You need to have a canvas with a specific id and these attributes in your page:
```html
<canvas resize="true" id="drawgon" data-paper-scope="1"></canvas>
<canvas id="drawgon" resize="true" data-paper-scope="1"></canvas>
```

Initialize DrawgonJS:
Expand All @@ -31,6 +31,7 @@ var draw = new Drawgon("drawgon", {
baseFontSize: 15,
pathSmoothing: 10,
cornerSmoothing: 4,
center: [0, 0],
zoom: 1,
maxZoom: 16,
minZoom: 0.4,
Expand Down
11 changes: 8 additions & 3 deletions dist/drawgon-core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* DrawgonJS v1.0.0-alpha.2 (https://github.com/wggb/drawgon-js)
* DrawgonJS v1.0.0-alpha.3 (https://github.com/wggb/drawgon-js)
* Copyright (c) 2021 WhiteGooseGoesBlack
* @license MIT (https://github.com/wggb/drawgon-js/blob/main/LICENSE)
*/
Expand Down Expand Up @@ -112,6 +112,7 @@ var Drawgon = function(id, config) {
baseFontSize: 15,
pathSmoothing: 10,
cornerSmoothing: 4,
center: [ view.center.x, view.center.y ],
zoom: 1,
maxZoom: 16,
minZoom: .4
Expand All @@ -128,6 +129,7 @@ var Drawgon = function(id, config) {
this.baseFontSize = this.config.baseFontSize;
this.pathSmoothing = this.config.pathSmoothing;
this.cornerSmoothing = this.config.cornerSmoothing;
view.center = this.config.center;
view.zoom = this.config.zoom;
this.maxZoom = this.config.maxZoom;
this.minZoom = this.config.minZoom;
Expand Down Expand Up @@ -182,6 +184,7 @@ var Drawgon = function(id, config) {
$this.mode = $this.config.mode;
$this.strokeWidth = $this.config.strokeWidth;
$this.strokeColor = $this.config.strokeColor;
view.center = $this.config.center;
view.zoom = $this.config.zoom;
};
this.clear = function() {
Expand Down Expand Up @@ -282,15 +285,17 @@ var Drawgon = function(id, config) {
try {
JSON.parse(text).forEach(function(item) {
let mode = item[0].trim().toLowerCase();
if (mode == "path") $this.items.push(new Path(item[1])); else if (mode == "pointtext") $this.items.push(new PointText(item[1]));
if (mode == "path") $this.items.push(new Path(item[1])); else if (mode == "pointtext") $this.items.push(new PointText(item[1])); else if (mode == "raster") $this.items.push(new Raster(item[1]));
});
return true;
} catch (error) {
alert("Text can't be parsed.");
return false;
}
};
this.setDataFromJSON = function(text) {
$this.clear();
$this.loadDataFromJSON(text);
return $this.loadDataFromJSON(text);
};
this.tool.onMouseDown = function(event) {
$this.mouse.click = event.point;
Expand Down
4 changes: 2 additions & 2 deletions dist/drawgon-core.min.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions dist/drawgon.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* DrawgonJS v1.0.0-alpha.2 (https://github.com/wggb/drawgon-js)
* DrawgonJS v1.0.0-alpha.3 (https://github.com/wggb/drawgon-js)
* Copyright (c) 2021 WhiteGooseGoesBlack
* @license MIT (https://github.com/wggb/drawgon-js/blob/main/LICENSE)
*/
Expand Down Expand Up @@ -112,6 +112,7 @@ var Drawgon = function(id, config) {
baseFontSize: 15,
pathSmoothing: 10,
cornerSmoothing: 4,
center: [ view.center.x, view.center.y ],
zoom: 1,
maxZoom: 16,
minZoom: .4
Expand All @@ -128,6 +129,7 @@ var Drawgon = function(id, config) {
this.baseFontSize = this.config.baseFontSize;
this.pathSmoothing = this.config.pathSmoothing;
this.cornerSmoothing = this.config.cornerSmoothing;
view.center = this.config.center;
view.zoom = this.config.zoom;
this.maxZoom = this.config.maxZoom;
this.minZoom = this.config.minZoom;
Expand Down Expand Up @@ -182,6 +184,7 @@ var Drawgon = function(id, config) {
$this.mode = $this.config.mode;
$this.strokeWidth = $this.config.strokeWidth;
$this.strokeColor = $this.config.strokeColor;
view.center = $this.config.center;
view.zoom = $this.config.zoom;
};
this.clear = function() {
Expand Down Expand Up @@ -282,15 +285,17 @@ var Drawgon = function(id, config) {
try {
JSON.parse(text).forEach(function(item) {
let mode = item[0].trim().toLowerCase();
if (mode == "path") $this.items.push(new Path(item[1])); else if (mode == "pointtext") $this.items.push(new PointText(item[1]));
if (mode == "path") $this.items.push(new Path(item[1])); else if (mode == "pointtext") $this.items.push(new PointText(item[1])); else if (mode == "raster") $this.items.push(new Raster(item[1]));
});
return true;
} catch (error) {
alert("Text can't be parsed.");
return false;
}
};
this.setDataFromJSON = function(text) {
$this.clear();
$this.loadDataFromJSON(text);
return $this.loadDataFromJSON(text);
};
this.tool.onMouseDown = function(event) {
$this.mouse.click = event.point;
Expand Down
Loading

0 comments on commit 3b71033

Please sign in to comment.