Post Reply 
Image/ sketch in program
05-10-2023, 10:25 AM (This post was last modified: 05-10-2023 10:28 AM by Amer7.)
Post: #1
Image/ sketch in program
Hi,
Is there a simple way to include a image/ sketch in program.
Like before an input, or at the end so there is some kind of guidance when using a program?

Like If i can use plot, is there a way I could draw it in some basic program like CAD, Paint etc. and than use some pogram to translate the image to a plotting code?
Is there a way to plot 2D ( coodrinates x,y) -Points and than for it to show up?
Find all posts by this user
Quote this message in a reply
05-10-2023, 03:36 PM
Post: #2
RE: Image/ sketch in program
Yeah, you can load a png to screen with G0:=AFiles("img.png") as long as that files exists in the application files, you can save it there before hand or put it there in the connection kit.

Of course you can also plot and draw on the calculator, you really should familiarise yourself with teh graphics section of the latest manual available at: https://literature.hpcalc.org/items/322 - around page 637 onwards.
Quote:PIXON_P, PIXON
Syntax: PIXON([G], x, y [ ,color])
Syntax: PIXON_P([G], x, y [ ,color])
Sets the color of the pixel in graphic variable G with coordinates (x,y) to the entered color. G can be any of the graphics variables and is optional. The default is G0, the current graphic.
The optional color can be any hexadecimal integer entered in the form aaRRGGBB. This is an RGB color with the alpha channel in the high order byte. The alpha channel numbers can be any integer between 0 (opaque) and 255 (transparent). If no color is specified, the default black is used.
there are commands for lines, arcs, rectangles, triangles, and text to screen etc.

G0 is the current graphic screen, G1 upwards are temporary graphics screens and you can copy between all of them with BLIT_P.

Have a good read through the manual :-).
Find all posts by this user
Quote this message in a reply
05-15-2023, 10:34 AM (This post was last modified: 05-15-2023 06:12 PM by Amer7.)
Post: #3
RE: Image/ sketch in program
(05-10-2023 03:36 PM)matalog Wrote:  Yeah, you can load a png to screen with G0:=AFiles("img.png") as long as that files exists in the application files, you can save it there before hand or put it there in the connection kit.

Of course you can also plot and draw on the calculator, you really should familiarise yourself with teh graphics section of the latest manual available at: https://literature.hpcalc.org/items/322 - around page 637 onwards.
Quote:PIXON_P, PIXON
Syntax: PIXON([G], x, y [ ,color])
Syntax: PIXON_P([G], x, y [ ,color])
Sets the color of the pixel in graphic variable G with coordinates (x,y) to the entered color. G can be any of the graphics variables and is optional. The default is G0, the current graphic.
The optional color can be any hexadecimal integer entered in the form aaRRGGBB. This is an RGB color with the alpha channel in the high order byte. The alpha channel numbers can be any integer between 0 (opaque) and 255 (transparent). If no color is specified, the default black is used.
there are commands for lines, arcs, rectangles, triangles, and text to screen etc.

G0 is the current graphic screen, G1 upwards are temporary graphics screens and you can copy between all of them with BLIT_P.

Have a good read through the manual :-).

Thank you for your reply, I will test it!

EDIT:
This works for me but in home screen G0:=AFiles("img.png")

But when I make a program to calculate a few things, and then Print them out.
EA:
LOCAL xa,ya,xb,yb,xc,yc;
xa:=4124.123;
ya:=1234.12;
xb:=2345.123;
yb:=6678.123;
xc:=8886.123;
yc:=4444.444;

y:=a1+b1;
PRINT("y= "+y);

G0:=AFiles("Y.png")
- Where the Y.png is a picture of " y= a1+b1; to be shown after the print is done or before...

( I want to use the picture as a reference, like I have a program with 8 inputs, and few calculations, I want to have the sketch displayed so I could see what is input 1, input2....input 8....)
I dont want to waste time going in gallery app and looking at the picture.


And when I use pixon after Print like
LOCAL y;
y:=a1+b1;
PRINT("y= "+y);
PIXON(xa,ya);
PIXON(xb,yb);
PIXON(xc,yc);

