// Define variables
let stars = [];
let numStars = 100;
// Set up the canvas
function setup() {
createCanvas(600, 600);
// Create stars and add them to the array
for (let i = 0; i < numStars; i++) {
stars.push(new Star());
}
}
// Draw the stars
function draw() {
background(0);
// Update and display each star
for (let i = 0; i < numStars; i++) {
stars[i].update();
stars[i].display();
}
}
// Define the Star class
class Star {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(1, 5);
this.speed = random(1, 5);
this.color = color(random(255), random(255), random(255));
}
// Update the star's position
update() {
this.x += this.
fix invalid codeThu, 03 Aug 2023 > 字符串插值不支持空格
## Resources
* [Javascript](https://www.javascript.com/)
* [Node](https://nodejs.org/en/)
* [React](https://reactjs.org/)
* [React-Router](https://github.com/ReactTraining/react-router)
* [React-MDL](https://github.com/react-mdl/react-mdl)
* [react-router-dom](https://www.npmjs.com/package/react-router-dom)
* [react-dom](https://www.npmjs.com/package/react-dom)
* [react-scripts](https://www.npmjs.com/package/react-scripts)
function makeButton(color, text) {
return `
<button style="color: ${color};">${text}</button>
`
}
makeButton('red', 'Click Me')
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<div class="container" id="main">
hello world
<br>
<a href="#" id="clicker">click</a>
<span id="score">0</span>
<br>
<div id="shop">
<h1>shop</h1>
<p>
<span id="auto-clicker">0</span>
<a href="#" id="buy-auto-clicker">
###
time complexityTue, 01 Aug 2023 O(n)
<!DOCTYPE html>
<html>
<head>
<title>Clicker Game</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<div class="container" id="main">
<h1>Clicker Game</h1>
<p>Click the space with your mouse to get coins</p>
<div id="button-container">
<button>Click</button>
</div>
<div>
<p>Coins: <span id="coins-value">0</span></p>
</div>
<div>
<p>Clicks: <span id="clicks-value">0</span></p>
</div>
</div>
</body>
</html
function setup() {
createCanvas(600, 400);
}
function draw() {
background(0);
stroke(255);
strokeWeight(4);
noFill();
ellipse(300, 200, 100, 100);
ellipse(mouseX, mouseY, 100, 100);
}
function that:
## JS DOM
### With arrow functions
let stars = [];
let planets = [];
let numStars = 10;
let numPlanets = 30;
function setup() {
createCanvas(600, 600);
for (let i = 0; i < numStars; i++) {
stars.push(new Star());
}
for (let i = 0; i < numPlanets; i++) {
let starIndex = floor(random(numStars));
planets.push(new Planet(stars[starIndex]));
}
}
function draw() {
background(0);
for (let i = 0; i < numStars; i++) {
stars[i].update();
stars[i].display();
}
for (let i = 0; i < numPlanets; i++) {
planets[i].update();
planets[i].display();
}
}
class Star {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(20, 50);
<div class="container" id="main">
<div class="container" id="clicker">
<div class="clicker" id="clicker-1">
<div class="clicker" id="clicker-1">
<div class="clicker" id="clicker-double">
<div class="clicker" id="clicker-1"></div>
<div class="clicker" id="clicker-1"></div>
</div>
<div class="clicker" id="clicker-1"></div>
<div class="clicker" id="clicker-1"></div>
</div>
<div class="clicker" id="clicker-1"></div>
<div class="clicker" id="clicker-1"></div>
</div>
</div>
</div>
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
for (var i = 0; i <= 400; i = i + 10) {
var startX = 0;
var startY = i;
var endX = i;
var endY = 400;
line(startX, startY, endX, endY);
}
}
function draw() {
background(220);
}
format:
Hi
def add(a, b):
return a + b
translateTue, 01 Aug 2023 int main(int argc, char const *argv[]) {
/* code */
return 0;
}
// main.js
function setup() {
createCanvas(500, 500);
background(0);
}
function draw() {
background(0);
point(0, 0);
point(0, 500);
point(500, 0);
point(500, 500);
point(250, 250);
point(250, 50);
point(250, 450);
point(50, 250);
point(450, 250);
point(50, 50);
point(50, 450);
point(450, 50);
point(450, 450);
}
<!DOCTYPE html>
<html>
<head>
<title>hello world</title>
</head>
<body>
<p>hello world</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="container" id="main">hello world</div>
</body>
</html>
translateTue, 01 Aug 2023 #include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
function setup() {
createCanvas(400, 400);
strokeWeight(10);
}
function draw() {
background(220);
for (let i = 0; i < height; i = i + 40) {
line(0, i, width, i);
}
}
let button = document.getElementById("button");
button.addEventListener("click", function () {
console.log("You Clicked Me!");
});
function that:
let stars = [];
let numStars = 100;
// Set up the canvas
function setup() {
createCanvas(600, 600);
// Create stars and add them to the array
for (let i = 0; i < numStars; i++) {
stars.push(new Star());
}
}
// Draw the stars
function draw() {
background(0);
// Update and display each star
for (let i = 0; i < numStars; i++) {
stars[i].update();
stars[i].display();
}
}
// Define the Star class
class Star {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(1, 5);
this.speed = random(1, 5);
this.color = color(random(255), random(255), random(255));
}
// Update the star's position
update() {
this.x += this.speed;
if (
fix invalid codeThu, 03 Aug 2023 ## See Also
- [Textlint Document](https://github.com/textlint/docs/blob/master/docs/rule/document.md)
- [textlint-rule-no-dead-link](https://github.com/textlint/textlint-rule-no-dead-link)
- [textlint-rule-no-mixed-zenkaku-and-hankaku-alphabet](https://github.com/textlint/textlint-rule-no-mixed-zenkaku-and-hankaku-alphabet)
- [textlint-rule-no-mix-dearu-desumasu](https://github.com/textlint/textlint-rule-no-mix-dearu-desumasu)
- [textlint-rule-no-todo](https://github.com/textlint/textlint-rule-no-todo)
- [textlint-rule-preset-JTF-style](https://github.com/textlint/
translateTue, 01 Aug 2023 void draw(){
//
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
<script>
// main.js
function setup() {
createCanvas(500, 500);
background(0);
}
function draw() {
background(0);
point(0, 0);
point(0, 500);
point(500, 0);
point(500, 500);
point(250, 250);
point(250, 50);
point(250, 450);
point(50, 250);
point(450, 250);
point(50, 50);
point(50, 450);
point(450, 50);
point(450, 450);
}
</script>

function setup() {
createCanvas(200, 200);
background(100);
button = createButton('click me');
button.position(19, 19);
button.mousePressed(changeBG);
}
function changeBG() {
var val = random(255);
background(val);
}
fix invalid codeThu, 03 Aug 2023 ## Usage
Pass a string of code and an options object to the `check` function.
SELECT * FROM customers WHERE age=24;
function makeBinaryStarSystem(){
var star1 = new Star(random(width/2), random(height/2), random(5,30));
var star2 = new Star(random(width/4), random(height/4), random(5,40));
star1.mouseOver(mouseX, mouseY);
star2.mouseOver(mouseX, mouseY);
star1.update();
star2.update();
star1.display();
star2.display();
}
The explanation for the code
// Define variables
let stars = [];
let numStars = 100;
// Set up the canvas
function setup() {
createCanvas(600, 600);
// Create stars and add them to the array
for (let i = 0; i < numStars; i++) {
stars.push(new Star());
}
}
// Draw the stars
function draw() {
background(0);
// Update and display each star
for (let i = 0; i < numStars; i++) {
stars[i].update();
stars[i].display();
}
}
// Define the Star class
class Star {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(1, 5);
this.speed = random(1, 5);
this.color = color(random(255), random(255), random(255));
}
// Update the star's position
update() {
this.x += this.speed
function draw() {
background(0);
// Update and display each star
for (let i = 0; i < numStars; i++) {
stars[i].update();
stars[i].display();
}
}
// Define the Star class
class Star {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(1, 5);
this.speed = random(1, 5);
this.color = color(random(255), random(255), random(255));
}
// Update the star's position
update() {
this.x += this.speed;
if (this.x > width) {
this.x = 0;
}
}
// Display the star on the canvas
display() {
fill(this.color);
noStroke();
ellipse(this.x, this.y, this.size, this.size);
}
}
<button>☀️</button>
<style>
button {
font-size: 2em;
background-color: #fcfcfc;
border: 2px solid #eee;
border-radius: 4px;
margin: 4px;
}
button:active {
transform: translate(0, 2px);
}
</style>
function setup() {
createCanvas(800, 400);
background(40);
}
function draw() {
background(40);
stroke(255);
strokeWeight(4);
// Center of mass
push();
translate(width / 2, height / 2);
fill(0);
ellipse(0, 0, 16, 16);
pop();
// Star
push();
translate(width / 2, height / 2);
noStroke();
fill(255, 128, 0);
ellipse(100, 0, 32, 32);
// Planet
fill(0, 127, 255);
ellipse(200, 0, 24, 24);
pop();
}
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
strokeWeight(2);
stroke(255);
fill(0);
ellipse(width/2, height/2, 50, 50);
ellipse(width/2 + 100, height/2, 50, 50);
strokeWeight(4);
line(width/2, height/2, width/2 + 100, height/2);
}
### A template for your code:
fix invalid codeThu, 03 Aug 2023 div.stars {
position: absolute;
top: 0;
left: 0;
background-image: url(stars.png);
background-size: cover;
background-repeat: repeat;
animation: move 10s linear infinite;
}
@keyframes move {
0% {
left: 0;
top: 0;
}
100% {
left: 100%;
top: 100%;
}
}
def make_button(text)
return "<button>#{text}</button>"
end
make_button("Click me")
function that: in javascript what does the ** mean?
fix invalid codeThu, 03 Aug 2023 ## task 3:
@keyframes click {
0% {
background-color: red;
transform: translate(0, 0);
}
100% {
background-color: purple;
transform: translate(0px, 20px);
}
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
for (var i = 10; i <= 390; i = i + 5) {
line(200, 10, i, 390);
}
}
<div class="container" id="main">hello world</div>
[Refactoring](https://en.wikipedia.org/wiki/Code_refactoring) - Improving code without changing its behavior
* Rename things
* Organize functions and variables
* Organize files and folders
* Split up files
* Add documentation
* Add comments
* Refactor code
### Variables
Variables are bits of memory that store values.
<h1>Let's play a game</h1>
<button class="btn" id="btn">Click me</button>
<span id="score">0</span>
<script>
const btn = document.querySelector('#btn');
const score = document.querySelector('#score');
btn.addEventListener('click', () => {
score.innerText ++
})
</script>
fix invalid codeThu, 03 Aug 2023 <span id="hack"></span>
function that:
<p>Core loop</p>
<ul>
<li>Clicking gains points</li>
<li>Points buy upgrades</li>
<li>Upgrades boost click power and coin/point gain</li>
<li>Players rebirth for multiplier bonus</li>
</ul>
<p>Upgrades</p>
<ul>
<li>Click power</li>
<li>Points per second</li>
<li>Coins per point</li>
<li>Autoclicker</li>
<li>Double point chance</li>
</ul>
<p>Systems</p>
<ul>
<li>Player levels</li>
<li>Talent tree</li>
<li>Clans</li>
<li>Daily rewards</li>
<li>Achievements</li>
<li>Quests</li>
<li>Crafting</li>
<li>Respec</li>
</ul>
<p>Unique mechanics</p>
<ul>
<li>Evolving click tool gains
#bird:active{
transform: rotate(15deg);
-moz-transform: rotate(15deg);
-o-transform: rotate(15deg);
-webkit-transform: rotate(15deg);
}
## Tech
* Html
* CSS
* Javascript
* Node.js
* Express
* MongoDB
## Installation
* Clone this repo
* Install the dependencies
* Start the server
* Open your browser with the port 3000
def binarySystem(num1, num2):
return 0.3 * num1 + 0.7 * num2
binarySystem(a, b)
let clicked = false;
button.addEventListener('click', function() {
clicked = !clicked;
if (clicked) {
button.style.animation = 'click 5s';
} else {
button.style.animation = '';
}
});
fix invalid codeThu, 03 Aug 2023 javascript
random = Math.random;
var s1 = createSprite(30, 200, 40, 40);
var s2 = createSprite(70, 200, 40, 40);
var s3 = createSprite(50, 180, 40, 40);
var s4 = createSprite(50, 220, 40, 40);
var stars = [];
stars.push(s1);
stars.push(s2);
stars.push(s3);
stars.push(s4);
function draw() {
background("black");
stroke("white");
noFill();
ellipse(s1.x, s1.y, s1.width, s1.height);
ellipse(s2.x, s2.y, s2.width, s2.height);
ellipse(s3.x, s3.y, s3.width, s3.height);
ellipse(s4.x, s4.y, s4.width, s4.height);
for (var i = 0; i < stars.length; i
$('#coins-value').text(totalCoins);
## Day 2
### HTML
HTML stands for "HyperText Markup Language". It is the language used to write text in webpages.
### Tags
A tag is a word between angle brackets, like `<p>` or `<div>`. Tags are the basic building blocks of HTML. Most tags have an opening tag, and a closing tag, with some text in between.
`<tag>Some text</tag>`
Tags can be nested, like this:
`<tag1><tag2>Some text</tag2></tag1>`
Some tags do not need to be closed, for example `<img>` and `<br>`.
HTML documents are made up of many tags, nested inside of one another.
### Attributes
Tags can also have attributes, which are added in the opening tag. Attributes are used to specify additional information about the tag.
`<tag attribute1="value1" attribute2="value2">Some text</tag>`
Attributes are used differently on different tags, and each tag can take different attributes.
### Comments
function setup() {
createCanvas(600, 600);
// Create stars and add them to the array
for (let i = 0; i < numStars; i++) {
stars.push(new Star());
}
}
// Draw the stars
function draw() {
background(0);
// Update and display each star
for (let i = 0; i < numStars; i++) {
stars[i].update();
stars[i].display();
}
}
// Define the Star class
class Star {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(1, 5);
this.speed = random(1, 5);
this.color = color(random(255), random(255), random(255));
}
// Update the star's position
update() {
this.x += this.speed;
if (this.x > width) {
this.x = 0;
}
translateTue, 01 Aug 2023 function setup() {
createCanvas(500, 500);
background(0);
}
function draw() {
background(0);
point(0, 0);
point(0, 500);
point(500, 0);
point(500, 500);
point(250, 250);
point(250, 50);
point(250, 450);
point(50, 250);
point(450, 250);
point(50, 50);
point(50, 450);
point(450, 50);
point(450, 450);
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
rect(10, 10, 100, 100);
rect(200, 10, 100, 100);
rect(10, 200, 100, 100);
rect(200, 200, 100, 100);
}