Created
April 5, 2020 11:37
-
-
Save shikarunochi/ee12a005cbcbd74de124fe673cc45f9e to your computer and use it in GitHub Desktop.
帽子のグラフ表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//移植元はこちらです。 | |
//https://twitter.com/yanatoku/status/1043501621030703104 | |
//https://twitter.com/Stosstruppe/status/1245682316325740545 | |
//https://twitter.com/Stosstruppe/status/1246383338635407365 | |
#include <M5Stack.h> | |
int dt[256], db[256]; | |
void setup(void) { | |
M5.begin(); | |
M5.Lcd.fillScreen(BLACK); | |
for (int l = 0; l < 256; l++) { | |
dt[l] = 192; | |
db[l] = -1; | |
} | |
for (int y = -180; y <= 180; y = y + 4) { | |
for (int x = -180; x <= 180; x = x + 4) { | |
double r = 3.14 / 180 * sqrt(x * x + y * y); | |
double z = 100 * cos(r) - 30 * cos(3 * r); | |
int sx = (int)(128 + x / 2 - y / 4); | |
int sy = (int)(80 - y / 4 - z / 2); | |
boolean ps = false; | |
if(sx < 0|| sx > 255){ | |
continue; | |
} | |
if (dt[sx] > sy) { | |
dt[sx] = sy; | |
ps = true; | |
} | |
if (db[sx] < sy) { | |
db[sx] = sy; | |
ps = true; | |
} | |
if (ps == true) { | |
M5.Lcd.drawPixel(sx + 30, sy + 20, TFT_GREEN); | |
} | |
} | |
} | |
} | |
void loop(void) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment