It is currently Sat May 27, 2017 11:42 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Transparent Colors?
Unread postPosted: Fri Apr 28, 2017 8:56 am 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 94
RSA, thats what i was looking for.

I dug into GIMP last night just before bed.
It has growed!
I didnt figure it out in 10 minutes so i shut down for the night.
Right now im on the train with only my tablet (ie brain dead).
So ill check your trick out when i get home.

Thanks all...

Richard


Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Fri Apr 28, 2017 8:10 pm 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 94
mjcoon wrote:
cavelamb wrote:
Playing around with it, alpha looks more like "saturation" than transparency.

Why do you say that? I associate the term "saturation" with use of deeper colours, such as might be obtained by exaggerating the proportion of the strongest colour in each pixel. The opposite of pastel.

Mike.



Because it was a simple RGB file.

Now it's an RGBA file...

We didn't have RGBA files way back when.
We just had RGB files - and we liked 'em.

Transparency back then was doen by designating the "transparent" color and
simply skipping pixels of that color when BLTing a picture to the video frame.
Might even be how RGBA is done (under the hood).
But I doubt it. That wouldn't allow for semitransparent. colors...
Those would havbe to be mixed on the fly.

RGB file was about 302KB
RGBA is 7kb?

Neat trick...

PS: don't put it on a black background! :) )


Attachments:
DIAL320-Dial-GX.PNG
DIAL320-Dial-GX.PNG [ 6.3 KiB | Viewed 382 times ]
Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Sat Apr 29, 2017 10:29 am 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 94
Eddie Likes!

Thanks for the new toy, RSA.


RSA wrote:
Cavelamb wrote:
The green parts of the dial should be transparent.

Gilles wrote:
In keeping with what emile tells you the code is actually quite simple...

Emile wrote:
The png image is not transparent if it was not created that way.
Paint.Net can be used to convert any image to an transparent png image.

Download Paint.Net it is free.
Select the "Green" with the "MagicWand" and "Delete"
The deleted green sections will be transperent 8-)
Also download Gilles's version at the link he supplied.

Emile


Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Sun Apr 30, 2017 10:09 am 
Offline

Joined: Sat Dec 22, 2012 2:32 pm
Posts: 830
The problem is that we can't manipulate the "alpha" channel of a bitmap with the current command-set. This prevents a direct "die-cutting" of transparent areas into a BMP ("masking")
But since we got the GR.FILL command, we can do indirect: a "maiden" BMP always has a=r=g=b=0, so as long we don't touch the desired areas, we can use the initial alpha=0 status to achieve the desired "mask" (see example below)

regards, brochi

Code:
GR.OPEN
GR.ORIENTATION 1
PAUSE     1000

r1      = 200
r2      = 160
r3      = 32
r4      = 65
dphi    = 27
phiOffs = 0
nCirc   = 10

GR.COLOR             255, 0,0,255,1
GR.CIRCLE            nn, 2*r1, 2*r1,r1 : GR.RENDER : PAUSE 500


GR.BITMAP.CREATE     bmp, 2*r1, 2*r1
GR.ROTATE.START      0, 30+r1,30+r1, rot
GR.BITMAP.DRAW       nn, bmp, 30,30
GR.ROTATE.END

GR.BITMAP.DRAWINTO.START bmp
GR.COLOR             255,0,0,0,0
GR.CIRCLE            nn,  r1,r1,r1    : GR.RENDER : PAUSE 500
FOR i             =  0   TO nCirc-1
phi              =  TORADIANS( phiOffs + i*dphi)
GR.CIRCLE           nn , r1+r2*SIN(phi), r1-r2*COS(phi),r3
GR.RENDER : PAUSE 200
NEXT
GR.CIRCLE            nn,  r1,r1,r4    : GR.RENDER : PAUSE 500
GR.BITMAP.FILL       bmp, r1,r1+r4+1  : GR.RENDER : PAUSE 500
GR.BITMAP.DRAWINTO.END



phi               =  0
DO
GR.MODIFY           rot, "angle", ++phi : GR.RENDER : PAUSE 10
UNTIL                forever


Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Sun Apr 30, 2017 2:38 pm 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 94
I had a chance to fool around with it some last night and a couple of hours today after church.

It's not what I want as a finished product.
But this is my learning project...
I'm very new to this kind of coding!

Version 4.2
What I did was generate the dial artwork using PaintNet.
(and thanks for the new toy! It will take a while to get comfortable with it, but I love a complex program that
can get usable output from the start.)

That means 11 files of the dial; one in each position.
I'm embarrassed that it took me too long to figure out the filename formatting.
Dangling zeros still confuse me.

A little bit of off center rotation comes from cropping
the dial pics by hand. They would be perfectly centered
if they could be assembled by BASIC! code.

