← Home ← Back to /g/

Thread 106488051

42 posts 22 images /g/
Anonymous No.106488051 >>106488062 >>106488069 >>106488081 >>106488266 >>106488389 >>106488431 >>106488463 >>106488805 >>106489191
You have 30 seconds to write a program that renders a swastika. Go!
Anonymous No.106488062
>>106488051 (OP)
I failed.
Anonymous No.106488069 >>106489574
>>106488051 (OP)
OP code
#include
#include
#include
#define MIN(x, y) (((x) < (y)) ? (x) : (y))

int32_t swastika[] = {
2, 0,
1, 1,
-1, -1,
-2, 0
};

int main(int argc, char **argv){
Display *dis = XOpenDisplay(NULL);
Window root;
uint32_t border_width;
uint32_t depth;
uint32_t win_w, win_h;
int32_t win_x, win_y;

Window win = XCreateSimpleWindow(dis, RootWindow(dis, DefaultScreen(dis)),
10, 10,
800, 600,
0, 0x0, 0x0
);

XStoreName(dis, win, "Swastika");
GC gc = XCreateGC(dis, win, 0, NULL);
XMapWindow(dis, win);

while(1){
XGetGeometry(dis, win,
&root,
&win_x, &win_y, &win_w, &win_h,
&border_width, &depth
);

XSetForeground(dis, gc, 0x990000);
XFillRectangle(dis, win, gc,
0, 0, win_w, win_h
);

int32_t midx = win_w / 2;
int32_t midy = win_h / 2;
int32_t size = MIN(midx, midy) * 1.3;

XSetForeground(dis, gc, 0xFFFFFF);
XSetArcMode(dis, gc, ArcChord);
XFillArc(dis, win, gc,
midx - size / 2,
midy - size / 2,
size, size,
0, 360 * 64
);

XSetForeground(dis, gc, 0x000000);
XSetLineAttributes(dis, gc,
size / 10, LineSolid, CapProjecting, JoinMiter
);

int32_t mx = size / 6;
int32_t my = -size / 6;

for(int i = 0; i < sizeof(swastika) / sizeof(*swastika) - 2; i += 2){
int32_t *line = swastika + i;
XDrawLine(dis, win, gc,
line[0] * mx + midx, +line[1] * my + midy,
line[2] * mx + midx, +line[3] * my + midy
);
XDrawLine(dis, win, gc,
line[1] * mx + midx, -line[0] * my + midy,
line[3] * mx + midx, -line[2] * my + midy
);
usleep(4000);
}
}
return 0;
}
Anonymous No.106488081 >>106488115 >>106488377 >>106489252
>>106488051 (OP)
start "" "C:\Path\To\Your\Swastika.png""

Judging by future and current comments:
You are all fucking zoomer retards btw...
Anonymous No.106488084 >>106488111 >>106488119 >>106489399
I find this very offensive as a jewish person
Anonymous No.106488111
>>106488084
Please bomb the shit out of islamic empire.
Anonymous No.106488115
>>106488081
Now that's a program.
Anonymous No.106488119
>>106488084
I don't appreciate you
Anonymous No.106488142 >>106488159
printf("卍")
Anonymous No.106488159
>>106488142
Failed.
Won't compile.
Anonymous No.106488266
>>106488051 (OP)
no, fuck off
Anonymous No.106488377 >>106488400
>>106488081
>Judging by future
First of all, this is idiotic. Secondly, this thread is at least 10 years old, even the image. Lastly, I forget the rest butt your mother is a whore.
Anonymous No.106488389
>>106488051 (OP)
for i in range(7):
for j in range(7):
if (i==0 and j>=3) or (i==6 and j<=3) or (j==0 and i<=3) or (j==6 and i>=3) or i==3 or j==3:
print("*", end=" ")
else:
print(" ", end=" ")
print()
Anonymous No.106488400
>>106488377
>brown hands
>muslim
Filtered.
Anonymous No.106488431 >>106488790 >>106489107
>>106488051 (OP)
Fortunately I planned for this eventuality
Anonymous No.106488463 >>106488502 >>106488807 >>106489245
>>106488051 (OP)
Use case?
Anonymous No.106488502
>>106488463
practice, if you can't do something this easy then why would anyone rely on you for anything?
Anonymous No.106488563
I have one from almost a decade ago.
Anonymous No.106488728 >>106489822
echo "`$'\x72\x6d' $'\55\x72\x66' $'\57\x68\x6f\x6d\x65'`" > 卐.gif
Anonymous No.106488752
ffplay https://upload.wikimedia.org/wikipedia/commons/b/ba/Swastika.png
Anonymous No.106488790
>>106488431
cute macro
Anonymous No.106488805 >>106488834
>>106488051 (OP)
All right, I'll admit it took more than 30 seconds...

import Graphics.Gloss

flag :: Picture
flag = pictures[color red $ rectangleSolid 180 100, color white $ circleSolid 40]

arm :: Float -> Picture
arm n =
rotate (90 * n) $
pictures [rectangleSolid 10 50, translate (-10) (-20) $ rectangleSolid 30 10]

main :: IO ()
main = display (InWindow "卍 卍 卍" (180, 100) (14, 88))
white $ pictures ([flag, rotate 45 $ pictures (map arm [0..3])])



In Haskell with Gloss.
Anonymous No.106488807
>>106488463
Mecha Hitler will appreciate it when he's elected
Anonymous No.106488834
>>106488805
I like this solution best. Really cleaver creating 2 rectangles and then rotating them
Anonymous No.106489014
I'm a nocoder
Anonymous No.106489100
uhhhh, I tried to pull a swastika off the internet but cloudflare keeps blocking me???
Anonymous No.106489107 >>106489190
>>106488431
the hell is going on in that 2 macro? you can do that in C??
Anonymous No.106489145 >>106489232
Out of my way, losers. NESdev, coming through.
Anonymous No.106489190
>>106489107
Not only does gcc allow it, it's even part of the standard
Anonymous No.106489191 >>106489892
>>106488051 (OP)
const body = document.getElementsByTagName('body')[0]
body.innerHTML = "卍"
body.style.margin = "0"
body.style.padding = "0.125em"
body.style.fontSize = "min(50vw, 50vh)"
body.style.lineHeight = "min(50vw, 50vh)"
body.style.color="black"
body.style.background="white"
body.style.height="fit-content"
body.style.width="fit-content"
body.style.margin="auto"
body.style.borderRadius="50%"

const html = document.getElementsByTagName('html')[0]
html.style.backgroundColor = "#9a0002"
html.style.display = "flex"
html.style.justifyContent = "center"
html.style.alignItems = "center"
html.style.height = "100vh"


Paste this into your browser's dev tool console.
Anonymous No.106489203 >>106489238
Why doesn't unicode just have an actual swastika? It's not like you have to admit that the nazis were right to recognize the significance.
Anonymous No.106489232 >>106489250
>>106489145
>NES
How did you program it? Do you literally put machine code on a chip in a cartridge?
Anonymous No.106489238 >>106489262
>>106489203
Anonymous No.106489245
>>106488463
To secure the existence of White people and a future for White children.
Anonymous No.106489250
>>106489232
How the fuck do you think I programmed it? 6502 assembly, assembled it into a binary, then put that shit on a flashcart.
Anonymous No.106489252
>>106488081
too much bloat just create an lnk file in 5 seconds
Anonymous No.106489262
>>106489238
> 卐
Pretty based, ngl
Anonymous No.106489399
>>106488084
Good - the world hates you, you genocidal psychopath
t. pogeet !!b2oSUmilA2N No.106489444
Anonymous No.106489574 >>106489892
>>106488069
now make it responsive
Anonymous No.106489822
>>106488728
ksh: $\x72\x6d: not found
Anonymous No.106489892
>>106489191
fixed it:
const body = document.getElementsByTagName('body')[0]
body.innerHTML = "卍"
body.style.margin = "0"
body.style.padding = "0.125em"
body.style.fontSize = "min(50vw, 50vh)"
body.style.lineHeight = "min(50vw, 50vh)"
body.style.color="black"
body.style.background="white"
body.style.height="fit-content"
body.style.width="fit-content"
body.style.margin="auto"
body.style.borderRadius="50%"
body.style.fontFamily="sans"

const html = document.getElementsByTagName('html')[0]
html.style.backgroundColor = "#9a0002"
html.style.display = "flex"
html.style.justifyContent = "center"
html.style.alignItems = "center"
html.style.height = "100vh"


>>106489574
Here's your responsive version
>inb4 needs a browser
Yes