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

Commit

Permalink
release: v1.0.0-alpha.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed May 3, 2024
1 parent 18bbe67 commit 065a30f
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 12 deletions.
8 changes: 4 additions & 4 deletions docs/content/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Demo1/>

```typescript
import { CarEngine, Scene, Widget, Circle, create, move, easeBounce, easeInCirc } from "newcar";
import { CarEngine, createScene, Widget, Circle, create, move, easeBounce, easeInCirc } from "newcar";

const engine = await new CarEngine().init(
"https://unpkg.com/canvaskit-wasm@latest/bin/canvaskit.wasm"
Expand All @@ -23,7 +23,7 @@ const root = new Widget().add(
by: easeBounce
})
);
const scene = new Scene(root);
const scene = createScene(root);
app.checkout(scene);
app.play();
```
Expand All @@ -35,7 +35,7 @@ app.play();
<Demo2/>

```typescript
import { CarEngine, Scene, easeInCirc, Path, stroke } from "newcar";
import { CarEngine, createScene, easeInCirc, Path, stroke } from "newcar";

const engine = await new CarEngine().init(
"https://unpkg.com/canvaskit-wasm@latest/bin/canvaskit.wasm"
Expand All @@ -56,7 +56,7 @@ const root = new Path({
root.addPathFromSVGString(`
M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z
`);
const scene = new Scene(root);
const scene = createScene(root);
app.checkout(scene);
app.play();
```
Expand Down
2 changes: 1 addition & 1 deletion docs/content/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import * as nc from "newcar";
const engine = await new nc.CarEngine().init("../node_modules/canvaskit-wasm/bin/canvaskit.wasm");
const app = engine.createApp(document.querySelector("#canvas"));
const root = new nc.Circle(100);
const scene = new nc.Scene(root);
const scene = nc.createScene(root);
app.checkout(scene);
app.play();
```
Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@newcar/mod-markdown": "workspace:0.3.0",
"@newcar/mod-math": "workspace:*",
"canvaskit-wasm": "0.39.1",
"newcar": "workspace:1.0.0-alpha.0",
"newcar": "workspace:1.0.0-alpha.1",
"vite-plugin-node-polyfills": "^0.21.0"
}
}
2 changes: 1 addition & 1 deletion packages/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/basic",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "The basic objects, animations and interpolators of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/basic/src/widgets/figures/arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Arc extends Figure {
this.strokePaint.setColor(this.style.borderColor.toFloat4())
this.strokePaint.setStrokeWidth(this.style.borderWidth)
this.strokePaint.setAlphaf(this.style.transparency * this.style.borderColor.alpha)

this.strokePaint.setAntiAlias(this.style.antiAlias)
try {
const dash = ck.PathEffect.MakeDash(
this.style.interval,
Expand All @@ -37,6 +37,7 @@ export class Arc extends Figure {
this.fillPaint.setColor(this.style.fillColor.toFloat4())
this.fillPaint.setStyle(ck.PaintStyle.Fill)
this.fillPaint.setAlphaf(this.style.transparency * this.style.fillColor.alpha)
this.fillPaint.setAntiAlias(this.style.antiAlias)

// Blend Mode
this.strokePaint.setBlendMode(str2BlendMode(ck, this.style.blendMode))
Expand Down
1 change: 1 addition & 0 deletions packages/basic/src/widgets/figures/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Line extends Widget {
this.paint.setStrokeWidth(this.style.width)
this.paint.setAlphaf(this.style.transparency * this.style.color.alpha)
this.paint.setBlendMode(str2BlendMode(ck, this.style.blendMode))
this.paint.setAntiAlias(this.style.antiAlias)
}

predraw(ck: CanvasKit, propertyChanged: string): void {
Expand Down
2 changes: 2 additions & 0 deletions packages/basic/src/widgets/figures/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class Path extends Figure {
this.strokePaint.setStrokeWidth(this.style.borderWidth)
this.strokePaint.setStrokeJoin(str2StrokeJoin(ck, this.style.join))
this.strokePaint.setStrokeCap(str2StrokeCap(ck, this.style.cap))
this.strokePaint.setAntiAlias(this.style.antiAlias)
try {
const dash = ck.PathEffect.MakeDash(
this.style.interval,
Expand All @@ -38,6 +39,7 @@ export class Path extends Figure {
this.fillPaint.setStyle(ck.PaintStyle.Fill)
this.fillPaint.setColor(this.style.fillColor.toFloat4())
this.fillPaint.setAlphaf(this.style.transparency * this.style.fillColor.alpha)
this.fillPaint.setAntiAlias(this.style.antiAlias)
}

predraw(ck: CanvasKit, propertyChanged: string): void {
Expand Down
3 changes: 3 additions & 0 deletions packages/basic/src/widgets/figures/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class Polygon extends Figure {
this.strokePaint.setStrokeWidth(this.style.borderWidth)
this.strokePaint.setStrokeJoin(str2StrokeJoin(ck, this.style.join))
this.strokePaint.setStrokeCap(str2StrokeCap(ck, this.style.cap))
this.strokePaint.setAntiAlias(this.style.antiAlias)
try {
const dash = ck.PathEffect.MakeDash(
this.style.interval,
Expand All @@ -54,6 +55,8 @@ export class Polygon extends Figure {
// Blend Mode
this.strokePaint.setBlendMode(str2BlendMode(ck, this.style.blendMode))
this.fillPaint.setBlendMode(str2BlendMode(ck, this.style.blendMode))

this.fillPaint.setAntiAlias(this.style.antiAlias)
}

predraw(ck: CanvasKit, propertyChanged: string): void {
Expand Down
3 changes: 3 additions & 0 deletions packages/basic/src/widgets/figures/rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Rect extends Figure {
this.strokePaint.setStrokeWidth(this.style.borderWidth)
this.strokePaint.setStrokeJoin(str2StrokeJoin(ck, this.style.join))
this.strokePaint.setStrokeCap(str2StrokeCap(ck, this.style.cap))
this.strokePaint.setAntiAlias(this.style.antiAlias)
try {
const dash = ck.PathEffect.MakeDash(
this.style.interval,
Expand All @@ -46,10 +47,12 @@ export class Rect extends Figure {
this.fillPaint.setStyle(ck.PaintStyle.Fill)
this.fillPaint.setColor(this.style.fillColor.toFloat4())
this.fillPaint.setAlphaf(this.style.transparency * this.style.fillColor.alpha)
this.fillPaint.setAntiAlias(this.style.antiAlias)

// Blend Mode
this.strokePaint.setBlendMode(str2BlendMode(ck, this.style.blendMode))
this.fillPaint.setBlendMode(str2BlendMode(ck, this.style.blendMode))
this.fillPaint.setAntiAlias(this.style.antiAlias)
}

predraw(ck: CanvasKit, propertyChanged: string): void {
Expand Down
1 change: 1 addition & 0 deletions packages/basic/src/widgets/imageWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class ImageWidget extends Widget {
init(ck: CanvasKit) {
this.paint = new ck.Paint()
this.paint.setAlphaf(this.style.transparency)
this.paint.setAntiAlias(this.style.antiAlias)
try {
this.image = ck.MakeImageFromEncoded(this.imageArray)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/core",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "The core of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface WidgetStyle {
rotation?: number
transparency?: number
blendMode?: BlendMode
antiAlias?: boolean
}

export class Widget {
Expand Down Expand Up @@ -69,6 +70,7 @@ export class Widget {
this.style.rotation = options.style.rotation ?? 0
this.style.transparency = options.style.transparency ?? 1
this.style.blendMode = options.style.blendMode ?? 'srcOver'
this.style.antiAlias = options.style.antiAlias ?? true
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/newcar/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "newcar",
"type": "module",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "A Highly configurable universal advanced engine, Born for creating animation rapidly.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/recorder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/recorder",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "The utils of newcar",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/utils",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "The utils of newcar",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down

0 comments on commit 065a30f

Please sign in to comment.