Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:50 19 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : IMAGE ROTATE

     Page 2 of 4    
Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 02:29pm 08 Jan 2021
Copy link to clipboard 
Print this post

Sorry Peter, I made the STUPID mistake of not deleting the .option

After deleting the .option and doing option lcdpanel hdmi again
All seems to be working apart from BLIT and Triangles
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8607
Posted: 02:35pm 08 Jan 2021
Copy link to clipboard 
Print this post

BLIT works - did you run my rotate program?

The things that aren't working for me are the EDIT and NANO command which just lock up.

TRIANGLE is a trivial bug - will fix when I work out what is happening to the editors
Edited 2021-01-09 00:46 by matherp
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 02:52pm 08 Jan 2021
Copy link to clipboard 
Print this post

Which rotate program?
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 02:56pm 08 Jan 2021
Copy link to clipboard 
Print this post

Found the program sorry missed that
Yes that does work
but it doesn't work with the other program I attached
Possibly 2 different things
I'll try the compass program listed earlier
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8607
Posted: 03:09pm 08 Jan 2021
Copy link to clipboard 
Print this post

The BLIT WRITE syntax is wrong - omit width and height

Try the attached


mmbasic.zip
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 04:35pm 08 Jan 2021
Copy link to clipboard 
Print this post

That one makes it worse I'm afraid
your shear code works beautifully
The compass code you had before doesn't work even when removing the image
Edited 2021-01-09 02:36 by lew247
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8607
Posted: 04:40pm 08 Jan 2021
Copy link to clipboard 
Print this post

  Quote  The compass code you had before doesn't work even when removing the image


I'm not psychic - a link?
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 04:44pm 08 Jan 2021
Copy link to clipboard 
Print this post

  lew247 said  
Code used and image attached
Code.zip
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8607
Posted: 05:50pm 08 Jan 2021
Copy link to clipboard 
Print this post

Try the attached


mmbasic.zip


