Skip to content

Commit 058d3ff

Browse files
committed
update print licence
1 parent 683d396 commit 058d3ff

File tree

12 files changed

+997
-119
lines changed

12 files changed

+997
-119
lines changed

docs/pita_doc/content/_index.ja.md

+26-19
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,37 @@
22
title: "はじめに"
33
---
44

5-
# 作図用プログラミング言語 Pita
5+
# Pita 作図のためのプログラミング言語
66

7-
**Pita**は、作図のためのプログラミング言語です。
7+
Pitaは、ベクター画像を生成するためのプログラミング言語です。
8+
ユーザーが記述した図形の仕様(ルール)を受け取り、それを満たすような図形を計算します。
9+
手続きを用いた生成的な図形表現や、制約を用いた宣言的な図形の定義を高速に行うことができます。
10+
Pitaは容易に図形の定義ができて後からの変更を行いやすいように設計されています。
811

12+
---
913

10-
## Pitaの特徴
11-
12-
* [簡潔な構文]({{%relref "/features/syntax/_index.md" %}})
13-
* [図形処理]({{%relref "/features/geometry/_index.md" %}})
14-
* [制約]({{%relref "/features/constraint/_index.md" %}})
15-
16-
![Screenshot](https://github.com/matcornic/hugo-theme-learn/raw/master/images/screenshot.png?width=40pc&classes=shadow)
14+
![Pitaで記述した図の例](https://github.com/agehama/Pita/raw/master/docs/pita_doc/images/pita_examples.png?classes=shadow)
1715

16+
### 1. 制約による図形記述
17+
Pitaの最大の特徴は、図を定義するのに座標やアルゴリズムを書く必要がないという点です。
18+
Pitaは図の定義に、図が満たすべき仕様(図形同士が接触している、平行である、...)を与えることができます。
19+
処理系はこの仕様を満たす図形を自動的に計算します。
1820

19-
## Contribute to this documentation
20-
Feel free to update this content, just click the **Edit this page** link displayed on top right of each page, and pullrequest it
21+
### 2. 図形の部品化
22+
Pitaは一度図形を作ったら、それを継承することで似たような図形を簡単に作ることができます。
23+
また、図形同士のブーリアン演算も行うことができます。
24+
さらに図形定義から他の図形定義を参照することもでき、作図工程のモジュール化を支援します。
2125

22-
{{% notice info %}}
23-
Your modification will be deployed automatically when merged.
24-
{{% /notice %}}
26+
### 3. 高い表現力
27+
Pitaは図形に関する高度な演算機能(図形をパスに沿うよう変形させる、障害物を迂回する経路を探索する、...)を提供します。
28+
また、分岐やループなどの制御構文、レコードやリストなどのデータ構造、第一級関数など汎用性の高い言語機能を備えているので、複雑な図形も簡潔に記述することが可能です。
2529

26-
## Documentation website
27-
This current documentation has been statically generated with Hugo with a simple command : `hugo -t hugo-theme-learn` -- source code is [available here at GitHub](https://github.com/matcornic/hugo-theme-learn)
30+
#### 他の特徴
31+
他にもPitaは次のような特徴を備えています。
2832

29-
{{% notice note %}}
30-
Automatically published and hosted thanks to [Netlify](https://www.netlify.com/). Read more about [Automated HUGO deployments with Netlify](https://www.netlify.com/blog/2015/07/30/hosting-hugo-on-netlifyinsanely-fast-deploys/)
31-
{{% /notice %}}
33+
- Windows, MacOS, Ubuntu のサポート
34+
- 数値計算による高速な制約計算
35+
- フォント対応
36+
- SVG出力対応
37+
- パスに関する演算機能
38+
- MITライセンス

docs/pita_doc/content/features/_index.ja.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Pitaの特徴"
2+
title: "1. Pitaの特徴"
33
---
44

55
## Pitaの特徴
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "クイックスタート"
3+
weight: 10
4+
chapter: true
5+
pre: "<b>1. </b>"
6+
---
7+
8+
### チャプター 1
9+
10+
# クイックスタート
11+
12+
Pitaのダウンロードとインストール、サンプルの実行手順を紹介します。
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: "ダウンロードとインストール"
3+
weight: 10
4+
---
5+
6+
### ダウンロードとインストール
7+
#### Windows
8+
9+
10+
#### MacOS
11+
Pitaは一度図形を作ったら、それを継承することで似たような図形を簡単に作ることができます。
12+
また、図形同士のブーリアン演算も行うことができます。
13+
さらに図形定義から他の図形定義を参照することもでき、作図工程のモジュール化を支援します。
14+
15+
#### Ubuntu
16+
Pitaは図形に関する高度な演算機能(図形をパスに沿うよう変形させる、障害物を迂回する経路を探索する、...)を提供します。
17+
また、分岐やループなどの制御構文、レコードやリストなどのデータ構造、第一級関数など汎用性の高い言語機能を備えているので、複雑な図形も簡潔に記述することが可能です。
18+
19+
### ソースコードのビルド
114 KB
Loading

examples/examples.cgl

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import "rec_shape2.cgl" as rec2
2+
import "koch_snowflake.cgl" as koch
3+
import "pita_p2.cgl" as p2
4+
import "pita_constraint_example.cgl" as cs
5+
6+
Center = (shape -> Square{polygon=BoundingBox(shape).result.polygon}.center())
7+
Left = (shape -> Square{polygon=BoundingBox(shape).result.polygon}.left())
8+
Right = (shape -> Square{polygon=BoundingBox(shape).result.polygon}.right())
9+
10+
main = Shape{
11+
a: (s = rec2.tree, s{})
12+
b: (s = koch.tree, s{scale: X2(0.4), pos: Vec2(500,0)})
13+
c: (s = p2.main, s{scale: X2(0.5), pos: Vec2(800,0)})
14+
d: (s = cs.main, s{scale: X2(2.0), pos: Vec2(1200,0)})
15+
sat((Center(a).y - Center(b).y)^2 == 0)
16+
sat((Center(b).y - Center(c).y)^2 == 0)
17+
sat((Center(c).y - Center(d).y)^2 == 0)
18+
var(b.pos.y, c.pos.y, d.pos.y)
19+
}
20+
21+
s = Free(main)
22+
main2 = s{
23+
dd = (Right(s.a).x - Left(s.b).x)
24+
sat( (dd - (Right(b).x - Left(c).x))^2 == 0)
25+
sat( (dd - (Right(c).x - Left(d).x))^2 == 0)
26+
var(c.pos.x, d.pos.x)
27+
}

examples/koch_snowflake.cgl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ koch_template = (p, q ->
55
n = {x: -v.y, y: v.x}
66
vby3 = div3(p, q)
77
m = Div(Add(p, q), 2.0)
8-
nby3 = SetLength(n, 0.5*Sqrt(3.0)*length(vby3))
8+
nby3 = SetLength(n, 0.5*Sqrt(3.0)*Length(vby3))
99
m1 = Add(p, vby3)
1010
m2 = Add(m1, vby3)
1111
ps = [p, m1, Add(m, nby3), m2, q]

examples/logo.cgl

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ main = Shape{
1818
a: tri{scale: X2(0.6), angle: -90}
1919
b: pita{}
2020
//sat(Contact(Moved(getRight(a), 10,0), getLeft(b)))
21-
sat(Contact(getRight(a), Moved(getLeft(b), -10, 0) ))
21+
sat(Contact(getRight(a), Moved(getLeft(b), -20, 0) ))
2222
var(b.pos)
23+
fill: Rgb(255,255,255)
2324
}

examples/pita_p2.cgl

+2-19
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,12 @@ baseColor = Rgb(245, 245, 245)
22
mainColor = Rgb(49, 187, 222)
33
accentColor = Rgb(68, 84, 106)
44

5-
fontPath = "C:/Users/dphs1/AppData/Roaming/Adobe/CoreSync/plugins/livetype/r/35668"
6-
sourceFontPath = "C:/Windows/Fonts/SourceCodePro-Regular.ttf"
7-
8-
sourceCodeText =
9-
"{
10-
size = 100
11-
polygon: [
12-
{x: 0, y: 0}, {x: size, y: 0}
13-
{x: size, y: size}, {x: 0, y: size}
14-
]
15-
fill: {r: 49, g: 187, b: 222}
16-
}"
17-
18-
sourceCodeShape = {
19-
a: BuildText(sourceCodeText, {}, sourceFontPath)
20-
}
21-
225
arrow = Shape{
236
body: Square{scale: Vec2(400, 20), pos: Vec2(-200, 0)}
247
head: Triangle{scale: X2(50), pos: X2(0), angle: 90}
258
}
269

27-
main = {
10+
main = Shape{
2811
a: Square{scale: X2(100), angle: 45}
2912
b: a{pos: Vec2(300, 0)}
3013
strength = 5.0
@@ -37,6 +20,6 @@ main = {
3720

3821
arrowShape = arrow{}
3922
d: DeformShapeByPath2({s:SubDiv(arrowShape, 10)},
40-
c,
23+
c.result,
4124
arrowShape.body.left(), arrowShape.head.top())
4225
}

examples/rec_shape2.cgl

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ shapeList = (f, depth, template ->
55
}
66
else Shape{
77
a: template{}
8-
b: f(f, depth-1, template){
8+
b: (c = f(f, depth-1, template), c{
99
pos.y = -1
1010
angle = 30
1111
scale = X2(0.9)
12-
}
12+
})
1313
}
1414
)
1515

1616
tree = Shape{
1717
depth = 50
18-
a: shapeList(shapeList, depth, Shape{a:Diff(Triangle{}, Buffer(Triangle{}, -0.1))}){scale = X2(100)}
19-
a.b.b.b.b.b = 0
18+
a: (c = shapeList(shapeList, depth, Shape{a:Diff(Triangle{}, Buffer(Triangle{}, -0.1))}), c{scale = X2(100)})
19+
//a.b.b.b.b.b = 0
2020
}

source/Geometry.cpp

+69-69
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,75 @@ namespace cgl
399399
}
400400
};
401401

402+
PackedRecord GetOffsetPathImpl(const Path& originalPath, double offset)
403+
{
404+
auto factory = gg::GeometryFactory::create();
405+
gg::PrecisionModel model(gg::PrecisionModel::Type::FLOATING);
406+
407+
//gob::BufferParameters param(10, gob::BufferParameters::CAP_ROUND, gob::BufferParameters::JOIN_BEVEL, 10.0);
408+
gob::BufferParameters param(10, gob::BufferParameters::CAP_FLAT, gob::BufferParameters::JOIN_BEVEL, 10.0);
409+
410+
gob::OffsetCurveBuilder builder(&model, param);
411+
412+
std::vector<gg::CoordinateSequence*> resultLines;
413+
bool isClosedPath = false;
414+
if (originalPath.empty())
415+
{
416+
CGL_Error("Original Path is Empty");
417+
}
418+
419+
if (2 <= originalPath.cs->size())
420+
{
421+
const auto front = originalPath.cs->front();
422+
const auto back = originalPath.cs->back();
423+
424+
isClosedPath = (front.x == back.x && front.y == back.y);
425+
}
426+
427+
const bool isLeftSide = 0.0 <= offset;
428+
//builder.getLineCurve(&points, 15.0, result);
429+
builder.getSingleSidedLineCurve(originalPath.cs.get(), std::abs(offset), resultLines, isLeftSide, !isLeftSide);
430+
431+
const auto coord = [&](double x, double y)
432+
{
433+
PackedRecord record;
434+
record.add("x", x);
435+
record.add("y", y);
436+
return record;
437+
};
438+
const auto appendCoord = [&](PackedList& list, double x, double y)
439+
{
440+
const auto record = coord(x, y);
441+
list.add(record);
442+
};
443+
444+
PackedList polygonList;
445+
for (size_t i = 0; i < resultLines.size(); ++i)
446+
{
447+
const auto line = resultLines[i];
448+
for (size_t p = 0; p < line->getSize(); ++p)
449+
{
450+
appendCoord(polygonList, line->getX(p), line->getY(p));
451+
}
452+
}
453+
454+
//getSingleSidedLineCurveがClosedPathを返すので最後の点を消す
455+
if (!isClosedPath)
456+
{
457+
polygonList.data.pop_back();
458+
}
459+
460+
//getSingleSidedLineCurveに左と右を指定したとき方向が逆になるので合わせる
461+
if (!isLeftSide)
462+
{
463+
std::reverse(polygonList.data.begin(), polygonList.data.end());
464+
}
465+
466+
PackedRecord result;
467+
result.add("line", polygonList);
468+
return result;
469+
}
470+
402471
PackedRecord ShapeResult(const PackedVal& lhs = PackedList())
403472
{
404473
return MakeRecord(
@@ -1116,75 +1185,6 @@ namespace cgl
11161185
return ShapeResult(MakeRecord("line", polygonList));
11171186
}
11181187

1119-
PackedRecord GetOffsetPathImpl(const Path& originalPath, double offset)
1120-
{
1121-
auto factory = gg::GeometryFactory::create();
1122-
gg::PrecisionModel model(gg::PrecisionModel::Type::FLOATING);
1123-
1124-
//gob::BufferParameters param(10, gob::BufferParameters::CAP_ROUND, gob::BufferParameters::JOIN_BEVEL, 10.0);
1125-
gob::BufferParameters param(10, gob::BufferParameters::CAP_FLAT, gob::BufferParameters::JOIN_BEVEL, 10.0);
1126-
1127-
gob::OffsetCurveBuilder builder(&model, param);
1128-
1129-
std::vector<gg::CoordinateSequence*> resultLines;
1130-
bool isClosedPath = false;
1131-
if (originalPath.empty())
1132-
{
1133-
CGL_Error("Original Path is Empty");
1134-
}
1135-
1136-
if (2 <= originalPath.cs->size())
1137-
{
1138-
const auto front = originalPath.cs->front();
1139-
const auto back = originalPath.cs->back();
1140-
1141-
isClosedPath = (front.x == back.x && front.y == back.y);
1142-
}
1143-
1144-
const bool isLeftSide = 0.0 <= offset;
1145-
//builder.getLineCurve(&points, 15.0, result);
1146-
builder.getSingleSidedLineCurve(originalPath.cs.get(), std::abs(offset), resultLines, isLeftSide, !isLeftSide);
1147-
1148-
const auto coord = [&](double x, double y)
1149-
{
1150-
PackedRecord record;
1151-
record.add("x", x);
1152-
record.add("y", y);
1153-
return record;
1154-
};
1155-
const auto appendCoord = [&](PackedList& list, double x, double y)
1156-
{
1157-
const auto record = coord(x, y);
1158-
list.add(record);
1159-
};
1160-
1161-
PackedList polygonList;
1162-
for (size_t i = 0; i < resultLines.size(); ++i)
1163-
{
1164-
const auto line = resultLines[i];
1165-
for (size_t p = 0; p < line->getSize(); ++p)
1166-
{
1167-
appendCoord(polygonList, line->getX(p), line->getY(p));
1168-
}
1169-
}
1170-
1171-
//getSingleSidedLineCurveがClosedPathを返すので最後の点を消す
1172-
if (!isClosedPath)
1173-
{
1174-
polygonList.data.pop_back();
1175-
}
1176-
1177-
//getSingleSidedLineCurveに左と右を指定したとき方向が逆になるので合わせる
1178-
if (!isLeftSide)
1179-
{
1180-
std::reverse(polygonList.data.begin(), polygonList.data.end());
1181-
}
1182-
1183-
PackedRecord result;
1184-
result.add("line", polygonList);
1185-
return ShapeResult(result);
1186-
}
1187-
11881188
PackedRecord GetOffsetPath(const PackedRecord& packedPathRecord, double offset)
11891189
{
11901190
Path originalPath = std::move(ReadPathPacked(packedPathRecord));

0 commit comments

Comments
 (0)