Skip to content

Commit

Permalink
F*ck actions, retrograting to CommonJS
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Traut committed Mar 23, 2022
1 parent 975b3e6 commit 0c30070
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 57 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/npm-publish.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/rename.sh

This file was deleted.

12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Storyboard = require('./src/storyboard.js');
const Sprite = require('./src/sprite.js');
const Animation = require('./src/animation');
const Events = require('./src/event.js');
const Easings = require('./src/easing.js');

exports.Storyboard = Storyboard.Storyboard;
exports.Sprite = Sprite.Sprite;
exports.Animation = Animation.Animation;
exports.createEvent = Events.newEvent;
exports.createParam = Events.newParam;
exports.easings = Easings;
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# dotosb
8 changes: 5 additions & 3 deletions src/animation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Sprite } from "dotosb";
const { Sprite } = require('./sprite.js');

export default class Animation extends Sprite {
class Animation extends Sprite {

frame_count;
frame_delay;
Expand All @@ -25,4 +25,6 @@ export default class Animation extends Sprite {
}
return sprite;
}
}
}

module.exports = { Animation };
4 changes: 3 additions & 1 deletion src/easing.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const functions = [
elasticInOut,
];

export function ease(easing, value) {
function ease(easing, value) {
return functions[easing].call(this, value);
}

Expand All @@ -85,3 +85,5 @@ function reverse(func, value) {
function toInOut(func, value) {
return 0.5 * (value < 0.5 ? func(2 * value) : 2 - func(2 - 2 * value));
}

module.exports = { ease };
7 changes: 4 additions & 3 deletions src/event.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EVENT_TYPES } from "./utils.js";
const { EVENT_TYPES } = require("./utils.js");

function parseValues(values, isTime) {
if(Array.isArray(values)) {
Expand Down Expand Up @@ -39,7 +39,7 @@ function isValid(event) {
return true;
}

export function newEvent(type, times, values, easing = 0) {
function newEvent(type, times, values, easing = 0) {
let start_values = values;
let end_values = null;
values = sanitizeValues(values);
Expand All @@ -64,7 +64,7 @@ export function newEvent(type, times, values, easing = 0) {
return event;
}

export function newParam(start, end, type) {
function newParam(start, end, type) {
const param = {
type: type,
start: start,
Expand Down Expand Up @@ -92,3 +92,4 @@ function sanitizeValues(values) {
});
}

module.exports = { newEvent, newParam };
4 changes: 3 additions & 1 deletion src/imap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default class IntervalMap {
class IntervalMap {

constructor() {
this.start_times = [];
Expand Down Expand Up @@ -37,3 +37,5 @@ export default class IntervalMap {
return events;
}
}

module.exports = { IntervalMap };
4 changes: 0 additions & 4 deletions src/index.js

This file was deleted.

10 changes: 6 additions & 4 deletions src/sprite.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { newEvent, newParam } from "./event.js";
import IntervalMap from "./imap.js";
import { ease } from './easing.js';
const { newEvent, newParam } = require('./event.js');
const { IntervalMap } = require('./imap.js');
const { ease } = require('./easing.js');

export class Sprite {
class Sprite {

events = [];
path;
Expand Down Expand Up @@ -77,3 +77,5 @@ export class Sprite {
return sprite;
}
}

module.exports = { Sprite };
18 changes: 10 additions & 8 deletions src/storyboard.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Sprite } from "./sprite.js";
import Animation from "./animation.js";
import fs from 'fs';
import { newEvent, newParam } from "./event.js";
const { Sprite } = require('./sprite.js');
const { Animation } = require('./animation.js');
const fs = require('fs');
const { newEvent, newParam } = require("./event.js");

export class Storyboard {
class Storyboard {

layers = new Map();

Expand Down Expand Up @@ -60,14 +60,14 @@ export class Storyboard {
}
}

export function fromFile(file_path) {
function fromFile(file_path) {
let data = fs.readFileSync(file_path, 'utf8');
data = data.replace(/(\r\n|\r|\n)/g, '\n');
data = data.replace('\\', '/');
return fromString(data);
}

export function fromString(data) {
function fromString(data) {
let layers = data.split('//Storyboard Layer ');
layers.shift();

Expand Down Expand Up @@ -144,4 +144,6 @@ export function fromString(data) {
}

return storyboard;
}
}

module.exports = { Storyboard, fromFile, fromString };
6 changes: 4 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const EVENT_TYPES = new Map([
const EVENT_TYPES = new Map([
["F", 1],
["S", 1],
["R", 1],
Expand All @@ -9,7 +9,7 @@ export const EVENT_TYPES = new Map([
["V", 2],
]);

export const EASINGS = {
const EASINGS = {
Linear: 0,
Out: 1,
In: 2,
Expand Down Expand Up @@ -46,3 +46,5 @@ export const EASINGS = {
BounceOut: 34,
BounceInOut: 35,
};

module.exports = { EVENT_TYPES, EASINGS };

0 comments on commit 0c30070

Please sign in to comment.