-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo.php
More file actions
86 lines (71 loc) · 2.28 KB
/
Copy pathgo.php
File metadata and controls
86 lines (71 loc) · 2.28 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
session_start();
define("CELL_COUNT", "19");
define("CELL_SIZE", "30");
if(isset($_POST['x']))
{
if(isset($_POST['y']))
{
if(isset($_POST['y']))
{
$post_x = $_POST['x'];
$post_y = $_POST['y'];
$move = $_POST['move'];
if(isset($_SESSION['array']))
{
$array=$_SESSION['array'];
}
$array[] = array($post_x,$post_y, $move);
$_SESSION['array'] = $array;
showField();
}
}
}
else
{
unset($_SESSION);
}
function put_stone($img)
{
foreach($_SESSION['array'] as $arr)
{
$mouse_X = (int)round((float)($arr[0] / CELL_SIZE)); //îïðåäåëåíèå êîîðäèíàò íàæàòè¤ ìûøè
$mouse_Y = (int)round((float)($arr[1] / CELL_SIZE));
if($arr[2]==1)
$color = imagecolorallocate($img, 255, 255, 255);
else
$color = imagecolorallocate($img, 0, 0, 0);
$black = imagecolorallocate($img, 0, 0, 0);
//
imagefilledellipse($img,$mouse_X*CELL_SIZE,$mouse_Y*CELL_SIZE,30,30,$color);
imageellipse($img,$mouse_X*CELL_SIZE,$mouse_Y*CELL_SIZE,30,30,$black);
}
}
function showField() // ðèñóåì ïîëå
{
header("Content-type: image/jpg");
$img = imagecreatetruecolor((CELL_SIZE*CELL_COUNT)+CELL_SIZE, (CELL_SIZE*CELL_COUNT)+CELL_SIZE);
$black = imagecolorallocate($img, 0, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 1, 1, $white);
for ($rows = 1; $rows < CELL_COUNT; $rows++)
{
for ($columns = 1; $columns < CELL_COUNT; $columns++)
{
cell_paint($img, $rows, $columns, $black);
}
}
if(isset($_SESSION['array']))
{
put_stone($img, $move);
}
imagejpeg($img, 'file.jpg');
imagedestroy($img);
}
function cell_paint($img,$rows, $columns, $black) //ðèñóåì êëåòêó
{
$x = ($columns) * CELL_SIZE;
$y = ($rows) * CELL_SIZE;
imagerectangle($img, $x, $y, $x+CELL_SIZE, $y+CELL_SIZE, $black);
}
?>