{"id":52122,"date":"2024-12-03T08:43:48","date_gmt":"2024-12-03T00:43:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52122\/"},"modified":"2024-12-03T08:43:48","modified_gmt":"2024-12-03T00:43:48","slug":"%e4%bd%bf%e7%94%a8-ps-%e5%88%9b%e5%bb%ba%e5%8a%a8%e6%80%81%e5%87%a0%e4%bd%95%e5%8a%a8%e7%94%bb","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52122\/","title":{"rendered":"\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span>    <\/p>\n<p><span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898<span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u662f<\/span><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b\u300b<\/span>\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241119\/1731984627673bfcf3e6bed.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b\u63d2\u56fe\" alt=\"\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b\u63d2\u56fe\" \/><\/p>\n<h2> <strong>\u7b80\u4ecb<\/strong> <\/h2>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u60a8\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528 p5.js \u521b\u5efa\u52a8\u6001\u4e14\u4e30\u5bcc\u591a\u5f69\u7684\u51e0\u4f55\u52a8\u753b\u3002\u5f62\u72b6\u5c06\u5728\u753b\u5e03\u4e0a\u968f\u673a\u79fb\u52a8\uff0c\u6539\u53d8\u989c\u8272\u5e76\u521b\u5efa\u89c6\u89c9\u4e0a\u8ff7\u4eba\u7684\u6548\u679c\u3002<\/p>\n<hr>\n<h2> <strong>\u7b2c 1 \u6b65\uff1a\u8bbe\u7f6e\u60a8\u7684\u73af\u5883<\/strong> <\/h2>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dp5.js\uff1a<\/strong><\/p>\n<ul>\n<li>\u524d\u5f80 p5.js \u7f51\u7ad9\u5e76\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684 p5.js\u3002<\/li>\n<li>\u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5728\u7ebf p5.js \u7f16\u8f91\u5668 editor.p5js.org\uff0c\u5b83\u5141\u8bb8\u60a8\u76f4\u63a5\u5728\u6d4f\u89c8\u5668\u4e2d\u7f16\u5199\u548c\u8fd0\u884c\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff1a<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u60a8\u4f7f\u7528\u5728\u7ebf\u7f16\u8f91\u5668\uff0c\u8bf7\u5355\u51fb\u5de6\u4e0a\u89d2\u7684\u201c\u65b0\u5efa\u201d\u6765\u521b\u5efa\u65b0\u8349\u56fe\u3002<\/li>\n<li>\u5982\u679c\u60a8\u5728\u672c\u5730\u7f16\u7801\uff0c\u8bf7\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 html \u6587\u4ef6\u5e76\u94fe\u63a5 p5.js \u5e93\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr>\n<h2> <strong>\u7b2c\u4e8c\u6b65\uff1a\u7f16\u5199\u57fa\u672c\u7ed3\u6784<\/strong> <\/h2>\n<p>\u8ba9\u6211\u4eec\u9996\u5148\u8bbe\u7f6e p5.js \u8349\u56fe\u7684\u57fa\u672c\u7ed3\u6784\u3002\u8fd9\u5305\u62ec\u5b9a\u4e49 setup() \u548c draw() \u51fd\u6570\u3002<\/p>\n<pre>function setup() {\n  createcanvas(windowwidth, windowheight);\n  nostroke();  \/\/ disable stroke for the shapes\n}\n\nfunction draw() {\n  background(30, 30, 60, 25);  \/\/ dark background with transparency\n}\n\n\n<\/pre>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li> createcanvas(windowwidth, windowheight);\uff1a\u8fd9\u4f1a\u8bbe\u7f6e\u753b\u5e03\u5927\u5c0f\u4ee5\u5339\u914d\u60a8\u7684\u6d4f\u89c8\u5668\u7a97\u53e3\u3002<\/li>\n<li> nostroke();\uff1a\u8fd9\u4f1a\u5220\u9664\u6211\u4eec\u5c06\u521b\u5efa\u7684\u5f62\u72b6\u7684\u8fb9\u6846\u3002<\/li>\n<li> \u80cc\u666f(30, 30, 60, 25);\uff1a\u8fd9\u5c06\u80cc\u666f\u989c\u8272\u8bbe\u7f6e\u4e3a\u5177\u6709\u4e00\u5b9a\u900f\u660e\u5ea6\u7684\u6df1\u84dd\u8272\uff0c\u4e3a\u5f62\u72b6\u521b\u5efa\u62d6\u5c3e\u6548\u679c\u3002<\/li>\n<\/ul>\n<h2> <strong>\u7b2c\u4e09\u6b65\uff1a\u6dfb\u52a0\u52a8\u6001\u51e0\u4f55\u5f62\u72b6<\/strong> <\/h2>\n<p>\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u6dfb\u52a0\u4ee3\u7801\u6765\u521b\u5efa\u5177\u6709\u4e0d\u540c\u989c\u8272\u3001\u4f4d\u7f6e\u548c\u5927\u5c0f\u7684\u968f\u673a\u5f62\u72b6\u3002<\/p>\n<pre>function draw() {\n  background(30, 30, 60, 25); \/\/ dark background with transparency\n\n  for (let i = 0; i &lt; 5; i++) {\n    let x = random(width);\n    let y = random(height);\n    let size = random(20, 80);\n    let colorr = random(255);\n    let colorg = random(255);\n    let colorb = random(255);\n    let shapetype = random(['ellipse', 'rect', 'triangle']);\n\n    fill(colorr, colorg, colorb, 150); \/\/ set fill color with some transparency\n\n    if (shapetype === 'ellipse') {\n      ellipse(x, y, size, size);\n    } else if (shapetype === 'rect') {\n      rect(x, y, size, size);\n    } else if (shapetype === 'triangle') {\n      triangle(x, y, x + size, y, x + size \/ 2, y - size);\n    }\n  }\n}\n\n\n\n<\/pre>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u968f\u673a\u53d8\u91cf\uff1a<\/strong><\/p>\n<ul>\n<li> x \u548c y \u786e\u5b9a\u753b\u5e03\u4e0a\u6bcf\u4e2a\u5f62\u72b6\u7684\u4f4d\u7f6e\u3002<\/li>\n<li> size \u63a7\u5236\u6bcf\u4e2a\u5f62\u72b6\u7684\u5927\u5c0f\u3002<\/li>\n<li> colorr\u3001colorg\u3001colorb \u4e3a\u586b\u5145\u989c\u8272\u7684\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u5206\u91cf\u751f\u6210\u968f\u673a\u503c\u3002<\/li>\n<li> fill(colorr, colorg, colorb, 150);\uff1a\u8fd9\u8bbe\u7f6e\u4e86\u7a0d\u5fae\u900f\u660e\u7684\u586b\u5145\u989c\u8272\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5f62\u72b6\u7c7b\u578b\uff1a<\/strong><\/p>\n<ul>\n<li> ellipse(x, y, size, size);\uff1a\u7ed8\u5236\u5706\u5f62\u6216\u692d\u5706\u5f62\u3002<\/li>\n<li> rect(x, y, size, size);: \u7ed8\u5236\u6b63\u65b9\u5f62\u6216\u77e9\u5f62\u3002<\/li>\n<li> triangle(x, y, x + size, y, x + size \/ 2, y &#8211; size);: \u7ed8\u5236\u4e00\u4e2a\u4e09\u89d2\u5f62\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2> <strong>\u7b2c\u56db\u6b65\uff1a\u4f7f\u52a8\u753b\u54cd\u5e94\u5f0f<\/strong> <\/h2>\n<p>\u4e3a\u4e86\u786e\u4fdd\u753b\u5e03\u968f\u7a97\u53e3\u8c03\u6574\u5927\u5c0f\uff0c\u8bf7\u6dfb\u52a0\u4ee5\u4e0b\u51fd\u6570\uff1a<\/p>\n<pre>function windowResized() {\n  resizeCanvas(windowWidth, windowHeight);\n}\n\n\n\n<\/pre>\n<h2> <strong>\u7b2c\u4e94\u6b65\uff1a\u8fd0\u884c\u4f60\u7684\u8349\u56fe<\/strong> <\/h2>\n<ul>\n<li>\u5982\u679c\u60a8\u4f7f\u7528 p5.js \u5728\u7ebf\u7f16\u8f91\u5668\uff0c\u53ea\u9700\u6309\u201c\u64ad\u653e\u201d\u6309\u94ae\u5373\u53ef\u67e5\u770b\u52a8\u753b\u3002<\/li>\n<li>\u5982\u679c\u60a8\u5728\u672c\u5730\u7f16\u7801\uff0c\u8bf7\u5728\u7f51\u7edc\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00 html \u6587\u4ef6\u4ee5\u67e5\u770b\u52a8\u753b\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664    <\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5982\u4f55\u4ec5\u901a\u8fc7 border \u5b9e\u73b0\u5e26\u6709\u5355\u89d2\u989c\u8272\u7684 div\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b \u6536\u85cf \u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898\u662f\u300a\u4f7f\u7528 ps \u521b\u5efa\u52a8\u6001\u51e0\u4f55\u52a8\u753b\u300b\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e\u6587\u7ae0\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01 \u7b80\u4ecb \u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u60a8\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528 p5.js \u521b\u5efa\u52a8\u6001\u4e14\u4e30\u5bcc\u591a\u5f69\u7684\u51e0\u4f55\u52a8\u753b\u3002\u5f62\u72b6\u5c06\u5728\u753b\u5e03\u4e0a\u968f\u673a\u79fb\u52a8\uff0c\u6539\u53d8\u989c\u8272\u5e76\u521b\u5efa\u89c6\u89c9\u4e0a\u8ff7\u4eba\u7684\u6548\u679c\u3002 \u7b2c 1 \u6b65\uff1a\u8bbe\u7f6e\u60a8\u7684\u73af\u5883 \u4e0b\u8f7dp5.js\uff1a \u524d\u5f80 p5.js \u7f51\u7ad9\u5e76\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684 p5.js\u3002 \u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5728\u7ebf p5.js \u7f16\u8f91\u5668 editor.p5js.org\uff0c\u5b83\u5141\u8bb8\u60a8\u76f4\u63a5\u5728\u6d4f\u89c8\u5668\u4e2d\u7f16\u5199\u548c\u8fd0\u884c\u4ee3\u7801\u3002 \u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff1a \u5982\u679c\u60a8\u4f7f\u7528\u5728\u7ebf\u7f16\u8f91\u5668\uff0c\u8bf7\u5355\u51fb\u5de6\u4e0a\u89d2\u7684\u201c\u65b0\u5efa\u201d\u6765\u521b\u5efa\u65b0\u8349\u56fe\u3002 \u5982\u679c\u60a8\u5728\u672c\u5730\u7f16\u7801\uff0c\u8bf7\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 html \u6587\u4ef6\u5e76\u94fe\u63a5 p5.js \u5e93\u3002 \u7b2c\u4e8c\u6b65\uff1a\u7f16\u5199\u57fa\u672c\u7ed3\u6784 \u8ba9\u6211\u4eec\u9996\u5148\u8bbe\u7f6e p5.js \u8349\u56fe\u7684\u57fa\u672c\u7ed3\u6784\u3002\u8fd9\u5305\u62ec\u5b9a\u4e49 setup() \u548c draw() \u51fd\u6570\u3002 function setup() { createcanvas(windowwidth, windowheight); nostroke(); \/\/ disable stroke for the shapes } function draw() { background(30, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-52122","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52122"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52122\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}