Skip to content

Commit 4c642d4

Browse files
committed
Adds crossHairs. Reveals a bug in objectdraw?
1 parent f5167cd commit 4c642d4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

objectdrawPrograms/crossHairs.grace

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
dialect "objectdraw"
2+
print(1@2)
3+
def crossHairs = object {
4+
inherits graphicApplicationSize(400@400)
5+
6+
// lines forming crosshairs
7+
def vertical = lineFrom ((canvas.width/2) @ 0)
8+
to ((canvas.width/2) @ (canvas.height)) on (canvas)
9+
def horizontal =
10+
lineFrom(0 @ (canvas.height/2)) to ((canvas.width) @ (canvas.height/2)) on (canvas)
11+
12+
// Move the lines to follow the mouse
13+
method onMouseDrag(point) {
14+
15+
vertical.setEndPoints((point.x) @ 0,
16+
(point.x) @ (canvas.height))
17+
horizontal.setEndPoints(0 @ (point.y),
18+
(canvas.width) @ (point.y))
19+
}
20+
21+
def shapes: Choice = menuWithOptions ["FramedSquare","FramedCircle"]
22+
23+
// required to pop up window and start graphics
24+
startGraphics
25+
}

0 commit comments

Comments
 (0)