Only PRINT show up, no point drawing.
Find all posts by this user
Quote this message in a reply
05-17-2023, 11:30 AM (This post was last modified: 05-17-2023 11:32 AM by Amer7.)
Post: #4
RE: Image/ sketch in program
I have to use
RECT(); --- This clears the screen making it blank like a white a4 papper
P_PIXON(x,y,color) ----- This draws the point
WAIT(-1); ----- this makes the sceen wait untill i press anything.

Now everything will be needed to be scaled down. Any ideas how to do it easy with number like 5-6 million, and make it self adapt ? Maybe while do?
Find all posts by this user
Quote this message in a reply
05-17-2023, 07:27 PM
Post: #5
RE: Image/ sketch in program
I'm not sure what you are asking or saying really.

It will definitely help to read the section of the manual that I suggested.

Another thing that the manual mentions is TEXTOUT_P() which will let you print text on top of the image, or just below it, so that the both things can be displayed at once.
Find all posts by this user
Quote this message in a reply
05-17-2023, 07:28 PM
Post: #6
RE: Image/ sketch in program
(05-17-2023 11:30 AM)Amer7 Wrote:  I have to use
RECT(); --- This clears the screen making it blank like a white a4 papper
P_PIXON(x,y,color) ----- This draws the point
WAIT(-1); ----- this makes the sceen wait untill i press anything.

Now everything will be needed to be scaled down. Any ideas how to do it easy with number like 5-6 million, and make it self adapt ? Maybe while do?

If you have a specific number of things you want to do just put them in some sort of loop. I would probably use a FOR NEXT loop if you know the number at the start.
Find all posts by this user
Quote this message in a reply
05-18-2023, 05:21 PM (This post was last modified: 05-18-2023 05:33 PM by Amer7.)
Post: #7
RE: Image/ sketch in program
(05-17-2023 07:27 PM)matalog Wrote:  I'm not sure what you are asking or saying really.

It will definitely help to read the section of the manual that I suggested.

Another thing that the manual mentions is TEXTOUT_P() which will let you print text on top of the image, or just below it, so that the both things can be displayed at once.

EXPORT tacka()
BEGIN
LOCAL xa,ya,xb,yb,xc,yc,red,green;
red:=RGB(255,0,0);


xa:=40.123; ---- POINT COORDINATES
ya:=120.12;
xb:=70.123;
yb:=142.123;
xc:=150.123;
yc:=200.444;

PRINT("yc="+yc); ----- PRINT OUT IN TERMINAL POINT COORDINATES
PRINT("xc="+xc);
WAIT(-1); ----- This will make terminal screen wait untill you press or move your finger on touch screen
RECT() ----- This will make all of your screen white background
PIXON_P(xb,yb,red); ----- This draws a point on the screen, in red color

/

PIXON_P(xc,yc,red);
WAIT(-1); ----- It will stay on the display( point drawing untill you press anything )
END;


Now whoever does geodesy he will know that most coordinates are six figures
meaning
y= 6 543 543,123m
x=4 523 456,124m

Hp prime cant draw this, it has reach of screen pixel size. Next would be to make a loop to autmatically divide the coordinates so they could fit the screen size.
like while y/10>320 repeat etc.


-My new question is. How can I make the pixel dimension thicker- Maybe draw a rectangle aroud it?
Is there some way i could automatically draw a line between two points?
The drawing in the end is a triangular network. Ie. triangle network with 4 points
Find all posts by this user
Quote this message in a reply
05-18-2023, 10:10 PM
Post: #8
RE: Image/ sketch in program
I can only refer you to the manual I have been mentioning and the pages I already mentioned, they cover all of the drawing things you can use on the HP Prime.

