mirror of
https://github.com/m4rcel-lol/m5rcode.git
synced 2025-12-06 19:13:57 +05:30
Update test.m5r
This commit is contained in:
committed by
GitHub
parent
d7a30f1321
commit
c8f8161c6d
105
files/test.m5r
105
files/test.m5r
@@ -1,54 +1,81 @@
|
||||
<?py
|
||||
# M5RCode Python Block: OBFUSCATED - 3D Hello World + Floating Rotating 3D Square
|
||||
# M5RCode Python Block: OBFUSCATED - True 3D Floating Cube & Hello World
|
||||
|
||||
import tkinter as _tk
|
||||
import math as _m
|
||||
import time as _t
|
||||
|
||||
class _T:
|
||||
_WW=700
|
||||
_WH=400
|
||||
|
||||
class _3D:
|
||||
def __init__(self):
|
||||
self._rt=_tk.Tk()
|
||||
self._rt.title(''.join([chr(c) for c in [51,68,32,84,101,115,116]])) # 3D Test
|
||||
self._cv=_tk.Canvas(self._rt,width=420,height=260,bg='#181c22',highlightthickness=0)
|
||||
self._rt.title(''.join([chr(c) for c in [84,104,114,101,101,68,32,84,101,115,116]])) # ThreeD Test
|
||||
self._cv=_tk.Canvas(self._rt,width=_WW,height=_WH,bg='#181c22',highlightthickness=0)
|
||||
self._cv.pack()
|
||||
self._ang=0
|
||||
self._t=0
|
||||
self._A=0.0
|
||||
self._B=0.0
|
||||
self._t=0.0
|
||||
self._run()
|
||||
self._rt.mainloop()
|
||||
|
||||
def _pr(self, x,y,z):
|
||||
# Perspective projection
|
||||
d = 400
|
||||
zz = z+220
|
||||
return (
|
||||
_WW//2 + int(d * x / (zz+1)),
|
||||
_WH//2 + int(d * y / (zz+1))
|
||||
)
|
||||
|
||||
def _run(self):
|
||||
self._cv.delete('all')
|
||||
# Draw "3D" shadowed Hello World text
|
||||
_s="".join([chr(c) for c in [72,101,108,108,111,32,119,111,114,108,100]])
|
||||
for _i in range(15,0,-3):
|
||||
self._cv.create_text(212+_i,90+_i,fill=f"#2a2a5{9-_i//3}",font=('Consolas',42,'bold'),text=_s)
|
||||
self._cv.create_text(212,90,fill="#ffe257",font=('Consolas',42,'bold'),text=_s)
|
||||
# Rotating & bouncing 3D square (pseudo-perspective)
|
||||
_a=self._ang
|
||||
_Y=130+_m.sin(self._t)*24
|
||||
_sz=70
|
||||
_pts=[]
|
||||
for _dx,_dy in [(-1,-1),(1,-1),(1,1),(-1,1)]:
|
||||
# 3D cube points, rotate a bit in Y, project to 2D
|
||||
_x=_dx*_sz*_m.cos(_a)
|
||||
_y=_dy*_sz*0.67
|
||||
_z=_dx*_sz*_m.sin(_a)
|
||||
_X=_x+_z*0.45
|
||||
_pts.append((212+_X,_Y+_y-_z*0.29))
|
||||
# Draw top face for 3D effect
|
||||
self._cv.create_polygon([_pts[i] for i in [0,1,2,3]],fill="#00ffae",outline="#222",width=3)
|
||||
# Draw floating shadow
|
||||
self._cv.create_oval(212-45,(_Y+_sz*1.03)+10,212+45,(_Y+_sz*1.24)+20,fill="#000",outline="")
|
||||
# Draw outline with depth
|
||||
for _offs in range(1,8):
|
||||
_offp=[(_x,_y+_offs*2) for _x,_y in _pts]
|
||||
self._cv.create_polygon(_offp,outline="#161413",fill="",width=1)
|
||||
# Animate: spin & up-down
|
||||
self._ang+=0.12
|
||||
self._t+=0.1
|
||||
self._rt.after(28,self._run)
|
||||
# "3D" hello
|
||||
_s = ''.join([chr(c) for c in [72,101,108,108,111,32,119,111,114,108,100]])
|
||||
for _i in range(17,0,-3):
|
||||
self._cv.create_text(_WW//2+_i,_WH//4+_i,fill=f"#3e238{9-_i//3}",font=('Consolas',62,'bold'),text=_s)
|
||||
self._cv.create_text(_WW//2,_WH//4,fill="#ffe257",font=('Consolas',62,'bold'),text=_s)
|
||||
|
||||
_T()
|
||||
# Draw ground
|
||||
self._cv.create_oval(_WW//2-180,_WH//2+112,_WW//2+185,_WH//2+145,fill="#5800aa",outline="#380075")
|
||||
|
||||
# Cube vertices (3D)
|
||||
_sz=75
|
||||
_F=_m.sin(self._t)*45
|
||||
_verts=[ # 8 points of a cube
|
||||
[-1,-1,-1], [1,-1,-1], [1,1,-1], [-1,1,-1],
|
||||
[-1,-1,1], [1,-1,1], [1,1,1], [-1,1,1]
|
||||
]
|
||||
# 3D rotation and translation
|
||||
_P=[]
|
||||
for v in _verts:
|
||||
x,y,z=v
|
||||
# rotate around Y (self._A), X(self._B)
|
||||
x2=x*_m.cos(self._A)-z*_m.sin(self._A)
|
||||
z2=x*_m.sin(self._A)+z*_m.cos(self._A)
|
||||
y2=y*_m.cos(self._B)-z2*_m.sin(self._B)
|
||||
z3=y*_m.sin(self._B)+z2*_m.cos(self._B)
|
||||
_P.append(self._pr(x2*_sz, y2*_sz+_F, z3*_sz+110))
|
||||
# Cube edges
|
||||
_edges=[(0,1),(1,2),(2,3),(3,0),(4,5),(5,6),(6,7),(7,4),
|
||||
(0,4),(1,5),(2,6),(3,7)]
|
||||
# Draw cube faces (as filled polygons for 3D solid look)
|
||||
_faces=[(0,1,2,3),(4,5,6,7),(0,1,5,4),(2,3,7,6),(0,3,7,4),(1,2,6,5)]
|
||||
_colf=["#66ffee","#f2a2fa","#00eedc","#39dabf","#bfeaff","#ccfcfc"]
|
||||
for ii,f in enumerate(_faces):
|
||||
pts=[_P[i] for i in f]
|
||||
self._cv.create_polygon(pts,fill=_colf[ii],outline="#3c3c57",width=2,stipple='gray25')
|
||||
# Draw all edges (to make it look "wireframe-3d")
|
||||
for a,b in _edges:
|
||||
self._cv.create_line(*_P[a],*_P[b],fill="#231f39",width=3)
|
||||
self._cv.create_line(*_P[a],*_P[b],fill="#aff",width=1)
|
||||
# Animate
|
||||
self._A+=0.09
|
||||
self._B+=0.055
|
||||
self._t+=0.07
|
||||
self._rt.after(24,self._run)
|
||||
|
||||
_3D()
|
||||
?>
|
||||
<?js
|
||||
(function(){
|
||||
@@ -63,7 +90,6 @@ ${a}=array(72,101,108,108,111,32,119,111,114,108,100);
|
||||
echo implode(array_map('chr',${a})) . "\n";
|
||||
?>
|
||||
<?cs
|
||||
// M5RCode C# Block: OBFUSCATED, illustrative
|
||||
using System;
|
||||
class S{
|
||||
static void Main(){
|
||||
@@ -72,7 +98,6 @@ class S{
|
||||
}
|
||||
?>
|
||||
<?cpp
|
||||
// M5RCode C++ Block: OBFUSCATED, illustrative
|
||||
#include <iostream>
|
||||
int main() {
|
||||
int arr[] = {72,101,108,108,111,32,119,111,114,108,100};
|
||||
@@ -82,5 +107,5 @@ int main() {
|
||||
}
|
||||
?>
|
||||
<?css
|
||||
body { color: #ffe257; background: #1a1c1f; }
|
||||
body { color: #ffe257; background: #181c22; }
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user