NOTE BLIT WRITE NOW ONLY HAS THREE PARAMETERS

  Quote  BLIT WRITE [#]n, x, y


This also has working IMAGE ROTATE and IMAGE RESIZE commands - see the CMM2 manual for details but ignore the optional pagenumber parameter
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 06:15pm 08 Jan 2021
Copy link to clipboard 
Print this post

Peter you're a genius
I really wish there was some way to show my gratitude
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 06:47pm 08 Jan 2021
Copy link to clipboard 
Print this post



If you used a little red filled-in circle the image would be easier to rotate (ha!) and would convey the same information.
Micromites and Maximites! - Beginning Maximite
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 06:52pm 08 Jan 2021
Copy link to clipboard 
Print this post

  yock1960 said  
I worked on that code quite a bit more after that...it was like an 'ear worm'!  
Here it is, in a little demo, but contains a standalone 'compass' subroutine. Basically, I had to use trig functions for everything.
Steve
Compass.zip


Steve

If you see this post, have you any idea why I'm getting the black triangles around the intermediate directions?
I've quite possible made an error when adapting your code.
There's also a "spare" blue rectangle in the top left corner, not sure if that's related to the code or not, it doesn't appear when I run the weather code that doesn't have the image rotate section in it
I made it yellow so it's easier to see the artifacts, and it's an up close shot of the screen





This is the modified section of your code I'm using

option explicit
color RGB(WHITE),RGB(YELLOW)
CLS
dim cx% = 130             ' off by 15 due to how rotate image works (or something)
dim cy% = 160             ' ditto
dim wid% = 100             ' radius
dim ang! = 0.087266463    '5 degrees in radians
dim rad90! = 1.570796327  '90 degrees in radians
dim x%
compass_rose 350,350,175

sub compass_rose cx%,cy%,wid%
 local a%
' cardinal directions  
 text cx%+9,cy%+15-(wid%+22),"N",L,2,,RGB(BLACK),RGB(YELLOW)
 text cx%+9,cy%+15+(wid%+5),"S",L,2,,RGB(BLACK),RGB(YELLOW)
 text cx%+wid%+18,cy%+4,"E",L,2,,RGB(BLACK),RGB(YELLOW)
 text cx%-(wid%+5),cy%+4,"W",L,2,,RGB(BLACK),RGB(YELLOW)
' intermediate directions
 text 10,10,"NE",L,7,,RGB(WHITE),RGB(YELLOW)
 image rotate 6,4,30,30,cx%+(wid%-16)*cos(.785),cy%-(wid%-16)*cos(.785),45,0
 text 10,10,"SE",L,7,,RGB(WHITE),RGB(YELLOW)
 image rotate 6,4,30,30,cx%+(wid%-16)*cos(.785),cy%+(wid%-16)*cos(.785),135,0
 text 10,10,"SW",L,7,,RGB(WHITE),RGB(YELLOW)
 image rotate 6,4,30,30,cx%-(wid%-16)*cos(.785),cy%+(wid%-16)*cos(.785),225,0
 text 10,10,"NW",L,7,,RGB(WHITE),RGB(BLUE)
 image rotate 6,4,29,29,cx%-(wid%-16)*cos(.785),cy%-(wid%-16)*cos(.785),315,0
 ' tick marks, every 5 degrees (360/5 = 72)
 for a% = 0 to 71
   line (cx%+15)+(cos(a%*ang!)*(wid%-4)),(cy%+15)-(sin(a%*ang!)*(wid%-4)),(cx%+15)+(cos(a%*ang!)*(wid%+1)),(cy%+15)-(sin(a%*ang!)*(wid%+1)),,RGB(WHITE)
 next
' compass perimiter
 circle cx%+15,cy%+15,wid%
 circle cx%+15,cy%+15,wid%-4

' pointers to intermediate directions (not sure why I need 1 to 8 here!, besides bad math :-) )
 for a% = 1 to 8
   triangle cx%+15-sin(9*a%*ang!)*wid%*.5,cy%+15-cos(9*a%*ang!)*wid%*.5,cx%+15+cos(9*a%*ang!)*wid%*.07,cy%+15-sin(9*a%*ang!)*wid%*.07,cx%+15-cos(9*a%*ang!)*wid%*.07,cy%+15+sin(9*a%*ang!)*wid%*.07,RGB(WHITE),RGB(WHITE)
 next
 line cx%+15-sin(9*a%*ang!)*wid%*.5,cy%+15-cos(9*a%*ang!)*wid%*.5,cx%+15+sin(9*a%*ang!)*wid%*.5,cy%+15+cos(9*a%*ang!)*wid%*.5,,RGB(BLACK)
 line cx%+15-sin(9*a%*ang!)*wid%*.5,cy%+15+cos(9*a%*ang!)*wid%*.5,cx%+15+sin(9*a%*ang!)*wid%*.5,cy%+15-cos(9*a%*ang!)*wid%*.5,,RGB(BLACK)

' pointers to cardinal directions
 for a% = 0 to 3
   triangle cx%+15-sin(a%*rad90!)*(wid%+2),cy%+15-cos(a%*rad90!)*(wid%+2),cx%+15+cos(a%*rad90!)*wid%*.11,cy%+15+sin(a%*rad90)*wid%*.11,cx%+15-cos(a%*rad90!)*wid%*.11,cy%+15-sin(a%*rad90!)*wid%*.11,RGB(RED),RGB(RED)
 next
 line cx%+15,cy%+15+wid%*.99,cx%+15,cy%+15-wid%*.99,,RGB(BLACK)
 line cx%+15-wid%*.99,cy%+15,cx%+15+wid%*.99,cy%+15,,RGB(BLACK)
 circle cx%+15,cy%+16,wid%*.18,,,RGB(BLACK),RGB(GREEN)
 circle cx%+15,cy%+16,wid%*.13,,,RGB(BLUE),RGB(BLUE)
 circle cx%+15,cy%+16,wid%*.04,,,RGB(YELLOW),RGB(YELLOW)
end sub


Edited 2021-01-09 05:03 by lew247
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:39pm 08 Jan 2021
Copy link to clipboard 
Print this post

What's the background color when those texts are printed? Image rotate copies those pixels, but then they are rotated and those black portions are they underlying background (I think). Play around with the colors. Peter added a flag, which is in my code, but not yours (the 1 at the end), to not copy black pixels. Perhaps that's not available in your 'super special' version of MMBASIC. You can try IMAGE ROTATE_FAST, which did have the option, but the text quality after rotation is a bit less.

Steve
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:00am 09 Jan 2021
Copy link to clipboard 
Print this post

The background colour is CLS RGB(42,117,198)
I can't figure out why it's doing it to be honest
and when I update the colours so it's the right ones it becomes this


I've made a set of images with the intermediate directions rotated to the correct angles on them
I don't suppose you know a formula to work out where to place them on the screen in the correct place without doing it by trial and error?
cx% = 785
cy% = 238
wid% = 105
ang! = 0.087266463
rad90! = 1.570796327  '90 degrees in radians

I'd like to place the intermediate directions outside the compass as in the cardinal directions, and then possibly place the next intermediates (nnw etc) inside the compass
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:06am 09 Jan 2021
Copy link to clipboard 
Print this post

Peter:
Have you any idea why this happens?

The image rotate when it's redrawn always uses the colours located around 10,10
If I use any other location to write the text as in the examples below I get this

As you can see I tried using 540,110 to do the text so it got the background from there but  as you can see it doesn't work

Also the black corners I can't remove
Any suggestions?



 text 540,110,"NE",L,7,,RGB(BLACK),RGB(134,174,230)
 image rotate 6,4,30,30,cx%+(wid%-16)*cos(.785),cy%-(wid%-16)*cos(.785),45
 text 10,10,"SE",L,7,,RGB(BLACK),RGB(134,174,230)
 image rotate 6,4,30,30,cx%+(wid%-16)*cos(.785),cy%+(wid%-16)*cos(.785),135
 text 540,110,"SW",L,7,,RGB(BLACK),RGB(134,174,230)
 image rotate 6,4,30,30,cx%-(wid%-16)*cos(.785),cy%+(wid%-16)*cos(.785),225
 text 540,110,"NW",L,7,,RGB(BLACK),RGB(134,174,230)
 image rotate 6,4,29,29,cx%-(wid%-16)*cos(.785),cy%-(wid%-16)*cos(.785),315
 text 540,110,"  ",L,7,,RGB(BLACK),RGB(134,174,230) ' clear text


EDIT:
The reason it's getting the grey is because I have a box in the top panel
BOX 0,0,mm.hres,mm.vres/16,1,RGB(WHITE),RGB(162, 160, 160 )' top panel
Edited 2021-01-09 21:34 by lew247
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8607
Posted: 11:12am 10 Jan 2021
Copy link to clipboard 
Print this post

Try the attached - note the use of the dontcopyblack parameter and non-black text to get rid of the rotation artefacts

Option explicit
CLS RGB(134,174,230)
Dim cx% = 785
Dim cy% = 238
Dim wid% = 105
Dim ang! = 0.087266463
Dim rad90! = 1.570796327  '90 degrees in radians

compass_rose 625,475,75

Sub compass_rose cx%,cy%,wid%
Local a%
Text cx%+9,cy%+15-(wid%+22),"N",L,4,,RGB(1,1,1),RGB(134,174,230)
Text cx%+9,cy%+15+(wid%+5),"S",L,4,,RGB(1,1,1),RGB(134,174,230)
Text cx%+wid%+18,cy%+4,"E",L,4,,RGB(1,1,1),RGB(134,174,230)
Text cx%-(wid%+5),cy%+4,"W",L,4,,RGB(1,1,1),RGB(134,174,230)
Text 10,10,"NE",L,7,,RGB(1,1,1),RGB(134,174,230)
Image rotate 6,4,30,30,cx%+(wid%-16)*Cos(.785),cy%-(wid%-16)*Cos(.785),45,1
Text 10,10,"SE",L,7,,RGB(1,1,1),RGB(134,174,230)
Image rotate 6,4,30,30,cx%+(wid%-16)*Cos(.785),cy%+(wid%-16)*Cos(.785),135,1
Text 10,10,"SW",L,7,,RGB(1,1,1),RGB(134,174,230)
Image rotate 6,4,30,30,cx%-(wid%-16)*Cos(.785),cy%+(wid%-16)*Cos(.785),225,1
Text 10,10,"NW",L,7,,RGB(1,1,1),RGB(134,174,230)
Image rotate 6,4,29,29,cx%-(wid%-16)*Cos(.785),cy%-(wid%-16)*Cos(.785),315,1
Text 10,10,"  ",L,7,,RGB(134,174,230),RGB(134,174,230) ' clear text
' tick marks, every 5 degrees (360/5 = 72)
For a% = 0 To 71
  Line (cx%+15)+(Cos(a%*ang!)*(wid%-4)),(cy%+15)-(Sin(a%*ang!)*(wid%-4)),(cx%+15)+(Cos(a%*ang!)*(wid%+1)),(cy%+15)-(Sin(a%*ang!)*(wid%+1)),,RGB(WHITE)
Next
' compass perimiter
Circle cx%+15,cy%+15,wid%
Circle cx%+15,cy%+15,wid%-4
End Sub

 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 11:29am 10 Jan 2021
Copy link to clipboard 
Print this post

This is the result, much better but still the triangle artifacts

 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8607
Posted: 12:00pm 10 Jan 2021
Copy link to clipboard 
Print this post

  Quote  This is the result, much better but still the triangle artifacts


Not for me - did you try my code exactly as posted on the latest version of mmbasic attached below

mmbasic.zip
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 12:11pm 10 Jan 2021
Copy link to clipboard 
Print this post

peter you're a real genious  
Loaded that version and it works perfectly
thank you so much
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 12:23pm 10 Jan 2021
Copy link to clipboard 
Print this post

Sorry I spoke too soon
Once I incorporated it into my code it's still picking up the colour from 10,10
I tried using 540,110 hoping that it would pick up that blue shade but it still uses 10,10 but with no written text nw,ne etc

 
     Page 2 of 4    
Print this page
© JAQ Software 2024