-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhex.php
257 lines (205 loc) · 7.87 KB
/
hex.php
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
include("config.php");
$ok=1;
if(isset($_GET['hex']) && $_GET['hex']!='')
{
$input = clear($_GET['hex']);
if(!preg_match('/^[a-f0-9]{6}$/i', $input) && !isset($_GET['hex_code']))
{
header('Location: index.php');
}
$input = explode('#',$input);
$input = end($input);
if(strlen($input)!=6) header('Location: index.php');
$ok=1;
}
if(isset($_GET['hex_code']) && $_GET['hex_code']!='')
{
$input = clear($_GET['hex_code']);
if(substr($input,0,1) != '#') $input = '#'.$input;
if(!preg_match('/^#[a-f0-9]{6}$/i', $input))
{
header('Location: index.php');
}
$input = explode('#',$input);
$input = end($input);
if(strlen($input)!=6) die();
$ok=1;
}
if($ok!=1) die();
$color = new Color($input);
if($color->isLight( $input ))
$dl = 'light';
else if($color->isDark( $input ))
$dl = 'dark';
if($dl=='light')
{
$txtcol = 'black';
$txtback = $input;
$txt = "روشن";
}
else if($dl=='dark')
{
$txtcol = 'white';
$txtback = $input;
$txt = "تیره";
}
Theme::header();
?>
<style>
body{
background-color: #<?=$input?>;
background-image: url('assets/img/back.png');
}
</style>
<div class="container" style="background:white;">
<div class="row" style='font-size:20px; font-weight:200;'>
<div class="col-sm-6">
<div class="uptil">
<span style='background:#<?=$input?>; width:100%!important;'><p style="font-size:30px; font-weight:500; direction:ltr; color:<?=$txtcol?>">#<?=$input?></p></span>
</div>
</div>
<div class="col-sm-6">
<table class="table table-striped table-advance table-hover " style=" text-align:center;">
<tbody>
<tr style="height:70px;">
<td style="background:#<?=$txtback?>; color:<?=$txtcol?>;"><span class="label label-default" style="font-size:12px;">این رنگ <?=$txt?> است</span></td>
<td style="background:#<?=$txtback?>; color:<?=$txtcol?>; font-size:12px;">متن روی بلوک دارای پس زمینه با این رنگ</td>
</tr>
<tr>
<td>Hex</td>
<td>#<?php echo $color->gethex(); ?></td>
</tr>
<tr>
<td>RGB</td>
<?php $rgb = hex2rgb($input); ?>
<td style="direction:ltr;">( <p style="display:inline; color:red;"><?=$rgb[0]?></p> , <p style="display:inline; color:green;"><?=$rgb[1]?></p> , <p style="display:inline; color:blue;"><?=$rgb[2]?></p> )</td>
</tr>
<tr>
<td>HSL</td>
<?php $hsl = $color->getHsl(); ?>
<td style="direction:ltr;">( <?=round($hsl['H'],2)?> , <?=round($hsl['S'],2)?> , <?=round($hsl['L'],2)?> )</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row" style='font-size:20px; font-weight:200; margin-top:35px;'>
<div class="mor">
<div class="row">
<div class="col-sm-2"><p>رنگ های تیره تر</p></div>
<div class="col-sm-10"><hr style="margin-left:10px; margin-top:15px; border-top: 0.1px dashed grey; opacity:0.6; "></div>
</div>
<?php
$color = new Color($input);
$darken="";
$lighten="";
for($i=0;$i<18;$i++)
{
$newcolor = $color->darken('2');
$color = new Color($newcolor);
$back = $color->gethex();
$darken .= "<a href='?hex=$back' class='tooltips' title='#$back' data-placement='bottom' data-toggle='tooltip '><span style='background:#$back'></span></a>";
}
echo $darken;
?>
<div class="row">
<div class="col-sm-2"><p>رنگ های روشن تر</p></div>
<div class="col-sm-10"><hr style="margin-left:10px; margin-top:15px; border-top: 0.1px dashed grey; opacity:0.6; "></div>
</div>
<?php
$color = new Color($input);
for($i=0;$i<18;$i++)
{
$newcolor = $color->lighten('2');
$color = new Color($newcolor);
$back = $color->gethex();
$lighten .= "<a href='?hex=$back' class='tooltips' title='#$back' data-placement='bottom' data-toggle='tooltip '><span style='background:#$back'></span></a>";
}
echo $lighten;
$color = new Color($input);
?>
<div class="row">
<div class="col-sm-2"><p>رنگ مکمل</p></div>
<div class="col-sm-10"><hr style="margin-left:10px; margin-top:15px; border-top: 0.1px dashed grey; opacity:0.6; "></div>
</div>
<?php
$color = new Color($input);
$complementary = $color->complementary();
$color = new Color($complementary);
$complement = '';
for($i=0;$i<18;$i++)
{
$newcolor = $color->lighten('2');
$color = new Color($newcolor);
$back = $color->gethex();
$complement .= "<a href='?hex=$back' class='tooltips' title='#$back' data-placement='bottom' data-toggle='tooltip '><span style='background:#$back'></span></a>";
}
echo $complement;
$color = new Color($input);
?>
</div>
</div>
<!-- advertise start -->
<!-- <div class="row">
<div class="col-sm-12">
<center>
<hr>
<script type="text/javascript">
;!( function( w, d ) {
'use strict';
var ad = { user: "1537263719", width: 970, height: 90, id: 'anetwork-' + ~~( Math.random() * 999999 ) },
h = d.head || d.getElementsByTagName( 'head' )[ 0 ],
s = location.protocol + '//static-cdn.anetwork.ir/aw/aw.js';
if ( typeof w.anetworkParams != 'object' )
w.anetworkParams = {};
d.write( '<div id="' + ad.id + '" style="display: inline-block"></div>' );
w.anetworkParams[ ad.id ] = ad;
d.write( '<script type="text/javascript" src="' + s + '" async></scri' + 'pt>' );
})( this, document );</script>
</center>
</div> -->
<!-- </div> -->
<!-- advertise end -->
<div class="row" style="font-size:20px; font-weight:200; margin-top:35px;">
<p style="font-size:12px;"> <i class="fa fa-info-circle animated tada infinite"></i> برای رنگ پس زمینه از کلاس <b>bgcolor</b> و برای رنگ متن از کلاس <b>forecolor</b> و برای رنگ قاب دور المان ها از کلاس <b>bordercolor</b> استفاده کنید</p>
<pre style="text-align:left; direction:ltr;">
<?php $str = "<style>
.bgcolor { background-color:#$input; }
.forecolor { color:#$input; }
.bordercolor { border:3px solid #$input; }
</style>";
echo htmlentities($str); ?>
</pre>
</div>
<div class="row" style="font-size:20px; font-weight:200; margin-top:15px;">
<p style="font-size:12px;"> <i class="fa fa-info-circle animated tada infinite"></i> برای نوشتن یک متن با این رنگ می توانید از کد زیر استفاده کنید </p>
<pre style="text-align:left; direction:ltr;">
<?php $str = "<p style='color:#$input'>متن دلخواه شما</p>";
echo htmlentities($str); ?>
</pre>
</div>
<div class="row" style="font-size:20px; font-weight:200; margin-top:15px;">
<p style="font-size:12px;"> <i class="fa fa-info-circle animated tada infinite"></i> کد یک متن سایه دار با این رنگ </p>
<pre style="text-align:left; direction:ltr;">
<?php $str = "<p style='text-shadow: 4px 4px 2px rgba($rgb[0],$rgb[1],$rgb[2], 0.8);'>متن دلخواه سایه دار</p>";
echo htmlentities($str); ?>
</pre>
</div>
<div class="row" style="font-size:20px; font-weight:200; margin-top:15px;">
<p style="font-size:12px;"> <i class="fa fa-info-circle animated tada infinite"></i> ایجاد یک محیط (<b>div</b>) با رنگ پس زمینه </p>
<pre style="text-align:left; direction:ltr;">
<?php $str = "<div style='background-color:#$input'>محتوای محیط</div>";
echo htmlentities($str); ?>
</pre>
</div>
<div class="row" style="font-size:20px; font-weight:200; margin-top:15px;">
<p style="font-size:12px;"> <i class="fa fa-info-circle animated tada infinite"></i> ایجاد یک (<b>gradients</b>) برای css3 با پشتیبانی انواع مرورگرها </p>
<pre style="text-align:left; direction:ltr;">
<?php
echo $color->getCssGradient();
?>
</pre>
</div>
</div>
<?php Theme::footer(); ?>