All Projects → danielearwicker → baltar

danielearwicker / baltar

Licence: MIT license
Example graphics editor using MobX

Programming Languages

typescript
32286 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to baltar

Json Mobx
Simple undo/redo and persistence for MobX
Stars: ✭ 78 (+85.71%)
Mutual labels:  serialization, mobx
kafka-protobuf-serde
Serializer/Deserializer for Kafka to serialize/deserialize Protocol Buffers messages
Stars: ✭ 52 (+23.81%)
Mutual labels:  serialization
BLOG DESKTOP
Yancey Official Blog for PC.
Stars: ✭ 80 (+90.48%)
Mutual labels:  mobx
CodableWrapper
@codec("encoder", "decoder") var cool: Bool = true
Stars: ✭ 143 (+240.48%)
Mutual labels:  serialization
msgpack-perl
MessagePack serializer implementation for Perl / msgpack.org[Perl]
Stars: ✭ 48 (+14.29%)
Mutual labels:  serialization
dataclasses-jsonschema
JSON schema generation from dataclasses
Stars: ✭ 145 (+245.24%)
Mutual labels:  serialization
Apex.Serialization
High performance contract-less binary serializer for .NET
Stars: ✭ 82 (+95.24%)
Mutual labels:  serialization
drf-action-serializer
A serializer for the Django Rest Framework that supports per-action serialization of fields.
Stars: ✭ 48 (+14.29%)
Mutual labels:  serialization
doku
fn(Code) -> Docs
Stars: ✭ 65 (+54.76%)
Mutual labels:  serialization
tjson.js
JavaScript-compatible implementation of Tagged JSON (TJSON), written in TypeScript.
Stars: ✭ 53 (+26.19%)
Mutual labels:  serialization
kafka-serialization
Lego bricks to build Apache Kafka serializers and deserializers
Stars: ✭ 122 (+190.48%)
Mutual labels:  serialization
mengya
一个类知乎文章方面的应用项目
Stars: ✭ 14 (-66.67%)
Mutual labels:  mobx
electron-exhentai
No description or website provided.
Stars: ✭ 13 (-69.05%)
Mutual labels:  mobx
GroBuf
Fast binary serializer
Stars: ✭ 56 (+33.33%)
Mutual labels:  serialization
mobx-decorated-models
Decorators to create serialized model relations using Mobx
Stars: ✭ 18 (-57.14%)
Mutual labels:  mobx
mobx-react-mvvm-example
React MVVM architecture powered by MobX.
Stars: ✭ 58 (+38.1%)
Mutual labels:  mobx
taro-template
可用于生产环境的taro项目模版,技术栈:taro + taro-ui + typescript + dva / mobx + sass,无需过多关注项目配置,预置功能包括但不限于页面/组件/store/service模版一键生成/编译自动生成路由列表和组件入口/代码规范强制检查/请求拦截封装/小程序CI等,实现多端项目的高效快速开发。目前已有1.x / 2.x / 3.x 版本。
Stars: ✭ 59 (+40.48%)
Mutual labels:  mobx
VSerializer
A library to serialize and deserialize objects with minimum memory usage.
Stars: ✭ 25 (-40.48%)
Mutual labels:  serialization
data-flow
frontend data flow explored in React
Stars: ✭ 19 (-54.76%)
Mutual labels:  mobx
weapp-starter-kit
No description or website provided.
Stars: ✭ 13 (-69.05%)
Mutual labels:  mobx

baltar

Example graphics editor using MobX

Demo

To play with it, you will need:

  • a browser (Chrome, Safari, Edge, Firefox)
  • Git
  • Node.js

In a Terminal (Mac/Linux) or Command line (Windows):

git clone https://github.com/danielearwicker/baltar.git
cd baltar
npm install
node fuse.js

Then go to localhost:4444 in your browser .

To read the code, start at src/index.tsx and work your way down the JSX rendering.

We create an EditorModel, load any previous state into it from localStorage, wire it up to the Undo system, and then render the Editor.

The Editor consists of:

  • Toolbar - this gets passed the Undo system so it can send commands to it
  • PropertyPalette - the pane on the right where shape settings appear
  • Paper - the drawing surface

Persistent data is in properties marked with @json - see json-mobx, which also takes care of Undo.

Also of note is src/geometry/Coordinate.ts which demonstrates the principle of view state being separate from model state. Every coordinate in the system has a live value being immediately manipulated and seen by the user, and a committed value that is known to the persistence system. The commit method copies one to the other. So during a drag operation, the live value is being edited. When it ends, the changes are committed. (This is very similar to validation.)

The drawing tools Box, Ellipse and Counter are instances of ShapeContent, defined in src/factory.ts.

The Counter is interesting in that it demonstrates "liveness":

export class Counter extends Rectangular {

    @observable count = 0;

    timer: any;

    constructor() {
        super();
        this.timer = setInterval(() => this.count++, 1000);
    }

    dispose() {
        clearInterval(this.timer);
    }

    get content() {
        const { l, b } = this.rect.normalized;
        return <text fill="magenta" fontSize="5em" x={l} y={b}>{this.count+""}</text>
    }
}

Draw a counter on the page and then move it around a few times. Then click Undo and Redo. The counter does not reset, because the object is not being recreated. Rather, the old persistent state (the position, managed here by the base class Rectangular) is being reconciled into the existing object, just as React reconciles Virtual DOM elements into existing real DOM elements.

If you Undo back past the point where the counter was created, it will disappear and be disposed. Its internal timer will be cleared. If you then Redo to make it reappear, now the counter will have reset.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].