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

Commit

Permalink
release: v2.0.0-beta.14
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Aug 17, 2024
1 parent 70a0f35 commit 5e3fcb7
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 62 deletions.
49 changes: 36 additions & 13 deletions examples/scene1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,47 @@ import * as mt from '@newcar/mod-math'

await useFont('./default.ttf')

export default importScene(
const scene = importScene(

`{
`
{
"root": {
"type": "Widget",
"arguments": [],
"children": [
{
"type": "MathFunction",
"arguments": [
"fn((x) => Math.sin(x))",
[-3.14, 3.14]
],
"type": "Rect",
"arguments": [400, 400],
"options": {
"style": {
"color": [255, 0, 0, 1]
"border": true,
"fill": false,
"borderColor": [255, 255, 255, 1]
},
"lineWidth": 2,
"divisionY": 200,
"divisionX": 400,
"x": 100,
"y": 200
"x": 300,
"y": 150
}
},
{
"type": "Circle",
"arguments": [10],
"options": {
"style": {
"fill": true,
"fillColor": [255, 255, 255, 1]
},
"x": 300,
"y": 150
},
"animations": [
{
"type": "move",
"parameters": {
"duration": 1,
"to": [400, 400]
}
}
]
}
]
}
Expand All @@ -38,6 +57,10 @@ export default importScene(
nc as any,
nc as any,
)

console.log(scene)

export default scene
//
// export default createScene(
// new Circle(100, {
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-geometry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-geometry",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-layout/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-layout",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-markdown",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-math/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/mod-math",
"type": "module",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-skottie/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/mod-skottie",
"type": "module",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
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": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "The basic objects, animations and interpolators of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/core",
"type": "module",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "The core of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/json/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@newcar/json",
"type": "module",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "The core of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
23 changes: 12 additions & 11 deletions packages/json/src/import-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ export function processItem(
return importWidget(item as WidgetFormat, widgets, anims, easingFunctions)
}
}
if (Array.isArray(item)) {
if (Array.isArray(item) && item.length === 4) {
return Color.rgba(item[0], item[1], item[2], item[3] ?? 1)
}
else if (!isString(item)) {
return item
}
else if (isString(item as string) && /color\(.+\)/.test(item as string)) {
return Color.parse((item as string).replace(/color\(/, '').replace(/\)$/, ''))
}
Expand All @@ -39,9 +42,6 @@ export function processItem(
// eslint-disable-next-line no-new-func
return Function(`return ${(item as string).replace(/calc\(/, '').replace(/\)$/, '')}`)()
}
else {
return item
}
}

export function processOptions(
Expand Down Expand Up @@ -88,12 +88,7 @@ export function importWidget<T extends typeof Widget>(
widgetData = JSON.parse(widgetData) as WidgetFormat
}
const widget = new widgets[widgetData.type](...processArguments(widgetData.arguments ?? [], widgets, anims, easingFunctions), processOptions(widgetData.options, widgets, anims, easingFunctions))
if (widgetData.children) {
widget.add(...widgetData.children.map((child) => {
return importWidget(child, widgets, anims, easingFunctions)
}))
}
if (widgetData.animations) {
if (Array.isArray(widgetData.animations)) {
widgetData.animations.forEach((animation) => {
if (Array.isArray(animation)) {
widget.animate(
Expand All @@ -114,7 +109,7 @@ export function importWidget<T extends typeof Widget>(
)
}
else {
if (animation.custom) {
if (typeof animation.custom === 'string') {
if (animation.custom === 'change-property') {
widget.animate(changeProperty(() => (widget as Record<string, any>)[animation.target])
.withAttr({
Expand Down Expand Up @@ -146,5 +141,11 @@ export function importWidget<T extends typeof Widget>(
})
}

if (widgetData.children) {
widget.add(...widgetData.children.map((child) => {
return importWidget(child, widgets, anims, easingFunctions)
}))
}

return widget
}
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": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"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": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"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": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "The utils of newcar",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/plugin-debug",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-timeview/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/plugin-timeview",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"description": "",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
31 changes: 6 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5e3fcb7

Please sign in to comment.