Building the dial images:
Starts with the background screen of the blank dial - the numbers.
Next, the dial (with transparent parts) is added as a layer.
Finally, the finger stop is added as a layer and the image saved.

So the obvious next question is - how to build the images on-the-fly in BASIC! code?
I sorta suspect that means GR.GROUPing each image.
But I haven't had a chance to study up on that.

Anyway, it's growing....




Code:
!Dial4-2.bas     % This program is learn about graphics animation
!
GR.OPEN 255, 255, 255, 255        % white screen  Alpha = 0
GR.color ,,0                       % sets GREEN to 0
GR.ORIENTATION 0                % force landscape mode
GR.SCREEN Scr_Wide,Scr_High
CX = int(Scr_Wide/2)
CY  = int(Scr_High/2)
bm_High = 320  : bm_High2 = 160
bm_Wide = 360  : bm_Wide2 = 160
!
GR.TEXT.DRAW text1, bm_high+100, bm_wide, "Loading"
! load 11 screen frames into annimation array
DIM aa_dial[20]                 % This animation will use 11 frames!
for Num = 1 to 11 
  LET fn$ = "F-" + Right$("0"+int$(num-1),2) +".png"
  GR.BITMAP.LOAD bm0, FN$
  GR.BITMAP.DRAW aa_dial[num], bm0, CX - bm_Wide2 , CY - bm_high2
  GR.HIDE aa_dial[num]
NEXT Num
% Top of the animation loop
Do   
  for digit = 1 to 11
     Steps = Digit   
    FOR index = 1 TO Steps     
      GR.SHOW aa_dial[index]
      GR.RENDER
      PAUSE 100
      IF INDEX < steps-1 THEN GR.HIDE aa_dial[index]
     NEXT index    %
    pause 500    
! Rotate back the other way
   FOR index = Steps  TO 1 STEP -1  % OTHER WAY
     GR.SHOW aa_dial[index]    
     GR.RENDER
     PAUSE 50                          % returns faster
     IF INDEX > -1 THEN GR.HIDE aa_dial[index]   
   NEXT index   
    Pause 500
  Next Digit 
  Until 0

  ! ONERROR:
!   Print "tOtAl ElEcTrIc fOoBaR"   
   END


Attachments:
Dial4-2.zip [437.4 KiB]
Downloaded 6 times
Dial4.zip [436.56 KiB]
Downloaded 5 times
Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Mon May 01, 2017 4:56 am 
Offline
User avatar

Joined: Sat Oct 04, 2014 5:45 am
Posts: 642
Cavelamb wrote:
It's not what I want as a finished product.
But this is my learning project...
I'm very new to this kind of coding!

I suspect you did not download/run/compile Gilles's or Brochi's code, then you would have seen how to.
However I strongly suggest to study Brochi's example code. It is perfect for what you want to do.

Screenshot of Brochi's example
Image

_________________
Download and tutorial for RFODESIGNER
https://sites.google.com/site/rfodesigner/


Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Mon May 01, 2017 5:31 am 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 94
Nope. I didn't. I wrote my own.
Is that okay?

Did you look at MINE?
It's one page of code and it rotates the dial just fine.
I thought I'd move on to incorporating the user input and be done with it...

Brochi's routine is cool. But I didn't write it. He did.

V 4.2 -
Updated art (from CAD)
Cleaned up the code.


Attachments:
Dial4-2.zip [1007.54 KiB]
Downloaded 9 times
Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Mon May 01, 2017 5:43 am 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 94
Brochi?
Fascinating.
That answers the question of how to create the image on the fly.
Now?
Any way to speed up the rotation?
Even without the short pause it's too slow for this application.

Or can that image be rotated 30 degrees and stuffed into an array (as my approach did)?
How to transfer the image to a named object?


Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Mon May 01, 2017 12:59 pm 
Offline
User avatar

Joined: Sat Oct 04, 2014 5:45 am
Posts: 642
Cavelamb wrote:
Any way to speed up the rotation?
Even without the short pause it's too slow for this application.

In Brochi's code below can you try to increment "phi" by 2 or 3 instead of by 1. It could double or triple the speed ;)
I am sure he only slowed it for demonstration purposes.
Code:
GR.MODIFY  rot, "angle", ++phi : GR.RENDER : PAUSE 10

_________________
Download and tutorial for RFODESIGNER
https://sites.google.com/site/rfodesigner/


Report this post
Top
 Profile  
 
 Post subject: Re: Transparent Colors?
Unread postPosted: Tue May 02, 2017 11:38 am 
Offline
User avatar

Joined: Sat Mar 26, 2016 9:23 am
Posts: 94
That works.

So now... Brochi?
May I use your suggestion in my code?
And how to give proper credit?

Richard


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2, 3  Next


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred