-
-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathItemPathJS.ux
More file actions
28 lines (23 loc) · 752 Bytes
/
ItemPathJS.ux
File metadata and controls
28 lines (23 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<Item ux:Class="ItemPathJS" Title="JavaScript Path">
<JavaScript>
var Observable = require("FuseJS/Observable")
var rows = 4
var cols = 20
//draw a full rectangle
var path = "M 0 0 h 100 v 100 h -100 v -100 z"
var cellHeight = 100 / rows
var cellWidth = 100 / cols
//draw cells in opposite stroke direction to subtract them
for (var x=0; x < cols; ++x) {
for (var y =0; y < rows; ++y) {
if ( (x%2) == (y%2) ) {
continue
}
path += "M " + ((x/cols) * 100) + " " + ((y/rows) * 100)
path += "v " + cellHeight + " h " + cellWidth + " v -" + cellHeight + " h -" + cellWidth + " z"
}
}
exports.path = path
</JavaScript>
<Path Data="{path}" Color="#444" Height="200" StretchMode="Fill"/>
</Item>