-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2015, Viktor Dakalov. All rights reserved. Use of this source code | ||
// is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
library dlog.example.table; | ||
|
||
import "dart:math" as Math; | ||
import "package:dlog/dlog.dart" as dlog; | ||
|
||
double rad(num deg) => | ||
deg * (Math.PI / 180); | ||
|
||
main() { | ||
|
||
// create new table and specify the column number | ||
var table = new dlog.Table(1); | ||
|
||
// you can add header names (optional) | ||
// in this case the number of columns is changed to 3 | ||
table.columns.add("deg°"); | ||
table.columns.addAll(["radian", "vector (x, y)"]); | ||
|
||
for (int angle = 0; angle < 360; angle++) { | ||
|
||
String x = (1 * Math.sin(angle)).toStringAsFixed(4), | ||
y = (1 * Math.cos(angle)).toStringAsFixed(4); | ||
|
||
// add row (number of cell equal columns number) | ||
table.data.addAll([ | ||
angle, // deg° | ||
rad(angle), // radian | ||
[x, y] // vector (x, y) | ||
]); | ||
} | ||
|
||
// cut part of table | ||
var pi = table.clone().crop(0, 180), | ||
pi2 = table.clone().crop(180, 180); | ||
|
||
// output to console | ||
print(table); | ||
|
||
// output range 0-179 | ||
print(pi); | ||
|
||
// output range 180-359 | ||
print(pi2); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2015, Viktor Dakalov. All rights reserved. Use of this source code | ||
// is governed by a BSD-style license that can be found in the LICENSE file. | ||
|
||
library dlog.example.tree; | ||
|
||
import "package:dlog/dlog.dart" as dlog; | ||
|
||
List<Map> users = [ | ||
{ | ||
"name": "Dmitry", | ||
"age": 23, | ||
"city": "Yekaterinburg" | ||
}, | ||
{ | ||
"name": "Vasya", | ||
"age": 28, | ||
"city": "Moskow" | ||
} | ||
]; | ||
|
||
main() { | ||
|
||
var users_tree = new dlog.Tree("Users"); | ||
users_tree.openGroup(); | ||
|
||
for (int i = 0; i < users.length; i++) { | ||
users_tree..add(users[i]["name"]) | ||
..openGroup() | ||
..add("age: ${users[i]["age"]}") | ||
..add("city: ${users[i]["city"]}") | ||
..closeGroup() | ||
; | ||
} | ||
|
||
// users_tree.closeGroup(); | ||
print(users_tree..closeGroup()); | ||
|
||
} |