Skip to content

Commit

Permalink
added samples in readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
skramm committed Feb 9, 2025
1 parent 2cb7a17 commit 58a1542
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,39 @@ int main()
}
```

### News ###
### TRYME

Try the above snippet
[online here](https://godbolt.org/z/d9oqYs34f),
or on your own Debian-style Linux box:
```
$ sudo apt install build-essentials
$ wget https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp
$ wget https://raw.githubusercontent.com/skramm/homog2d/master/misc/tryme.cpp
$ g++ tryme.cpp
$ ./a.out
```
will print:
```
[7,8]
```

#### TRYME2:

A slightly more significant file is [available here](misc/tryme2.cpp), try this:

```
$ wget https://raw.githubusercontent.com/skramm/homog2d/master/misc/tryme2.cpp
$ g++ tryme2.cpp
$ ./a.out
```

It will generate this Svg file:

![tryme2](docs/tryme2.svg)


### News

- 2025-01-26: fresh 2.12 release, see https://github.com/skramm/homog2d/releases
- 2024-04-21: switch to C++17, enable runtime polymorphism using `std::variant`, [see here](docs/homog2d_manual.md#section_rtp)
Expand All @@ -53,7 +85,7 @@ int main()

(see [history](docs/homog2d_history.md) for more)

### Details ##
### Details

- Install: to install on your machine, copy file `homog2d.hpp` somewhere where your compiler can reach it, or `$ sudo make install` after cloning repo.
This will copy that file in `/usr/local/include`.
Expand Down
20 changes: 20 additions & 0 deletions docs/tryme2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions misc/homog2d.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
<Unit filename="test_files/single_file.cpp" />
<Unit filename="test_files/test_multiple.cpp" />
<Unit filename="test_files/ttmath_t1.cpp" />
<Unit filename="tryme.cpp" />
<Unit filename="tryme2.cpp" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
Expand Down
34 changes: 34 additions & 0 deletions misc/tryme2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#include "homog2d.hpp"
using namespace h2d;
using namespace h2d::img;

template<typename T1,typename T2>
void
drawPts( Image<SvgImage>& im, const T1& shape1, const T2& shape2 )//, Color col )
{
auto x = shape1.intersects(shape2);
if( x() )
draw( im, x.get() ); //, DrawParams().setColor(col) );
}

int main()
{
Image<SvgImage> im(300,250);

Line2d li( Point2d(30,50), Point2d(100,80) );
li.draw( im, DrawParams().setColor(0,0,250) );

FRect r( 40,30,200,180 );
auto r2 = Homogr(-5.*M_PI/180.) * r;
r2.draw( im, DrawParams().setColor(200,0,0) );

Circle cir( 162, 141, 65 );
cir.draw( im, DrawParams().setColor(0,250,0) );

drawPts( im, li, cir );
drawPts( im, li, r2 );
drawPts( im, r2, cir );

std::cout << im;
}

0 comments on commit 58a1542

Please sign in to comment.