用canvas绘制花朵

news/2024/10/17 12:22:49/

一 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>使用canvas绘制花朵</title><script type="text/javascript">var context;var A, n;function btn_onclick() {var width;var height;var canvas;var Xo, Yo;var k;canvas=document.getElementById("canvas");width=canvas.width;height=canvas.height;context=canvas.getContext('2d');Xo=width/2;
            Yo=height/2;
            k=parseInt(document.getElementById("drawType").value);if(k==2)A=Yo*0.25;elseA=Yo*0.75;context.save();context.clearRect(0,0,width,height);context.translate(Xo,Yo);context.beginPath();for(var B=0;B<=6.28;B=B+0.01){draw(B);}context.closePath();context.restore();}function draw(B) {var n = 10;switch (parseInt(document.getElementById("drawType").value)) {case 3:r = A * Math.sin(n * B) * Math.exp(-B / (20));break;case 2:r = A * (Math.sin(n * B)) + 3 * Math.sin(3 * n * B);break;case 1:r = A * Math.sin(n * B);}x = r * Math.cos(B);y = r * Math.sin(B);context.fillStyle = "green";context.strokeStyle = "black";context.lineTo(-x, -y);context.fill();context.stroke();}</script><h1>使用canvas绘制花朵</h1>花的类型:<select id="drawType"><option value="1">蓬莱菊</option><option value="2">令箭荷花</option><option value="3">大丽花</option></select><input type="button" id="btn" value="绘制" onclick="btn_onclick()" /><br /><canvas id="canvas" width="200px" height="200px"></canvas></head>
<body></body>
</html>

 

 

 

    

 

转载于:https://www.cnblogs.com/yangyu54/p/4597336.html


http://www.ppmy.cn/news/563083.html

相关文章

基于TensorFlow训练花朵识别模型的源码和Demo

基于TensorFlow训练花朵识别模型的源码和Demo 下面就通过对现有的 Google Inception-V3 模型进行 retrain &#xff0c;对 5 种花朵样本数据的进行训练&#xff0c;来完成一个可以识别五种花朵的模型&#xff0c;并将新训练的模型进行测试部属&#xff0c;让大家体验一下完整的…

四瓣花图形绘制

代码实现 import turtle for i in range(4):turtle.seth(90*(i1))turtle.circle(50,90)turtle.seth(-90i*90)turtle.circle(50,90) turtle.hideturtle()#隐藏画笔箭头

网上花店网页

<!DOCTYPE html> <html><head><meta http-equiv"Content-Type" content"text/html;charset utf-8"/><link rel"stylesheet" href"css/style03.css" type"text/css"/><title>网上花店…

“花朵分类“ 手把手搭建【卷积神经网络】

前言 本文介绍卷积神经网络的入门案例,通过搭建和训练一个模型,来对几种常见的花朵进行识别分类; 使用到TF的花朵数据集,它包含5类,即:“雏菊”,“蒲公英”,“玫瑰”,“向日葵”,“郁金香”;共 3670 张彩色图片;通过搭建和训练卷积神经网络模型,对图像进行分类,…

绘制花朵Flower

XMarksTheSpot 基类见:http://blog.csdn.net/u013384702/article/details/17883367 Code:(GraphicsPath类的使用) using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms;namespace CsStudy {class Flower : XMarksTheSpot{public…

【HTML——盛开花朵】(效果+代码)

效果展示 代码 下面即为全部源代码: 盛开花朵.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML>

玫瑰花怎么画?花朵怎么画?鲜花怎么画?

玫瑰花怎么画&#xff1f;花朵怎么画&#xff1f;鲜花怎么画&#xff1f;如何找到女朋友&#xff1f;学习绘画难吗&#xff1f;怎样才能学好绘画&#xff1f;想必这些都是绘画初学者们经常在想的问题吧&#xff0c;就是不知道如何才能绘画好一朵好看的玫瑰花&#xff0c;想要给…

【花朵识别】基于matlab模板匹配花朵分类【含Matlab源码 472期】

⛄一、获取代码方式 获取代码方式1: 完整代码已上传我的资源:【花朵识别】基于matlab模板匹配花朵分类【含Matlab源码 472期】 点击上面蓝色字体,直接付费下载,即可。 获取代码方式2: 付费专栏Matlab图像处理(初级版) 备注: 点击上面蓝色字体付费专栏Matlab图像处理…