"Fossies" - the Fresh Open Source Software Archive

Member "mapgenerator-1.1.2/src/ocircle.cpp" (26 Oct 2003, 2037 Bytes) of package /linux/www/old/mapgenerator-1.1.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ocircle.cpp" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2                           ocircle.cpp  -  description
    3                              -------------------
    4     begin                : Mon Aug 13 2001
    5     copyright            : (C) 2001 by Gabriel Huber
    6     email                : Gabriel-Huber@gmx.de
    7  ***************************************************************************/
    8 
    9 /***************************************************************************
   10  *                                                                         *
   11  *   This program is free software; you can redistribute it and/or modify  *
   12  *   it under the terms of the GNU General Public License as published by  *
   13  *   the Free Software Foundation; either version 2 of the License, or     *
   14  *   (at your option) any later version.                                   *
   15  *                                                                         *
   16  ***************************************************************************/
   17 
   18 #include "ocircle.h"
   19 
   20 oCircle::oCircle(int x,int y,int r,const std::string & alt, const std::string &oth):Objects(alt,oth){
   21     cx=x;
   22     cy=y;
   23     cr=r;
   24 }
   25 
   26 oCircle::~oCircle(){
   27 }
   28 
   29 void oCircle::draw(int xpos,int ypos){
   30     Objects::draw();
   31     fl_circle(cx-xpos,cy-ypos,cr);
   32     fl_circle(cx-xpos,cy-ypos,2);
   33     fl_circle(cx+cr-xpos,cy-ypos,2);
   34     fl_color(white_line);
   35     fl_circle(cx-xpos,cy-ypos,cr+1);
   36     fl_circle(cx-xpos,cy-ypos,1);
   37     fl_circle(cx+cr-xpos,cy-ypos,1);
   38 }
   39 
   40 void oCircle::add_size(int x,int y){
   41     int vx=abs(cx-x);
   42     int vy=abs(cy-y);
   43     cr=(int)abs((int)(sqrt(pow(vx,2)+pow(vy,2))));
   44 }
   45 
   46 int oCircle::select(int x,int y){
   47     int vx=abs(cx-x);
   48     int vy=abs(cy-y);
   49     int vlen=(int)abs((int)(sqrt(pow(vx,2)+pow(vy,2))));
   50     if(vlen<=cr || vlen<=3)
   51         return 1;
   52     return 0;
   53 }
   54 
   55 void oCircle::save(htmlfile *html){
   56     html->sav_circle(URL,cx,cy,cr,alt_text,oth_atr);
   57 }
   58 
   59 void oCircle::move(int x,int y){
   60     cx=x;
   61     cy=y;
   62 }
   63 
   64 void oCircle::resize(int x,int y){
   65     int vx=abs(cx-x);
   66     int vy=abs(cy-y);
   67     cr=(int)abs((int)(sqrt(pow(vx,2)+pow(vy,2))));
   68 }