1
- from math import *
2
1
from casioplot import *
3
2
4
3
@@ -9,47 +8,6 @@ def get_color(rgb, rgba):
9
8
return int (r ), int (g ), int (b )
10
9
11
10
12
- def draw (p , color = (0 , 0 , 0 )):
13
- x , y = p
14
- x += casioplot_settings .get ('width' ) // 2
15
- y += casioplot_settings .get ('height' ) // 2
16
-
17
- if casioplot_settings .get ('width' ) >= x >= 0 and casioplot_settings .get ('height' ) >= y >= 0 :
18
- bg = get_pixel (x , y )
19
- if len (color ) == 4 :
20
- c = get_color (bg , (color [0 ], color [1 ], color [2 ], color [3 ]))
21
- else :
22
- c = get_color (bg , (color [0 ], color [1 ], color [2 ], 255 ))
23
-
24
- set_pixel (round (x ), round (y ), c )
25
- else :
26
- print ("Warning: Pixel at position ({};{}) doesn't exist." .format (
27
- x - casioplot_settings .get ('width' ) // 2 ,
28
- y - casioplot_settings .get ('height' ) // 2 ))
29
-
30
-
31
- def line (p1 , p2 , color ):
32
- """
33
- Test of a line drawing function that use trigonometry to find the nearest pixel for each point of a line.
34
- """
35
- xa , ya = p1
36
- xb , yb = p2
37
- x , y = xa - xb , ya - yb
38
- d = dist (x , y )
39
- if x != 0 :
40
- a = atan2 (y , x )
41
- # if x < 0:
42
- # a += pi
43
- elif y > 0 :
44
- a = pi / 2
45
- else :
46
- a = 3 * pi / 2
47
- for i in range (round (d )):
48
- x1 = round (cos (a ) * i ) - xa
49
- y1 = round (sin (a ) * i ) - ya
50
- draw ((x1 , y1 ), color )
51
-
52
-
53
11
def _f_part (x ):
54
12
return x - int (x )
55
13
0 commit comments