Pages 640 and 641 tell you how to draw lines between 2 points, and also how to draw rectangles (even rectangles with lines of different colour around them.

You can ues the LINE_P and RECT_P to do the things that you want.
Find all posts by this user
Quote this message in a reply
05-24-2023, 08:03 PM (This post was last modified: 05-24-2023 08:34 PM by Amer7.)
Post: #9
RE: Image/ sketch in program
(05-18-2023 10:10 PM)matalog Wrote:  I can only refer you to the manual I have been mentioning and the pages I already mentioned, they cover all of the drawing things you can use on the HP Prime.

Pages 640 and 641 tell you how to draw lines between 2 points, and also how to draw rectangles (even rectangles with lines of different colour around them.

You can ues the LINE_P and RECT_P to do the things that you want.

Hey I managed to write the code. With the pixels, and while do loop. The issue is I'm facing

   

This is x=10, and y=10;
The HP prime has coordinate beginning in top left corner 0,0
Is it possible to make it to be coordinate beginning 0,0 from lower left corner?
-I have to change the basis of coordinates- will try to find how
Code:
EXPORT tacka()
BEGIN
LOCAL xa,ya,xb,yb,xc,yc;
LOCAL yt,xt;



xa:=4500432.123;
ya:=6700220.120;
xb:=4521452.123;
yb:=6812223.223;
xc:=4900111.333;
yc:=6600444.444;
xt:=5233212.089;
yt:=6422666.666;

PRINT("yc="+yc);
PRINT("xc="+xc);
PRINT("ya="+ya);
PRINT("xa="+xa);
PRINT("yb="+yb);
PRINT("xb="+xb);
PRINT("yT="+yt);
PRINT("xT="+xt);

PRINT("_________________________");

WHILE xa>230 DO
xa:=xa/2;
END;

WHILE ya>300 DO
ya:=ya/2;
END;

WHILE xb>230 DO
xb:=xb/2;
END;

WHILE yb>300 DO
yb:=yb/2;
END;

WHILE xc>230 DO
xc:=xc/2;
END;
WHILE yc>300 DO
yc:=yc/2;
END;

WHILE xt>230 DO
xt:=xt/2;
END;
WHILE yt>300 DO
yt:=yt/2;
END;



PRINT("yc="+yc);
PRINT("xc="+xc);
PRINT("ya="+ya);
PRINT("xa="+xa);
PRINT("yb="+yb);
PRINT("xb="+xb);
PRINT("yT="+yt);
PRINT("xT="+xt);
WAIT(-1);
RECT();

//Tacka A
TEXTOUT_P("TACKA A",ya-10,xa-10,1,RGB(200,100,0));
RECT_P(ya,xa,ya+5,xa+5,RGB(225,100,0));
PIXON_P(ya,xa,RGB(225,100,0));

//TackaB
TEXTOUT_P("TACKA B",yb-10,xb-10,1,RGB(100,100,0));
RECT_P(yb,xb,yb+5,xb+5,RGB(100,100,0));
PIXON_P(yb,xb,RGB(100,100,0));
//TACKA C
TEXTOUT_P("TACKA C",yc-10,xc-10,1,RGB(0,100,0));
RECT_P(yc,xc,yc+5,xc+5,RGB(0,100,0));
PIXON_P(yc,xc,RGB(0,100,0));
//Tacka T
TEXTOUT_P("TACKA T",yt-10,xt-10,1,RGB(225,0,0));
RECT_P(yt,xt,yt+5,xt+5,RGB(225,0,0));
PIXON_P(yt,xt,RGB(225,0,0));
//Linije 

LINE_P(ya,xa,yb,xb,RGB(200,200,200));
LINE_P(ya,xa,yt,xt,RGB(225,0,0));
LINE_P(yt,xt,yc,xc,RGB(225,0,0));
LINE_P(yt,xt,yb,xb,RGB(200,200,200));
LINE_P(yc,xc,yb,xb,RGB(200,200,200));
WAIT(−1);

END;
Find all posts by this user
Quote this message in a reply
05-24-2023, 10:24 PM
Post: #10
RE: Image/ sketch in program
To flip the coordinate system upside down then make the Y coordinate 240-Y, that should start at the bottom Left, if You are putting text there, you may have to add the height of the text if the text position if at the top of the letters.
Find all posts by this user
Quote this message in a reply
05-25-2023, 11:18 AM (This post was last modified: 05-25-2023 11:34 AM by Amer7.)
Post: #11
RE: Image/ sketch in program
Thank you, It works.
This is program for Pothenot snellius - Problem used in Geodesy to calculate the coordinates of point T.

On the beginning you are asked to input coordinates of points A,M,B, and measured angle Alpha, Beta. Point A is determined going from unknown point T in clockwise direction A,M,B


[Image: attachment.php?aid=12152]

This is the result

[Image: attachment.php?aid=12153]

You can Use this data to test the program:
[Image: attachment.php?aid=12155]
Note: this is 47 deg- 43 min-13.8sec
Calculator set in Degrees mode

The code:
Code:

EXPORT Nazad2()
BEGIN
LOCAL Aa,Ab,ya,xa,yb,xb,Xt,Yt;
LOCAL xm,ym,da,db,Mi1,Kk2,Pp2;
LOCAL Tx,Ty;

INPUT({Aa,Ab,ya,xa,ym,xm,yb,xb},"U smjeru kazaljke na satu od nepoznate tacke", {"Alfa","Beta","ya","xa","ym","xm","yb","xb"});

// Duzine a=da i b=db
da:=SQRT((ya-ym)^2+(xa-xm)^2);
db:=SQRT((ym-yb)^2+(xm-xb)^2);

///Mikro tj Mi
Mi1:=atan((da*sin(Ab))/(db*sin(Aa)));

// Direkcioni sa A na M 
LOCAL y1,x1,n1;
y1:=ym-ya;
x1:=xm-xa;

CASE
  IF y1>0 AND x1>0 THEN n1:=ATAN(y1/x1) END;
  IF y1>0 AND x1<0 THEN n1:=ATAN(y1/x1)+180 END;
  IF y1<0 AND x1<0 THEN n1:=ATAN(y1/x1)+180 END;
  IF y1<0 AND x1>0 THEN n1:=ATAN(y1/x1)+360 END;

END;

// Direkcioni sa B na M 
LOCAL y2,x2,n2;
y2:=ym-yb;
x2:=xm-xb;

CASE
  IF y2>0 AND x2>0 THEN n2:=ATAN(y2/x2) END;
  IF y2>0 AND x2<0 THEN n2:=ATAN(y2/x2)+180 END;
  IF y2<0 AND x2<0 THEN n2:=ATAN(y2/x2)+180 END;
  IF y2<0 AND x2>0 THEN n2:=ATAN(y2/x2)+360 END;
END;

// Ugao delta 
LOCAL n3,n4,n5,n6,Dd1;

CASE
IF n1>180 THEN n3:=n1-180 END;
IF n1<180 THEN n3:=n1+180 END;
END;

CASE
IF n2>180 THEN n4:=n2-180 END;
IF n2<180 THEN n4:=n2+180 END;
END;

// Ugao delta Dd1
Dd1:=n3-n4;

// fi+ ksi=Ff1    fi - ksi=kk1
LOCAL Ff1,Kk1;
Ff1:= 180- ((Aa+Ab+Dd1)/2);
Kk1:=atan(tan(Ff1)*1/tan(Mi1+45));


// FI I KSI 
LOCAL Fi1,Ks1;

CASE 
IF Mi1>45 THEN Fi1:=Ff1-Kk1 END;
IF Mi1<45 THEN Fi1:=Ff1+Kk1 END;
END;

CASE
IF Mi1>45 THEN Ks1:=Ff1+Kk1 END;
IF Mi1<45 THEN Ks1:=Ff1-Kk1 END;
END;

LOCAL Fa,Fb;
Fa:=n1+Fi1;
Fb:=n2-Ks1;


Xt:=(xa*tan(Fa)-xb*tan(Fb)-ya+yb)/(tan(Fa)-tan(Fb));
Yt:=ya+(Xt-xa)*tan(Fa);

Tx:=ROUND(Xt,3);
Ty:=ROUND(Yt,3);

PRINT();
PRINT("X= "+Xt);
PRINT("Y= "+Yt);

PRINT("------UPUTSTVO--------");
PRINT("--------DIGITRON U STEPENE------");
PRINT("u smjeru kazaljke na satu od nepoznate Oznacit A(FI) M u sredini, desno B- ksi");

PRINT("da= "+da);
PRINT("db= "+db);
PRINT("Mikro= "+→HMS(Mi1));
PRINT("A na M= "+→HMS(n1));
PRINT("B na M= "+→HMS(n2));
PRINT("n3 = "+→HMS(n3));
PRINT("n4 = "+→HMS(n4));
PRINT("delta = "+→HMS(Dd1));
PRINT("fi + ksi  = "+→HMS(Fi1));
PRINT("fi - ksi  = "+→HMS(Kk1));
PRINT("fi   = "+→HMS(Fi1));
PRINT("ksi   = "+→HMS(Ks1));
PRINT("alfaA   = "+→HMS(Fa));
PRINT("alfaB   = "+→HMS(Fb));
PRINT("***-----REZULTAT----------****");
PRINT("X= "+Xt);
PRINT("Y= "+Yt);

///Resizing

WHILE xa>230 DO
xa:=xa/1/2;
END;

WHILE ya>300 DO
ya:=ya/1/2;
END;

WHILE xb>230 DO
xb:=xb/1/2;
END;

WHILE yb>300 DO
yb:=yb/1/2;
END;

WHILE xm>230 DO
xm:=xm/1/2;
END;
WHILE ym>300 DO
ym:=ym/1/2;
END;

WHILE Xt>230 DO
Xt:=Xt/1/2;
END;
WHILE Yt>300 DO
Yt:=Yt/1/2;
END;

WAIT(-1);
RECT();

//Tacka A
TEXTOUT_P("A",ya-10,240-xa-10,1,RGB(0,0,225));
RECT_P(ya,240-xa,ya+5,240-xa+5,RGB(0,0,225));
PIXON_P(ya,240-xa,RGB(0,0,225));

//TackaB
TEXTOUT_P("B",yb-10,240-xb-10,1,RGB(235,52,204));
RECT_P(yb,240-xb,yb+5,240-xb+5,RGB(235,52,204));
PIXON_P(yb,240-xb,RGB(235,52,204));
//TACKA M
TEXTOUT_P("M",ym-10,240-xm-10,1,RGB(0,225,0));
RECT_P(ym,240-xm,ym+5,240-xm+5,RGB(0,225,0));
PIXON_P(ym,240-xm,RGB(0,225,0));
//Tacka T
TEXTOUT_P("T",Yt-10,240-Xt-10,1,RGB(225,0,0));
RECT_P(Yt,240-Xt,Yt+5,240-Xt+5,RGB(225,0,0));
PIXON_P(Yt,240-Xt,RGB(225,0,0));
//koordinates
TEXTOUT_P("Yt="+Ty+"m Xt="+Tx+"m",2,240-10,1,RGB(225,0,0));


//Linije 
LINE_P(ya,240-xa,ym,240-xm,RGB(5,5,5));
LINE_P(ya,240-xa,Yt,240-Xt,RGB(5,5,5));
LINE_P(Yt,240-Xt,ym,240-xm,RGB(5,5,5));
LINE_P(Yt,240-Xt,yb,240-xb,RGB(5,5,5));
LINE_P(ym,240-xm,yb,240-xb,RGB(5,5,5));
WAIT(−1);


END;

@matalog I really appreciate the time you took to write the tips and commands. They were a lot of help!
Also thank to other users like road that helped me in the past with the variable inputs.


Attached File(s) Thumbnail(s)
           

.hpprgm  PresjekNazad1.hpprgm (Size: 7.85 KB / Downloads: 1)
Find all posts by this user
Quote this message in a reply
05-25-2023, 12:37 PM
Post: #12
RE: Image/ sketch in program
That looks good, well done.

If you add a pixel or 2 to the coordinates of the lines source and destination x+1,y+1 for example, you will end up in the centre of a 2x2 pixel box or big dot. If might leave it looking a bit better.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)