Skip to content

Instantly share code, notes, and snippets.

import graph3;
size(10cm,0);
currentprojection=perspective(0,100,0);
real h_0 = 0.357;
real h_1 = 0.956;
real w_0 = 0.7;
real w_1 = 0.547;
real t_0 = 0.367;
@wduminy
wduminy / gist:6199987
Last active July 26, 2017 05:54
Shows how to make a cell in a JFace TableViewer look and act like a hyperlink
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
@wduminy
wduminy / gist:5894305
Created June 30, 2013 08:04
abstract heightmap
template <typename elemT, size_t m_columns, size_t n_rows >
class Heightmap {
public:
typedef std::array<elemT, n_rows * m_columns> container_t;
const container_t& elems() const {return _elems;}
container_t& elems() {return _elems;}
const elemT& operator() (size_t c, size_t r) const {
check_range(c,r); return _elems.at(r * n_rows + c);}
elemT& operator() (size_t c, size_t r) {
check_range(c,r);return _elems.at(r * n_rows + c);}
@wduminy
wduminy / gist:5859474
Last active March 14, 2024 05:17
Flips a surface in SDL
SDL_Surface* flip_vertical(SDL_Surface* sfc) {
SDL_Surface* result = SDL_CreateRGBSurface(sfc->flags, sfc->w, sfc->h,
sfc->format->BytesPerPixel * 8, sfc->format->Rmask, sfc->format->Gmask,
sfc->format->Bmask, sfc->format->Amask);
const auto pitch = sfc->pitch;
const auto pxlength = pitch*(sfc->h - 1);
auto pixels = static_cast<unsigned char*>(sfc->pixels) + pxlength;
auto rpixels = static_cast<unsigned char*>(result->pixels) ;
for(auto line = 0; line < sfc->h; ++line) {
memcpy(rpixels,pixels,pitch);