Drawing multicolor

13 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Drawing multicolor

Hello dudes,

i'm new to his forum. OS4coding seems really interesting.
I have only a little AOS coding experience, since in the past i left Amiga buy a PC (sigh). So i don't remember pratically nothing of my initial programming experience on Amiga. So forgive me for any strange and unexpected question.

First question:
Want to draw pixel randomly using a palette of 16M colors.
How can i realize this. I tried, but it's seems to me that colors are only few.
Moreover, it's possible to increase the line width when drawing?

Thank you very much

JosDuchIt
JosDuchIt's picture
Offline
Last seen: 8 years 6 days ago
Joined: 2012-01-08 20:57
Hi, AmigaBlitter, I don't

Hi, AmigaBlitter,

I don't think i can help you, but wellcome.
Maybe you should post your try to trigger more interesting answers

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
*BUMP*

*BUMP*

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
@AmigaBlitter I assume you

@AmigaBlitter

I assume you are already familiar with pen-based drawing using rastports?

Drawing using direct ARGB values on a high-/true-color screen is not that much different.

Only instead of the SetAPen(), SetBPen() and SetOutlinePen() functions you have the tags RPTAG_APenColor, RPTAG_BPenColor and RPTAG_OPenColor that can be used together with the SetRPAttrs() function to specify colors as 32-bit ARGB.

  1. void SetAPenRGB (struct RastPort *rp, uint8 red, uint8 green, uint8 blue) {
  2. SetRPAttrs(rp,
  3. RPTAG_APenColor, 0xff000000|((uint32)red << 16)|((uint32)green << 8)|((uint32)blue),
  4. TAG_END);
  5. }
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Thank you I will try.

Thank you
I will try.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
It works!

It works! (kinda)

IMAGE(http://imageshack.us/a/img22/3508/screenxj.png)

  1. x=0;
  2. for (i=0; i< 256*256*256; i++) {
  3. x++;
  4. uint r = i & 0xff;
  5. uint g = i >> 8 & 0xff;
  6. uint b = i >> 16 & 0xff;
  7.  
  8.  
  9. if (x>=1280) {
  10. x=0;
  11. y++;
  12. }
  13.  
  14. SetAPenRGB (MyWindow->RPort, r, g, b*i) ;
  15. WritePixel( MyWindow->RPort, x, y);
  16.  
  17. }

Does anyone knows a nice color wheel code or something to draw the colors spectrum in a good way?

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
Writing each pixel through a

Writing each pixel through a rastport is rather slow, isn't it.

It's better to write the RGB data into a buffer and then use WritePixelArray to draw it into the window in one go.

Here is an example: http://thomas-rapp.homepage.t-online.de/examples/colorwheel.c

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
@thomas WritePixelArray() is

@thomas

WritePixelArray() is a CGX function. On AmigaOS 4.x you should rather use p96WritePixelArray() or BltBitMapTags() with BLITA_SrcType set to BLITT_RGB24.

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
To be honest I don't care

To be honest I don't care much what OS4 dictates. My code can be compiled and run without changes for OS3, OS4, MorphOS and AROS. If I used P96 I would lock out 70% of the systems (MorphOS, AROS and OS3 with CGX gfx card).

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
The code gyve me many

The code gyve me many cybergraph errors. Maybe my setup is different from your setup.

If i want to use Reaction and Intuition, what is the actual fastest way to plot pixels?

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
@AmigaBlitter That's because

@AmigaBlitter

That's because the cgx header file is not included in the AmigaOS SDK (probably for legal reasons).

I've modified thomas' code so that it uses p96 calls when compiling for AmigaOS 4.x. You can get it here:

http://dl.dropbox.com/u/26599983/colorwheel.c

It should compile using just:
gcc -O2 -Wall -D__USE_INLINE__ -o colorwheel colorwheel.c -lauto

I also added a proto/graphics.h include directive which was missing from the code.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Thank you both for replying.

Thank you both for replying.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
it's quite fast. One note:

it's quite fast. One note: resizing the window cause some graphics glitches on the bottom line of the window as well as the left lefte edge, when i try to resize to fast.

Log in or register to post comments