← Back

ofxDST

github.com/daitomanabe/ofxDST · @daitomanabe
OF 0.12 2D Utilities

Minimal Tajima DST (.dst) reader for openFrameworks

0 0 Last commit 9mo ago Created 9mo ago

README

ofxDST (openFrameworks addon)



Tajima DST(.dst)を openFrameworks で読むための最小アドオンです。

内部で dst-cpp を submodule として使用しています。

動作環境



できること



できないこと(重要)



インストール



# git clone する場合は --recursive を付ける
git clone --recursive https://github.com/daitomanabe/ofxDST.git

既にclone済みの場合は submodule を初期化

git submodule update --init --recursive


1. ofxDST フォルダを openFrameworks/addons/ofxDST にコピー 2. example-ofxDST を openFrameworks の Project Generator で生成 3. 生成したプロジェクトをビルドして実行

サンプルDSTファイルは example-ofxDST/bin/data/ に入っています。

ディレクトリ構成



ofxDST/
├── src/
│   ├── ofxDST.h          # openFrameworks用ラッパー
│   └── ofxDST.cpp
├── libs/
│   └── dst-cpp/          # submodule (https://github.com/daitomanabe/dst-cpp)
│       ├── include/dst/dst.hpp
│       └── src/dst.cpp
├── example-ofxDST/
│   └── bin/data/sample.dst
├── addon_config.mk
└── README.md


使い方(コード)



ofxDST::Reader dst;
dst.load("sample.dst");

// 外形を取得(DST単位、通常0.1mm)
auto bounds = dst.getBounds();

// 描画
dst.draw(100, 100, 1.0f, true);


API リファレンス



ofxDST::Reader



メソッド説明
bool load(const std::string& path)DSTファイルを読み込む。成功で true
void clear()読み込みデータをクリア
const std::unordered_map<std::string, std::string>& getHeaderTags()ヘッダ情報を取得(LA, ST, CO 等)
const std::vector<Record>& getRecords()相対移動レコードを取得
const std::vector<Point>& getPoints()絶対座標の点列を取得
const ofRectangle& getBounds()外形を取得(DST単位)
void draw(float x, float y, float scale, bool flipY)簡易描画

draw() の引数



引数型説明
xfloatスクリーン上のX座標(ピクセル)
yfloatスクリーン上のY座標(ピクセル)
scalefloatDST単位あたりのピクセル数(デフォルト: 1.0)
flipYboolY軸を反転するか(デフォルト: true)

型定義(dst-cpp からの re-export)



using ofxDST::Command = dst::Command;  // Stitch, Jump, Stop, Sequin, End
using ofxDST::Point   = dst::Point;    // x, y, cmd
using ofxDST::Record  = dst::Record;   // dx, dy, cmd
using ofxDST::Header  = dst::Header;   // tags (unordered_map)


ヘッダタグ(主要なもの)



タグ説明
LAデザイン名(Label)
STステッチ数
COカラーチェンジ数
+X, -X, +Y, -Y各方向への最大移動量

ofxDST::Command(コマンド種別)



値説明
Stitch通常のステッチ(糸を縫う)
Jumpジャンプ移動(糸を縫わない)
Stop停止(糸色変更のタイミング)
Sequinスパンコール
Endデータ終端

座標の向き



DSTのY軸は「上が+」として扱うことが多い一方、openFrameworksは画面座標が「下が+」です。 draw(..., flipY=true) でY方向を反転して表示します。

ライセンス



MIT License

Get this addon

HTTPS
SSH