多种语言花玫瑰,总有一款适合你
@
小丑竟然是自己
今天上午刚打完美赛,和另外两个队友一起奋斗了四天,最后一晚通宵,彻夜未眠,虽然很累,但看到写出一篇25页全英latex排版论文还是挺开心的。如果不得奖的话都打算退出建模圈了,比完赛看了一眼桌面右下角时间
还有两天就除夕了,还有五天就情人节了,emmm,我为什么要加一个就字,情人节好像和我还没啥关系。。。
但至少曾今还是有关系的,曾经有过两段感情,包括初恋,都是以我被分手告终,有时候想想是有点难过,可能的确是自己的原因吧,要么是自己性格的缺陷或者自己还不够足够优秀吧
大大小小也参加十多个各种比赛了,有个人的也有组队的,对于组队打比赛,遇到靠谱的队友一起合作,的确可以培养默契,认识许多新朋友,个人觉得很多人和大学同学不熟悉的原因主要是每个人的生活轨迹可能交集不是很多,如果多参加一些活动,不只是比赛,其实大学还是可以认识一些不错的朋友的,不过我认识的男同胞都是兄弟,本人目前各种取向还是正常的,O(∩_∩)O哈哈~
真心劝告还没有上大学的兄弟姐妹们上大学尽量选择男女比例稍微均衡的学校,要不就剩下和尚庙和尼姑庵了
但是大环境如果好了,也不要掉以轻心哈哈哈
下面是和某位不愿透露姓名的CSDN大佬的对话截图
既然情人节快到了,整理了几种画玫瑰线的代码,祝大家早日找到幸福的TA
Python版本动态画玫瑰
代码
import turtle
# 设置初始位置
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)
# 花蕊
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(10, 180)
turtle.circle(25, 110)
turtle.left(50)
turtle.circle(60, 45)
turtle.circle(20, 170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30, 110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90, 70)
turtle.circle(30, 150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80, 90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150, 80)
turtle.left(50)
turtle.circle(150, 90)
turtle.end_fill()
# 花瓣1
turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60)
turtle.circle(80, 98)
turtle.circle(-90, 40)
# 花瓣2
turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)
# 叶子1
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(-80, 90)
turtle.right(90)
turtle.circle(-80, 90)
turtle.end_fill()
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)
# 叶子2
turtle.right(90)
turtle.right(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(80, 90)
turtle.left(90)
turtle.circle(80, 90)
turtle.end_fill()
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200, 60)
turtle.pendown()
turtle.done()
效果
c语言画心形
代码
#include <stdio.h>
#include <math.h>
int main()
{
//FILE *fp = fopen("graph.txt", "w+");
float x, y, f;
for(y = 1.6; y >= -1.6; y -= 0.15){
for(x = -1.1; x <= 1.1; x += 0.05){
f = x*x + pow(y - pow(x*x, 1.0/3), 2) - 1; //函数方程
//fputc(f <= 1E-5 ? '*' : ' ', fp);
putchar(f <= 1E-5 ? '*' : ' ');
}
//fputc('\n', fp);
putchar('\n');
}
for(y = 1.6; y >= -1.6; y -= 0.15){
for(x = -1.1; x <= 1.1; x += 0.05){
f = x*x + pow(y - pow(x*x, 1.0/3), 2) - 1; //函数方程
//fputc(f > 1E-5 ? '*' : ' ', fp);
putchar(f > 1E-5 ? '*' : ' ');
}
//fputc('\n', fp);
putchar('\n');
}
//fclose(fp);
return 0;
}
由于c没有图形界面,只有在控制台输出啦
matlab画3D玫瑰
代码
function drawrose
grid on
[x,t]=meshgrid((0:24)./24,(0:0.5:575)./575.*20.*pi+4*pi);
p=(pi/2)*exp(-t./(8*pi));
change=sin(15*t)/150;
u=1-(1-mod(3.6*t,2*pi)./pi).^4./2+change;
y=2*(x.^2-x).^2.*sin(p);
r=u.*(x.*sin(p)+y.*cos(p));
h=u.*(x.*cos(p)-y.*sin(p));
map=[1.0000 0.6471 0.8275
0.9984 0.6353 0.8130
0.9969 0.6236 0.7985
0.9953 0.6118 0.7840
0.9937 0.6000 0.7695
0.9921 0.5882 0.7550
0.9906 0.5765 0.7404
0.9890 0.5647 0.7259
0.9874 0.5529 0.7114
0.9859 0.5412 0.6969
0.9843 0.5294 0.6824
0.9757 0.5149 0.6730
0.9670 0.5004 0.6636
0.9584 0.4859 0.6541
0.9498 0.4714 0.6447
0.9411 0.4568 0.6353
0.9325 0.4423 0.6259
0.9239 0.4278 0.6165
0.9153 0.4133 0.6070
0.9066 0.3988 0.5976
0.8980 0.3843 0.5882
0.8937 0.3780 0.5756
0.8894 0.3718 0.5631
0.8851 0.3655 0.5505
0.8808 0.3592 0.5380
0.8764 0.3529 0.5254
0.8721 0.3467 0.5129
0.8678 0.3404 0.5003
0.8635 0.3341 0.4878
0.8592 0.3279 0.4752
0.8549 0.3216 0.4627
0.8561 0.3165 0.4596
0.8573 0.3114 0.4564
0.8584 0.3063 0.4533
0.8596 0.3012 0.4502
0.8608 0.2961 0.4471
0.8620 0.2910 0.4439
0.8632 0.2859 0.4408
0.8643 0.2808 0.4377
0.8655 0.2757 0.4345
0.8667 0.2706 0.4314
0.8549 0.2620 0.4165
0.8432 0.2533 0.4016
0.8314 0.2447 0.3867
0.8196 0.2361 0.3718
0.8078 0.2274 0.3569
0.7961 0.2188 0.3420
0.7843 0.2102 0.3271
0.7725 0.2016 0.3122
0.7608 0.1929 0.2973
0.7490 0.1843 0.2824
0.7553 0.1827 0.2855
0.7616 0.1812 0.2887
0.7678 0.1796 0.2918
0.7741 0.1780 0.2949
0.7804 0.1764 0.2980
0.7867 0.1749 0.3012
0.7930 0.1733 0.3043
0.7992 0.1717 0.3074
0.8055 0.1702 0.3106
0.8118 0.1686 0.3137
0.7977 0.1631 0.3023
0.7836 0.1576 0.2910
0.7694 0.1521 0.2796
0.7553 0.1466 0.2682
0.7412 0.1411 0.2569
0.7271 0.1357 0.2455
0.7130 0.1302 0.2341
0.6988 0.1247 0.2227
0.6847 0.1192 0.2114
0.6706 0.1137 0.2000
0.6686 0.1141 0.1996
0.6667 0.1145 0.1992
0.6647 0.1149 0.1988
0.6628 0.1153 0.1984
0.6608 0.1157 0.1981
0.6588 0.1160 0.1977
0.6569 0.1164 0.1973
0.6549 0.1168 0.1969
0.6530 0.1172 0.1965
0.6510 0.1176 0.1961];
set(gca,'CameraPosition',[2 2 2])
hold on
surface(r.*cos(t),r.*sin(t),h,'EdgeAlpha',0.1,...
'EdgeColor',[0 0 0],'FaceColor','interp')
colormap(map)
end
效果
java画玫瑰线
代码
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class RoseJFrame extends JFrame implements ActionListener {
private RoseCanvas canvas;
public RoseJFrame() {
super("四叶玫瑰线");
Dimension dim = getToolkit().getScreenSize();
this.setBounds(dim.width/4, dim.height/4, dim.width/2, dim.height/2);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel jpanel = new JPanel();
this.getContentPane().add(jpanel, "North");
JButton button_color = new JButton("选择颜色");
jpanel.add(button_color);
button_color.addActionListener(this);
this.canvas = new RoseCanvas(Color.red);
this.getContentPane().add(this.canvas, "Center");
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
Color c = JColorChooser.showDialog(this, "选择颜色", Color.blue);
this.canvas.setColor(c);
this.canvas.repaint();
}
public static void main(String args[])
{
new RoseJFrame();
}
class RoseCanvas extends Canvas {
private Color color;
public RoseCanvas(Color color) {
this.setColor(color);
}
public void setColor(Color color) {
this.color = color;
}
public void paint(Graphics g) {
int x0 = this.getWidth() / 2;
int y0 = this.getHeight() / 2;
g.setColor(this.color);
g.drawLine(x0, 0, x0, y0 * 2);
g.drawLine(0, y0, x0*2, y0);
for (int j = 40; j < 100; j += 20)
for (int i = 0; i < 1024; i++) {
double angle = i*Math.PI/512;
double radius = j*Math.sin(8*angle);
int x = (int)Math.round(radius * Math.cos(angle) * 2);
int y = (int)Math.round(radius * Math.sin(angle));
g.fillOval(x0 + x, y0 + y*2, 2, 2);
}
}
}
}
运行效果
html动态玫瑰玫瑰
代码
<!DOCTYPE html>
<html>
<head>
<title>flower</title>
<meta charset="utf-8">
</head>
<body>
<h1 align="center">A beautiful flower for the most beautiful person under the sun</h1>
<br>
<h1 align="center">LOVE</h1>
<p style="text-align: center;">
<canvas id="c" height="500" width="500"></canvas>
<script>
var b = document.body;
var c = document.getElementsByTagName('canvas')[0];
var a = c.getContext('2d');
document.body.clientWidth;
</script>
<script>
with(m=Math)C=cos,S=sin,P=pow,R=random;c.width=c.height=f=500;h=-250;function p(a,b,c){if(c>60)return[S(a*7)*(13+5/(.2+P(b*4,4)))-S(b)*50,b*f+50,625+C(a*7)*(13+5/(.2+P(b*4,4)))+b*400,a*1-b/2,a];A=a*2-1;B=b*2-1;if(A*A+B*B<1){if(c>37){n=(j=c&1)?6:4;o=.5/(a+.01)+C(b*125)*3-a*300;w=b*h;return[o*C(n)+w*S(n)+j*610-390,o*S(n)-w*C(n)+550-j*350,1180+C(B+A)*99-j*300,.4-a*.1+P(1-B*B,-h*6)*.15-a*b*.4+C(a+b)/5+P(C((o*(a+1)+(B>0?w:-w))/25),30)*.1*(1-B*B),o/1e3+.7-o*w*3e-6]}if(c>32){c=c*1.16-.15;o=a*45-20;w=b*b*h;z=o*S(c)+w*C(c)+620;return[o*C(c)-w*S(c),28+C(B*.5)*99-b*b*b*60-z/2-h,z,(b*b*.3+P((1-(A*A)),7)*.15+.3)*b,b*.7]}o=A*(2-b)*(80-c*2);w=99-C(A)*120-C(b)*(-h-c*4.9)+C(P(1-b,7))*50+c*2;z=o*S(c)+w*C(c)+700;return[o*C(c)-w*S(c),B*99-C(P(b, 7))*50-c/3-z/1.35+450,z,(1-b/1.2)*.9+a*.1, P((1-b),20)/4+.05]}}setInterval('for(i=0;i<1e4;i++)if(s=p(R(),R(),i%46/.74)){z=s[2];x=~~(s[0]*f/z-h);y=~~(s[1]*f/z-h);if(!m[q=y*f+x]|m[q]>z)m[q]=z,a.fillStyle="rgb("+~(s[3]*h)+","+~(s[4]*h)+","+~(s[3]*s[3]*-80)+")",a.fillRect(x,y,1,1)}',0)
</script><br>
</p>
</body>
</html>