Click here to Skip to main content
15,880,956 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: The urge to sing "The lion sleeps tonight"... Pin
RickZeeland18-Apr-21 2:05
mveRickZeeland18-Apr-21 2:05 
GeneralRe: The urge to sing "The lion sleeps tonight"... Pin
Gary R. Wheeler18-Apr-21 3:45
Gary R. Wheeler18-Apr-21 3:45 
GeneralRe: The urge to sing "The lion sleeps tonight"... Pin
Sander Rossel18-Apr-21 4:20
professionalSander Rossel18-Apr-21 4:20 
GeneralRe: The urge to sing "The lion sleeps tonight"... Pin
Choroid19-Apr-21 6:37
Choroid19-Apr-21 6:37 
GeneralRe: The urge to sing "The lion sleeps tonight"... Pin
W Balboos, GHB18-Apr-21 6:22
W Balboos, GHB18-Apr-21 6:22 
GeneralRe: The urge to sing "The lion sleeps tonight"... Pin
Slow Eddie19-Apr-21 2:15
professionalSlow Eddie19-Apr-21 2:15 
GeneralRe: The urge to sing "The lion sleeps tonight"... Pin
Chris Maunder18-Apr-21 10:17
cofounderChris Maunder18-Apr-21 10:17 
GeneralI'm having way too much fun testing this code Pin
honey the codewitch17-Apr-21 13:02
mvahoney the codewitch17-Apr-21 13:02 
I'm building the drawing portions of my graphics library finally - the bit that lets you draw things like filled rectangles, ellipses and lines.

The library supports *any* pixel format as long as the pixel is less than or equal to 64 bits. You define what it looks like yourself.

But.

I have yet to build a "driver" portion that allows it to interface with some real display hardware.

So I've been using the library to draw lines and circles and stuff all over bitmaps, and then I'm rendering those bitmaps to "4 bit grayscale" ASCII art and rendering that to the console.

I didn't think making ascii bitmaps would be this much fun though. It's silly how much I'm enjoying "drawing" on the console screen.

This is one of those rare moments when testing made itself fun for me. I need more of these. Thumbs Up | :thumbsup:

