Repository navigation
Expand file tree
/
Copy pathtest_draw_elbows.py
More file actions
63 lines (48 loc) · 1.54 KB
/
Copy pathtest_draw_elbows.py
File metadata and controls
63 lines (48 loc) · 1.54 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from __future__ import division, print_function, unicode_literals
# This code is so you can run the samples without installing the package
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
#
testinfo = "s, q"
tags = "Draw, join"
import cocos
from cocos.director import director
from cocos import draw
import pyglet
class TestFigure(draw.Canvas):
def render(self):
x,y = director.get_window_size()
ys = y//4
ye = ys*3
xs = x//4
line_width = 50
self.set_color( (255,255,0,100) )
self.set_stroke_width( line_width )
self.set_join( draw.BEVEL_JOIN )
self.move_to( (xs+100, ys) )
self.line_to( (xs*2+100,ys) )
self.line_to( (xs*2+100,ys*2) )
self.line_to( (xs*3+100,ys*2) )
self.set_join( draw.MITER_JOIN )
self.move_to( (xs, ys+100) )
self.line_to( (xs*2,ys+100) )
self.line_to( (xs*2,ys*2+100) )
self.line_to( (xs*3,ys*2+100) )
self.set_join( draw.ROUND_JOIN )
self.move_to( (xs-100, ys+200) )
self.line_to( (xs*2-100,ys+200) )
self.line_to( (xs*2-100,ys*2+200) )
self.line_to( (xs*3-100,ys*2+200) )
class TestLayer(cocos.layer.Layer):
def __init__(self):
super( TestLayer, self ).__init__()
self.add( TestFigure() )
self.schedule( lambda x: 0 )
def main():
director.init()
test_layer = TestLayer ()
main_scene = cocos.scene.Scene (test_layer)
director.run (main_scene)
if __name__ == '__main__':
main()