i love you 浪漫字体复制_七夕 | 程序员到底有多浪漫?

a134fe8a172bf7e106c45951bf04a138.png

七夕情人节来临之际,朋友圈早已被各种代购刷屏,“你啥都不送,让你女朋友七夕的时候在朋友圈炫耀什么?”、“扫一扫进七夕保命群,教你七夕买什么送女友才能保命”、“你男朋友是不是以为你缺氧,所以每个节日都送你空气”......

不得不承认他们一个个都是被代购事业耽误的网络段子手啊。

除了买买买送送送,男朋友就没有其他哄女朋友开心的办法了吗?

实在想不到的话,那就学学看优秀的程序员有多浪漫吧~

1、简单粗暴的1行Python代码(一行内输入)

print('n'.join([''.join([('I LOVprint('n'.join([''.join([('I LOVE U'[(x-y) % 8] if ( (x*0.05)**2 + (y*0.1)**2 -1)**3 - (x*0.05)**2 * (y*0.1)**3 <=0 else ' ') for x in range(-30,30)]) for y in range(15, -15, -1)]))

730edd757e0d80e280561b86416032e6.png

2、照片墙

依赖:

pip install Image clize

使用:

python picture_wall.py --help
Usage:picture_wall.py[OPTONS][text...]

生成照片墙

Arguments:
text...          Text of picture wall,if not defined this will generege a rectangle picture wall

Options:
-s,--font-size=INT     font size of a clear value (default:20)
-e,--edge-len=INT      sub picture's egde length (default:50)
-w,--wall-width=INT    picture number of rectangle width (default:20)
-I,--wall-length=INT   picture number of rectangle length(defualt:10)
-d,--pic-dir=STR       picture's path (default:./img)
-o,--out-dir=STR       output dir(default:./out)
-p,--font-path=STR     font path (default:./demo.ttf)

Other actions:
-h,--help              Show the help

for example:

./picture_wall.py I Love U -s 30 -e 10 

28f1ff1b2cbeb643766358112b9d87dd.png
./picture_wall.py 我爱你 -s 30 -e 10

c3167e19c9f7389aa470a8cee96a84f1.png

如果指定为相册文件夹的话,将得到如下效果(文件夹下图片太多而且太大的话会比较慢):

8653aa8de5ce7cde990abcae4ebf837a.png

也可以选择尺寸的方式调整子图,例如:

python picture_wall.py 1314 -m size

cf28150cb4d2086b845806da9724905d.png

TODO

  • 子照片的处理方式有待提升,目前采用的只是根据字体像素透明度控制透明度,还可以抽象出来让用户选择控制方式~比如:
    • 根据字体像素透明度控制子图形状
    • 根据字体像素透明度控制子图颜色亮度
    • 或者直接采用圆形裁剪子图

3、爱心情书

依赖:

pip install jieba numpy pandas matplotlib wordcloud scipy wordcloud

使用:

python heart_cloud_word.py --help
Usage:./heart_cloud_word.py[OPTONS][par...]

生成文字云

Arguments:
  par...         

Options:
-t,--text-file=STR     text file that contain all you word(default:./data/love_letter.txt)
-s,--stop-file=STR    the stop word which can't be considered (defualt:./data/love_letter.txt)
-c,--color-img=STR     the color map img (default:./data/pink.jpg)
-m,--mask-file=STR     the mask img for the word
-o,--out-file=STR      outout file path which should with sufix of png/jpg... (default:./out/word_cloud.png)
-p,--font-path=STR     font path (default:./demo.ttf)

Other actions:
-h,--help              Show the help

for example:

./heart_cloud_word.py 

673ef3c782bf506a98e3cb71595e0063.png

4、Echarts--极坐标双数值轴

var data = [];

for (var i = 0; i <= 100; i++) {
    var theta = i / 100 * 360;
    var r = 5 * (1 + Math.sin(theta / 180 * Math.PI));
    data.push([r, theta]);
}

option = {
    title: {
        text: '极坐标双数值轴'
    },
    legend: {
        data: ['line']
    },
    polar: {},
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross'
        }
    },
    angleAxis: {
        type: 'value',
        startAngle: 0
    },
    radiusAxis: {
    },
    series: [{
        coordinateSystem: 'polar',
        name: 'line',
        type: 'line',
        data: data
    }]
};

0088dba359cd5c393c74fd5705c911f1.png

5、Matlab画爱心

平面图

x=linspace(-2,2,1000);  
y1=sqrt(2*sqrt(x.^2)-x.^2);  
y2=-2.14*sqrt(sqrt(2)-sqrt(abs(x)));  
plot(x,y1,'b',x,y2,'b');  
axis([-2.5,2.5,-3,1.5]);

1b1614891f3c284b4b6d953dd69fb544.png

立体图

f=@(x,y,z)(x.^2+ (9./4).*y.^2 + z.^2 - 1).^3 - x.^2.*z.^3 - (9./80).*y.^2.*z.^3;  
[x,y,z]=meshgrid(linspace(-1.5,1.5));  
val=f(x,y,z);  
isosurface(x,y,z,val,0);   
axis equal;view(3);colormap([1 0.2 0.2])  

0a6f31ae2a21a3840cc146f7e8f733d6.png

都看到这儿了,就留个赞再走呗n(*≧▽≦*)n~

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值