Deutsch   English   Français   Italiano  
<6523746156b3a0a3905a94f90ddb06f4ca6d7949.camel@gmail.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wij <wyniijj5@gmail.com>
Newsgroups: comp.lang.c++
Subject: Re: 'Graphics' of libwy
Date: Fri, 20 Dec 2024 11:10:30 +0800
Organization: A noiseless patient Spider
Lines: 108
Message-ID: <6523746156b3a0a3905a94f90ddb06f4ca6d7949.camel@gmail.com>
References: <4ffeda4ce7116f70754bcfcaee87cb729081fac3.camel@gmail.com>
		<vjqhau$1ceif$1@dont-email.me> <vjs2do$1p3ce$1@dont-email.me>
		<vjs7a7$1qa1n$1@dont-email.me> <vjs8uq$1qgh4$1@dont-email.me>
		<vjsaa3$1qrhs$1@dont-email.me> <vjtvvk$2787g$1@dont-email.me>
		<vju3t1$27s6m$1@dont-email.me>	<87cyho7l0y.fsf@nosuchdomain.example.com>
		<949627852d304fe2c28e4b02e1c2c8f1b92dcf02.camel@gmail.com>
		<875xngxv69.fsf@nosuchdomain.example.com>
		<46376a6ea82da504381a6431a4f21014d9a30a3f.camel@gmail.com>
		<871py4xq9y.fsf@nosuchdomain.example.com>
		<s_idnQttB9Q9Jfn6nZ2dnZfqnPednZ2d@giganews.com>
		<87wmfvw4aq.fsf@nosuchdomain.example.com>
	 <87seqjw1ee.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Date: Fri, 20 Dec 2024 04:10:32 +0100 (CET)
Injection-Info: dont-email.me; posting-host="331fdfa5841a78dd2e4c437ccab44d30";
	logging-data="3299738"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+kWcEoz021nGgJjJoFgZ4W"
User-Agent: Evolution 3.54.2 (3.54.2-1.fc41)
Cancel-Lock: sha1:tmZrzlSUtqUm9XxFKihA68/zqWc=
In-Reply-To: <87seqjw1ee.fsf@nosuchdomain.example.com>

On Thu, 2024-12-19 at 18:09 -0800, Keith Thompson wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> > Ross Finlayson <ross.a.finlayson@gmail.com> writes:
> > > On 12/18/2024 08:14 PM, Keith Thompson wrote:
> > > > wij <wyniijj5@gmail.com> writes:
> [...]
> > > > > But, what is the true thing the program is dealing with? What is =
'pixel'?
> > > >=20
> > > > Do you really not know what a pixel is?
> [...]
> > > Pixel =3D "picture element"
> >=20
> > You do know what a pixel is.=C2=A0 So why did you ask?
>=20
> My apologies, I didn't pay enough attention to the attribution lines.
> wij write "What is 'pixel'"; Ross wrote 'Pixel =3D "picture element"'.

class Pixel { /* Whatever suitable */ };
=20
int main() {=20
 Array2D<Pixel> img;=20

 load_picture(img, "mydog.jpg");
 draw_circle(img, cx,cy, dim);

 // cout.set_graphics_mode(...);  // if necessary =20
 // for(ssize_t y=3Dimg.height()-1; y>=3D0; --y) {
 //  cout << StrSeg(&img(0,y), img.width()) << WY_ENDL;=20
 // }

 cout << img;  // the about can be simplified to one line
};

'Pixel' is just something you can write into Array2D

---------- a_rawkey.cpp
#include <Wy.stdio.h>
#include <Wy.string.h>

using namespace Wy;

int main(int, char* [])
try {
 const char usage[]=3D"Type arrow keys (Up,Down,Left,Down) to move around, =
'ESC' to exit." WY_ENDL;
 Errno r;

 cout << usage;
 constexpr WeeStr KeyESC("\33");
 constexpr WeeStr KeyUp("\33[A");
 constexpr WeeStr KeyDown("\33[B");
 constexpr WeeStr KeyRight("\33[C");
 constexpr WeeStr KeyLeft("\33[D");

 constexpr WeeStr CursorUp("\33[1A");
 constexpr WeeStr CursorDown("\33[1B");
 constexpr WeeStr CursorRight("\33[1C");
 constexpr WeeStr CursorLeft("\33[1D");

 WeeStr stroke;
 for(;;) {
   if((r=3D_get_rawkey(cin,stroke))!=3DOk) {
     WY_THROW(r);
   }
   if(stroke=3D=3DKeyESC) {
     break;
   }

   if(stroke=3D=3DKeyUp) {
     cout << CursorUp;
   } else if(stroke=3D=3DKeyLeft) {
     cout << CursorLeft;
   } else if(stroke=3D=3DKeyDown) {
     cout << CursorDown;
   } else if(stroke=3D=3DKeyRight) {
     cout << CursorRight;
   } else {};
 }
 return 0;
}
catch(const Errno& e) {
 cerr << wrd(e) << WY_ENDL;
 return e.c_errno();
}
catch(...) {
 cerr << "main caught(...)" WY_ENDL;
 throw;
};  =20
------------

If the key code from raw mode tty is defined (maybe, but I don't know),=C2=
=A0
I think C++ writing vi like editor should be much simpler, no need for ncur=
ses.
If back to 'graphics', Pixel can be CSI sequence in this case.

My purpose is a 'C++ graphics'. No need to consider various kinds of=C2=A0
graphics accelerators or 'GUI', which cannot be standardized and would be
wrong goal.

What I now trying to experiment is separating graphics things to another=C2=
=A0
process. By doing so, 'the C++ code' just plays with Array2D<Pixel>, no nee=
d=C2=A0
to include those (mostly) heavy graphics library.