”
生活中,我们经常发现很多程序员的薪水很高,但往往沦落为单身狗。 情人节将至,他们只能孤独一人,过着十分凄惨的生活。
程序员自从毕业进入IT行业后,往往与女性没有接触,一不小心就到了被催婚的年龄。
以前,阿里的一位高级工程师穿着一双安踏运动鞋去相亲,但被对方拒绝了。 后来某程序员自爆去相亲,却带着相亲对象吃了79个麦当劳,回来后被妹子拉黑。
程序员常常是你嘲笑的对象,因为他们每天晚上都在机器和笔记本上工作,给人的印象是书呆子、迟钝、不善于沟通……
据说世界上有两种程序员,一种是有女朋友的程序员,另一种是不知道其他程序员如何找到女朋友的程序员。
有女朋友的程序员如何找女朋友? 我们来看看网友们是怎么说的。
程序员下班后如何找女朋友?
@zhihu小鸡精
程序员女友内心OS:你瞎什么眼!
@zhihu杨诺
这可以说是惨不忍睹
@知识程序员阿姨
作为银幕上的程序员,你还喜欢女生吗?
@zhihuyu Cheng
在这个行业里,长得帅并不重要吧?
@几乎认识卡拉贾迪斯
说了这么离谱的话
很多女孩表示都想找个程序员做男朋友,但是为什么……
事实上,除了是个书呆子之外,为什么近乎完美的高薪程序员仍然单身呢? 对于这个问题目前还没有合理的解释。 那么,就让我们一起来看看下面的故事吧!
为什么程序员不再追女孩了?
为什么程序员不再追女孩了? 当然是因为,女朋友怎么能有好看的代码,女朋友怎么能有懂我的女朋友,还有女朋友总是关心我,我为什么要有女朋友。
对不起我撒谎了,我为什么撒谎,我先讲个故事。
3个月前,我向一见钟情的女孩发了求情信,没想到她回复数据的速度很快。
和它交互了一个月,传递了一些参数,我终于鼓起勇气发出新的请求。
没有反应,再恳求,再恳求,她还是回复了404,我觉得我的路径有问题。
可以ping通,但是无法访问,奇怪! 于是我决定用我哥们的代理服务器,我最好的朋友建议我改一下参数程序员都去什么网站上班,比如某种香水。
这次我立即响应,当我登录主页提示我提交数据时,她返回了一个空结果作为响应,所以我传递了更多参数并再次发送请求。
这次她显示权限不足,还是404。我找了我最好的朋友一起帮忙找bug,但是在找我的bug的过程中,我发现有几个人同时给她发请求,但是都得到了一个回复。
有的甚至已经开启了白名单。 原来服务器端并不是无法处理并发,而是直接忽略了我的请求。
最后我恍然大悟,原来是CPU和显卡的性能不够,只能当备份了。 难怪他们经常回复数据、接受参数程序员都去什么网站上班,但功能都无法使用。
最终我花了差不多10K,但我意识到是时候及时补仓了。 最后,当我狠心卸载的时候,她还是想尽办法保留,还让我评价一下服务……
过几天,有人建议我尝试访问好友的代理地址,传递同样的参数,也许能行,而且性能会更好。 但我没有这么做,因为即使在这个充满枪声的社会,我也不想成为一个被女生诟病的渣男。
幸运的是,我没有等到“我一直把你当同学”触发暂停请求,但最终由于天赋和学习的不足,我无法处理这些高并发问题,更不用说保证线程安全了。 考虑到时间、空间、个人心理问题后,只能选择放弃。
前几天,突然听到朋友圈里,一个头像可爱的女孩说:“为什么女孩子总是追到一半就不再追了?”
什么? 一半? 为什么要给一个进度条? 一个女孩怎么会认为自己应该一直被追到底呢? ! 对不起,这种事情对于被追求者来说是一半,但是对于追求者来说已经结束了。
你不喜欢我,我心里不承认,你嘴上也不承认,后来我想通了,我不欠你什么。
我不想因为吃苦而去学习套路,因为很多事情告诉我,世界上最甜蜜、最感人的人就是这些愚蠢的人,而不是这些牛逼(pi)。
我身边的程序员都是老实女儿。 我们有一些积蓄,但我们不想成为提款机。
如果你不喜欢我,请直接告诉我,我没有比特币,更没有208万,我会怀着远大的志向和你说再见,但我仍然相信感情,我只希望当我遇见你的时候,那就是你了!
读完上面的故事,你有何感想? 程序员可能是世界上“直男癌”患者最多的群体之一。
但是……你真以为他们是直率、死板、书呆子、不懂得甜蜜的人吗? 开什么玩笑啊! 值此520之际,小编特意搜集了这位程序员的专属求婚表分享给大家,一起来看看程序员用代码做出来的甜蜜吧~
程序员的小甜蜜——烟花
完整项目预览地址:
属性设计
烟花应该有三种状态:
烟花:发射点(x,y),爆炸点(xEnd,yEnd),升空后爆炸等待时间(wait),爆炸后颗粒数(计数),烟花直径(半径)
烟花爆炸后的粒子:它们自己的位置(x,y),它们自己的大小(size),它们自己的速度(rate),以及烟花的最大直径(半径)。
config:全局变量和控制参数,包括画布宽度和高度、设置firework属性等。
设置全局变量
const config = {
width: 360,
height: 600,
canvases: ['bg', 'firework'],
skyColor: '210, 60%, 5%, 0.2)',
fireworkTime:{min:30,max:60},
//烟花参数本身有默认值 传入undefined则使用默认参数
fireworkOpt:{
x: undefined,
y: undefined,
xEnd: undefined,
yEnd: undefined,
count: 300, //炸裂后粒子数
wait: undefined, //消失后 => 炸裂 等待时间
}
}
构建粒子
class Particle{
//默认值写法
constructor({x, y, size = 1, radius = 1.2} = {}){
this.x = x;
this.y = y;
this.size = size;
this.rate = Math.random(); //每个微粒移动的速度都是随机不同的
this.angle = Math.PI * 2 * Math.random(); //每个微粒的偏移角度
//每次微粒移动速度分解为横纵坐标的移动。
this.vx = radius * Math.cos(this.angle) * this.rate;
this.vy = radius * Math.sin(this.angle) * this.rate;
}
go(){
this.x += this.vx;
this.y += this.vy;
this.vy += 0.02; //重力影响 y越大实际越偏下
//空气阻力
this.vx *= 0.98;
this.vy *= 0.98;
}
//画出微粒的位置
render(ctx){
this.go();
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2, false);
ctx.fill();
}
}
构建 Fireworks 类
class Firework{
constructor({x, y = config.height, xEnd, yEnd, count = 300, wait} = {}){
//烟花自身属性
this.x = x || config.width / 8 + Math.random() * config.width * 3 / 4;
this.y = y;
this.xEnd = xEnd || this.x;
this.yEnd = yEnd || config.width / 8 + Math.random() * config.width * 3 / 8;
this.size = 2;
this.velocity = -3;
this.opacity = 0.8;
this.color = `hsla(${360 * Math.random() | 0},80%,60%,1)`;
this.wait = wait || 30 + Math.random() * 30;
//微粒个数等
this.count = count;
this.particles = [];
this.createParticles();
this.status = 1;
}
//创建微粒
createParticles(){
for(let i = 0;i < this.count; ++i){
this.particles.push(new Particle({x:this.xEnd, y:this.yEnd}));
}
}
//升空
rise(){
this.y += this.velocity * 1;
this.velocity += 0.005; //升空时产生的阻力
//烟花升空到目标位置开始渐隐
if(this.y - this.yEnd <= 50){
this.opacity = (this.y - this.yEnd) / 50;
}
//如果到了目标位置 就开始第二个状态
if(this.y <= this.yEnd){
this.status = 2;
}
}
//渲染烟花 烟花所有动作完成之后返回false
render(ctx){
switch(this.status){
case 1: //升空
ctx.save();
ctx.beginPath();
ctx.globalCompositeOperation = 'lighter';
ctx.globalAlpha = this.opacity;
ctx.translate(this.x, this.y);
ctx.scale(0.8, 2.3);
ctx.translate(-this.x, -this.y);
ctx.fillStyle = this.color;
ctx.arc(this.x + Math.sin(Math.PI * 2 * Math.random()) / 1.2, this.y, this.size, 0, Math.PI * 2, false);
ctx.fill();
ctx.restore();
this.rise();
return true;
break;
case 2: //烟花消失阶段,等待炸裂
if(--this.wait <= 0){
this.opacity = 1;
this.status = 3;
}
return true;
break;
case 3: //炸裂之后 渲染烟花微粒
ctx.save();
ctx.globalCompositeOperation = 'lighter';
ctx.globalAlpha = this.opacity;
ctx.fillStyle = this.color;
for(let i = 0;i < this.particles.length;++i){
this.particles[i].render(ctx);
}
ctx.restore();
this.opacity -= 0.01;
return this.opacity > 0;
break;
default:
return false;
}
}
}
点燃烟花
const canvas = {
init: function(){
//一些属性的设定 可以不用管
this.setProperty();
this.renderBg();
//循环体 **主要
this.loop();
},
setProperty: function(){
this.fireworks = [];
this.width = config.width;
this.height = config.height;
this.fireworkTime = (config.fireworkTime.min + (config.fireworkTime.max - config.fireworkTime.min) * Math.random()) | 0;
this.bgCtx = document.querySelector('#bg').getContext('2d');
this.fireworkCtx = document.querySelector('#firework').getContext('2d');
},
renderBg(){
this.bgCtx.fillStyle = 'hsla(210, 60%, 5%, 0.9)'
this.bgCtx.fillRect(0, 0, this.width, this.height);
},
loop(){
requestAnimationFrame(this.loop.bind(this));
this.fireworkCtx.clearRect(0, 0, this.width, this.height);
//随机创建烟花
if(--this.fireworkTime <= 0){
this.fireworks.push(new Firework(config.fireworkOpt));
//每次到点之后重新设置烟花产生时间 (|0转化为整数)
this.fireworkTime = (config.fireworkTime.min + (config.fireworkTime.max - config.fireworkTime.min) * Math.random()) | 0;
}
for(let i = this.fireworks.length - 1; i >= 0; --i){
//渲染烟花 (若返回值为false则移除烟花)
!this.fireworks[i].render(this.fireworkCtx) && this.fireworks.splice(i,1);
}
}
}
canvas.init();
完全的
这时的烟花就是这样的,感觉就像少了一点尾巴。
现在我们已经消除了每一帧的画布。 添加一个小尾巴看起来很简单。 不是消除每一帧的画布,而是覆盖一层新的透明天空。
//canvas.loop方法
// this.fireworkCtx.clearRect(0, 0, this.width, this.height);
this.fireworkCtx.fillStyle = config.skyColor;
this.fireworkCtx.fillRect(0,0,this.width,this.height);
事情就是这样完成的。 不过,还是缺少爆燃后天空立即变亮的场景。 那么在画烟花的时候,首先得到烟花的颜色和透明度。
// *****Firework constructor
// this.color = `hsla(${360 * Math.random() | 0},80%,60%,1)`;
this.hue = 360 * Math.random() | 0;
this.color = `hsla(${this.hue},80%,60%,1)`;
// *****Firework 新增实例方法
getSkyColor(){
const skyColor = {
//只有炸裂阶段才返回亮度
lightness: this.status == 3 ? this.opacity : 0 ,
hue: this.hue
};
return skyColor;
}
// *****config 修改config的skyColor
// skyColor: 'hsla(210, 60%, 5%, 0.2)',
skyColor: 'hsla({hue}, 60%, {lightness}%, 0.2)',
// canvas.loop方法
//this.fireworkCtx.fillStyle = config.skyColor;
//每次替换色调与亮度值。
this.fireworkCtx.fillStyle = config.skyColor.replace('{lightness}', 5 + this.skyColor.lightness * 15).replace('{hue}' , this.skyColor.hue);
this.skyColor = { //新增
lightness: 0,
hue: 210
};
for(let i = this.fireworks.length - 1; i >= 0; --i){
//新增 天空颜色为最亮的烟花的颜色
this.skyColor = this.skyColor.lightness >= this.fireworks[i].getSkyColor().lightness ? this.skyColor : this.fireworks[i].getSkyColor();
!this.fireworks[i].render(this.fireworkCtx) && this.fireworks.splice(i,1);
}
即使现在也已经完成了。
完整的项目
Github项目地址: