Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #153929
| From | JohnF <John@F.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: terminal graphics using braille characters |
| Date | 2020-08-23 03:32 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <rhso0k$8n7$1@reader1.panix.com> (permalink) |
| References | <cb09d2a4-9ca3-4827-81b4-f7bcfd0e9b35o@googlegroups.com> |
luser droog <luser.droog@gmail.com> wrote:
> https://codereview.stackexchange.com/questions/248021/
> text-based-rendering-animation-engine-for-the-terminal
Very cute. But I give up... where does "766F6964" come from?
And here's a 31-line terminal animation of stored functions...
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* --- entry point --- */
void asciigraph ( double *f, int n ) {
int row=0,nrows=24, col=0,ncols=78;
double bigf=0.0;
for ( col=0; col<n; col++ )
if ( fabs(f[col]) > bigf ) bigf = fabs(f[col]);
for ( row=0; row<nrows; row++ ) {
double yval = bigf*((double)(nrows/2-row))/((double)(nrows/2));
for ( col=0; col<ncols; col++ )
printf("%c",(yval*f[(col*(n-1))/(ncols-1)]>=yval*yval? '*':' '));
printf("\n"); }
} /* --- end-of-function asciigraph() --- */
#ifdef TESTDRIVE
int main ( int argc, char *argv[] ) {
double f[999], pi=3.14159; /* stored function to be graphed */
double t=0.0, dt=0.05, w1=16.,w2=3.; int Nt=50;
int i=0, N=511; /* f[] index */
void asciigraph();
while ( --Nt > 0 ) {
for ( i=0; i<N; i++ ) {
double x = 2.0*pi*((double)i)/((double)(N-1));
f[i] = .75*sin(2.*x+pi/3.+w1*t) + 1.*sin(1.*x+pi/2.+w2*t); }
system("sleep 0.25; clear");
asciigraph(f,N);
t += dt; }
} /* --- end-of-function main() --- */
#endif
--
JohnF ( mailto: j@f.com where j=john and f=forkosh )
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
terminal graphics using braille characters luser droog <luser.droog@gmail.com> - 2020-08-22 17:41 -0700
Re: terminal graphics using braille characters JohnF <John@F.com> - 2020-08-23 03:32 +0000
Re: terminal graphics using braille characters Eli the Bearded <*@eli.users.panix.com> - 2020-08-23 06:52 +0000
Re: terminal graphics using braille characters "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-08-23 01:58 -0700
Re: terminal graphics using braille characters John Forkosh <forkosh@panix.com> - 2020-08-24 06:10 +0000
Re: terminal graphics using braille characters luser droog <luser.droog@gmail.com> - 2020-08-23 00:07 -0700
Re: terminal graphics using braille characters Öö Tiib <ootiib@hot.ee> - 2020-08-23 01:35 -0700
Re: terminal graphics using braille characters John Forkosh <forkosh@panix.com> - 2020-08-24 06:26 +0000
Re: terminal graphics using braille characters luser droog <luser.droog@gmail.com> - 2020-08-23 23:59 -0700
Re: terminal graphics using braille characters John Forkosh <forkosh@panix.com> - 2020-08-24 09:58 +0000
csiph-web