This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Material dialog we're creating | |
+----------------------+ | |
| Materials | | |
| __________________ | | |
|?(__________________)x| | |
|----------------------| | |
| /¨\ #| | |
|( ) Gold #| | |
| \_/ #| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const char* fillVertShader = | |
#ifdef NANOVG_GLES2 | |
"#version 100\n" | |
"precision highp float;\n" // CHANGED | |
#endif | |
"uniform vec2 viewSize;\n" | |
"attribute vec2 vertex;\n" | |
"attribute vec2 tcoord;\n" | |
"attribute vec4 color;\n" | |
"varying vec2 ftcoord;\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define mgArgs(...) mgmgArgs_(__VA_ARGS__, MG_NONE) | |
int mgArgs_(const char* text, ...); | |
int mgText_(const char* text, struct MGargs args); | |
// Can "cache" args for common operations, as well as merge them, or use inline. | |
int mgColor(float* r, float* g, float* b, float* a, struct MGargs args) | |
{ | |
struct MGargs labelArgs = mgArgs(mgFontSize(LABEL_SIZE), mgSpacing(LABEL_SPACING)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define foo(...) foo_(123, ##__VA_ARGS__, 0) | |
void foo_(int dummy, ...) | |
{ | |
unsigned int v; | |
va_list list; | |
printf("foo "); | |
va_start(list, dummy); | |
for (v = va_arg(list, unsigned int); v != 0; v = va_arg(list, unsigned int)) | |
printf("%d ", v); | |
va_end(list); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Anything with complex persistent UI state. | |
- collapsable tree view | |
- a sortable list view | |
- graph UI (movable nodes connected w/ wires) | |
- timeline UI (movable boxes constrained on rows) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Draws a graph using a triangle strip and simple gradient texture. | |
// Anti-aliasing may be off by a half a pixel. | |
// Works reasonable well with smooth as well as noisy data. | |
// The basic idea is that we draw the graph using a full height quad (or two triangles) | |
// per segment between two samples, and then we calculate texture coordinates | |
// so that 1px anti-aliasing gradient passes through the data points. The texture coordinate | |
// is calculated using the segment normal and one segment end point. | |
struct Point { | |
float x, y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void mmul(float* m, const float* a, const float* b) | |
{ | |
for (int r = 0; r < 4; r++) | |
for (int c = 0; c < 4; c++) | |
m[r*4+c] = a[r*4+0] * b[0*4+c] + a[r*4+1] * b[1*4+c] + a[r*4+2] * b[2*4+c] + a[r*4+3] * b[3*4+c]; | |
} | |
void midentity(float* m) | |
{ | |
for (int i = 0; i < 4; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
(0,0) | |
+.................. | |
: image : | |
: : | |
: +----+ : | |
: |rect| : | |
: +----+ : | |
: : | |
................... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright (c) 2013 Mikko Mononen [email protected] | |
// | |
// This software is provided 'as-is', without any express or implied | |
// warranty. In no event will the authors be held liable for any damages | |
// arising from the use of this software. | |
// Permission is granted to anyone to use this software for any purpose, | |
// including commercial applications, and to alter it and redistribute it | |
// freely, subject to the following restrictions: | |
// 1. The origin of this software must not be misrepresented; you must not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float evalCurve(float x, float tx, float ty, float sa, float sb) | |
{ | |
const float EPS = 1e-6f; | |
if (x < tx) { | |
return (ty * x) / (x + sa * (tx - x) + EPS); | |
} else { | |
return ((1-ty) * (x-1)) / ((1-x) - sb * (tx - x) + EPS) + 1.0f; | |
} | |
} |
OlderNewer