心型图案[二]
本帖最后由 jiujiukeji 于 2018-8-22 19:02 编辑<?php
$str = [".",":","-","=","+","*","#","%","@"];
for ($y = 1.5; $y > -1.5;$y -= 0.1) {
for ($x = -1.5; $x < 1.5; $x += 0.05) {
$z = $x * $x + $y * $y - 1;
$f = $z * $z * $z - $x * $x * $y * $y * $y;
echo ($f <= 0 ? $str[(int)($f * -8)] : ' ');
}
echo PHP_EOL;
}
效果图:
附带js版
var str = [".",":","-","=","+","*","#","%","@"];
var love='';
var x=0,y=0,z=0;f=0,st='';
for (y = 1.5; y > -1.5;y -= 0.1) {
for (x = -1.5; x < 1.5; x += 0.05) {
z = x * x + y * y - 1;
f = z * z * z - x * x * y * y * y;
e=parseInt(f * -8);
love+=f <= 0 ? str : ' ';
}
love+="\n";
}
console.log(love)
效果图:
再附python代码:
str = [".", ":", "-", "=", "+", "*", "#", "%", "@"];
love = '';
for y in range(15, -15, -1):
for x in range(-150, 150, 5):
z = x / 100 * x / 100 + y / 10 * y / 10 - 1
f = z * z * z - x / 100 * x / 100 * y / 10 * y / 10 * y / 10
e = int(f * -8);
if f <= 0:
love += str;
else:
love += ' ';
love += '\r';
print(love)
效果图
再来一个走起
记得右键查看源代码 这个❤的内部好奇怪:lol 大佬。。感谢分享 能改别的形状吗? 又来一个心形图案,赞一个 谢谢分享{:1_919:} 可以的,大兄弟
页:
[1]