Edit: Here's a result - the size is necessary because ASCII - it's only 128x128 "pixels" minus a few rows i cropped:
C++
template <typename BitmapType>
void dump_bitmap(const BitmapType& bmp) {
    static const char *col_table = " .,-~;*+!=1%O@$#";
    using gsc4 = pixel<channel_traits<channel_name::L,4>>;
    for(int y = 0;y<bmp.dimensions().height;++y) {
        for(int x = 0;x<bmp.dimensions().width;++x) {
            const typename BitmapType::pixel_type px = bmp[point16(x,y)];
            char sz[2];
            sz[1]=0;
            const auto px2 = px.template convert<gsc4>();
            size_t i =px2.template channel<0>();
            sz[0] = col_table[i];
            printf("%s",sz);
            
        }
        printf("\r\n");
    }
}
int main() {
    static const size_t bit_depth = 24;
    
    // our type definitions
    using bmp_type = bitmap<rgb_pixel<bit_depth>>;
    using draw = draw<bmp_type>;
    using color = color<typename bmp_type::pixel_type>;
    
    // declare the bitmap
    size16 bmp_size(128,128);
    uint8_t bmp_buf[bmp_type::sizeof_buffer(bmp_size)];
    bmp_type bmp(bmp_size,bmp_buf);

    // draw stuff
    bmp.clear(bmp.bounds()); // comment this out and check out the uninitialized RAM. It looks neat.
    srect16 b =srect16(spoint16(0,0),ssize16(bmp.dimensions().width,bmp.dimensions().height));
    srect16 cr = b.inflate(-50,-50);
    draw::filled_ellipse(bmp,cr,color::lawn_green);
    draw::ellipse(bmp,cr,color::lavender_blush);
    srect16 r = b.inflate(-4,0);
    srect16 r2=r.inflate(-r.width()*.30,-r.height()*.30);
    auto fr2 = r2.inflate(15,5);
    draw::filled_rectangle(bmp,fr2,color::purple);
    draw::rectangle(bmp,fr2,color::hot_pink);
    draw::line(bmp,r,color::white,&r2);
    draw::line(bmp,r.flip_horizontal(),color::white);
    
    dump_bitmap(bmp);
    return 0;
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                                    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                       #                          
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                       #                          
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                      #                           
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                     #                            
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                    #                             
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                   #                              
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                  #                               
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                 #                                
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$                #                                 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$               #                                  
%%%%%%%%%%%%%%%%%%%%%%%%%===================================================================#==========                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-----------------------------------------------------------------#----------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=----------------------------------------------------------------#-----------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=---------------------------------------------------------------#------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=--------------------------------------------------------------#-------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=--------------#----------------------------------------------#--------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=---------------#--------------------------------------------#---------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=----------------#-------------------------------------------#---------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-----------------#-----------------------------------------#----------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=------------------#---------------------------------------#-----------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-------------------#-------------------------------------#------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=--------------------#-----------------------------------#-------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=--------------------#----------------------------------#--------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=---------------------#--------------------------------#---------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=----------------------#------------------------------#----------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-----------------------#----------------------------#-----------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=------------------------#--------------------------#------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-------------------------#------------------------#-------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=--------------------------#----------------------#--------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=---------------------------#--------------------#---------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=----------------------------#------------------#----------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-----------------------------#----------------#-----------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=------------------------------#--------------#------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-------------------------------#-------------#------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=--------------------------------#-----------#-------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=--------------------------------#----------#--------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=---------------------------------#--------#---------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=----------------------------------#------#----------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-----------------------------------#----#-----------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=------------------------------------#--#------------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-------------------------------------##-------------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-------------------------------------##-------------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=------------------------------------#--#------------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=-----------------------------------#----#-----------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=----------------------------------#------#----------------------------------=                         
%%%%%%%%%%%%%%%%%%%%%%%%%=---------------------------------#--------#---------------------------------=                         
$%%%%%%%%%%%%%%%%%%%%%%%%=--------------------------------#----------#--------------------------------=                         
 $$%%%%%%%%%%%%%%%%%%%%%%=-------------------------------#-----------#--------------------------------=                         
   $$%%%%%%%%%%%%%%%%%%%%=------------------------------#-------------#-------------------------------=                         
     $$%%%%%%%%%%%%%%%%%%=------------------------------#--------------#------------------------------=                         
       $$%%%%%%%%%%%%%%%%=-----------------------------#----------------#-----------------------------=                         
         $$$%%%%%%%%%%%%%=----------------------------#------------------#----------------------------=                         
            $$$%%%%%%%%%%=---------------------------#--------------------#---------------------------=                         
               $$$$$%%%%%=--------------------------#----------------------#--------------------------=                         
                    $$$$$=-------------------------#------------------------#-------------------------=                         
                         =------------------------#--------------------------#------------------------=                         
                         =-----------------------#----------------------------#-----------------------=                         
                         =----------------------#------------------------------#----------------------=                         
                         =---------------------#--------------------------------#---------------------=                         
                         =--------------------#----------------------------------#--------------------=                         
                         =-------------------#-----------------------------------#--------------------=                         
                         =------------------#-------------------------------------#-------------------=                         
                         =-----------------#---------------------------------------#------------------=                         
                         =----------------#-----------------------------------------#-----------------=                         
                         =---------------#-------------------------------------------#----------------=                         
                         =---------------#--------------------------------------------#---------------=                         
                         =--------------#----------------------------------------------#--------------=                         
                         =-------------#--------------------------------------------------------------=                         
                         =------------#---------------------------------------------------------------=                         
                         =-----------#----------------------------------------------------------------=                         
                         =----------#-----------------------------------------------------------------=                         
                         ==========#===================================================================                         
                                  #                                                                                             
                                 #                                                                                              
                                #                                  

Real programmers use butterflies


modified 18-Apr-21 2:07am.

GeneralRe: I'm having way too much fun testing this code Pin
Gary R. Wheeler18-Apr-21 3:57
Gary R. Wheeler18-Apr-21 3:57 
GeneralLadies and Gentlemen of the jury, This Cat is an innocent ... Pin
BillWoodruff17-Apr-21 10:14
professionalBillWoodruff17-Apr-21 10:14 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
Greg Utas17-Apr-21 10:42
professionalGreg Utas17-Apr-21 10:42 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
OriginalGriff17-Apr-21 11:09
mveOriginalGriff17-Apr-21 11:09 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
pkfox17-Apr-21 11:13
professionalpkfox17-Apr-21 11:13 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
BillWoodruff17-Apr-21 22:56
professionalBillWoodruff17-Apr-21 22:56 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
pkfox18-Apr-21 1:36
professionalpkfox18-Apr-21 1:36 
AnswerRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
Eddy Vluggen17-Apr-21 13:04
professionalEddy Vluggen17-Apr-21 13:04 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
Daniel Pfeffer17-Apr-21 21:07
professionalDaniel Pfeffer17-Apr-21 21:07 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
Sander Rossel17-Apr-21 23:15
professionalSander Rossel17-Apr-21 23:15 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
Gary R. Wheeler18-Apr-21 4:10
Gary R. Wheeler18-Apr-21 4:10 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
BillWoodruff18-Apr-21 5:37
professionalBillWoodruff18-Apr-21 5:37 
GeneralRe: Ladies and Gentlemen of the jury, This Cat is an innocent ... Pin
peterkmx18-Apr-21 6:14
professionalpeterkmx18-Apr-21 6:14 
GeneralI'd just to thank the person who signed my email address ... Pin
OriginalGriff17-Apr-21 8:54
mveOriginalGriff17-Apr-21 8:54 
GeneralRe: I'd just to thank the person who signed my email address ... Pin
Daniel Pfeffer17-Apr-21 9:13
professionalDaniel Pfeffer17-Apr-21 9:13 
GeneralRe: I'd just to thank the person who signed my email address ... Pin
Slacker00717-Apr-21 9:32
professionalSlacker00717-Apr-21 9:32 
GeneralRe: I'd just to thank the person who signed my email address ... Pin
Eddy Vluggen17-Apr-21 9:21
professionalEddy Vluggen17-Apr-21 9:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.