Shiny orb
What could it be?
This commit is contained in:
parent
1c3c3494f6
commit
299272b7aa
@ -4,10 +4,17 @@
|
|||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "easyx.h"
|
#include "easyx.h"
|
||||||
#include "util/tree.h"
|
#include "util/tree.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "render_util.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <graphics.h>
|
#include <graphics.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
TimePoint since = time_Now();
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
|
||||||
@ -30,5 +37,14 @@ void app_Render(App *app) {
|
|||||||
(int)round(box.lefttop.y + box.size.y));
|
(int)round(box.lefttop.y + box.size.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FillMode mode_rotate = {
|
||||||
|
.rotate = Duration{.microseconds = 100 * 1000}};
|
||||||
|
|
||||||
|
|
||||||
|
setfillcolor(RGB(255, 255, 255));
|
||||||
|
setbkcolor(RGB(0, 0, 0));
|
||||||
|
render_SetModes(mode_rotate, since);
|
||||||
|
render_FillCircleW(app, vec2(200, 100), 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,20 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
BYTE *render_DissolvePattern(double progress) {
|
BYTE *render_DissolvePatternOut(double progress) {
|
||||||
if (progress < .0)
|
if (progress < .0)
|
||||||
progress = .0;
|
progress = .0;
|
||||||
if (progress > 1.0)
|
if (progress > 1.0)
|
||||||
progress = 1.0;
|
progress = 1.0;
|
||||||
|
|
||||||
int index = round(progress * 65);
|
int index = round(progress * 64);
|
||||||
return (BYTE *)(render_DissolvePatternData + index * 8);
|
return (BYTE *)(render_DissolvePatternData + index * 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BYTE *render_DissolvePatternIn(double progress) {
|
||||||
|
return render_DissolvePatternOut(1.0 - progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// generated from test_generate_pattern.cpp
|
// generated from test_generate_pattern.cpp
|
||||||
char render_DissolvePatternData[520] =
|
char render_DissolvePatternData[520] =
|
||||||
|
@ -3,8 +3,21 @@
|
|||||||
// for BYTE
|
// for BYTE
|
||||||
#include <minwindef.h>
|
#include <minwindef.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
// Returns a dissolve pattern for the given progress in [0,1]
|
// Returns a dissolve pattern for the given progress in [0,1]
|
||||||
BYTE *render_DissolvePattern(double progress);
|
// From empty to full
|
||||||
|
BYTE *render_DissolvePatternIn(double progress);
|
||||||
|
// From full to empty
|
||||||
|
BYTE *render_DissolvePatternOut(double progress);
|
||||||
|
|
||||||
|
|
||||||
// The underlying data. 520 bytes
|
// The underlying data. 520 bytes
|
||||||
extern char render_DissolvePatternData[520];
|
extern char render_DissolvePatternData[520];
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -52,21 +52,25 @@ const FillMode render_DefaultMode = {
|
|||||||
.style = BS_SOLID,
|
.style = BS_SOLID,
|
||||||
.hatch = 0,
|
.hatch = 0,
|
||||||
.rotate = {.microseconds = 0},
|
.rotate = {.microseconds = 0},
|
||||||
.dissolve = {.microseconds = 0}};
|
.dissolve = {.microseconds = 0},
|
||||||
|
.fadein = false};
|
||||||
|
|
||||||
|
|
||||||
void render_SetModes(FillMode mode, TimePoint since) {
|
void render_SetModes(FillMode mode, TimePoint since) {
|
||||||
if (mode.dissolve.microseconds != 0) {
|
if (mode.dissolve.microseconds != 0) {
|
||||||
// Dissolve mode
|
// Dissolve mode
|
||||||
double progress = duration_Seconds(time_Since(since)) / duration_Seconds(mode.dissolve);
|
double progress = duration_Seconds(time_Since(since)) / duration_Seconds(mode.dissolve);
|
||||||
setfillstyle(render_DissolvePattern(progress)); // progress is capped into [0,1] in this func
|
if (mode.fadein)
|
||||||
|
setfillstyle(render_DissolvePatternIn(progress)); // progress is capped into [0,1] in this func
|
||||||
|
else
|
||||||
|
setfillstyle(render_DissolvePatternOut(progress));
|
||||||
setrop2(R2_COPYPEN);
|
setrop2(R2_COPYPEN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.rotate.microseconds != 0) {
|
if (mode.rotate.microseconds != 0) {
|
||||||
// Rotate mode
|
// Rotate mode
|
||||||
int steps = round(duration_Seconds(time_Since(since)) / duration_Seconds(mode.dissolve));
|
int steps = round(duration_Seconds(time_Since(since)) / duration_Seconds(mode.rotate));
|
||||||
|
|
||||||
static const long hatches[] = {HS_HORIZONTAL, HS_FDIAGONAL, HS_VERTICAL, HS_BDIAGONAL};
|
static const long hatches[] = {HS_HORIZONTAL, HS_FDIAGONAL, HS_VERTICAL, HS_BDIAGONAL};
|
||||||
setfillstyle(BS_HATCHED, hatches[steps % 4], NULL);
|
setfillstyle(BS_HATCHED, hatches[steps % 4], NULL);
|
||||||
@ -79,11 +83,11 @@ void render_SetModes(FillMode mode, TimePoint since) {
|
|||||||
setrop2(mode.rop2);
|
setrop2(mode.rop2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_FillScreen(FillMode mode, TimePoint since) {
|
void render_FillScreen() {
|
||||||
solidrectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
solidrectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_FillRectW(App *app, Box2 rect, FillMode mode, TimePoint since) {
|
void render_FillRectW(App *app, Box2 rect) {
|
||||||
if (app->camera)
|
if (app->camera)
|
||||||
rect = camera_TransformBox2(app->camera, rect);
|
rect = camera_TransformBox2(app->camera, rect);
|
||||||
else
|
else
|
||||||
@ -95,7 +99,7 @@ void render_FillRectW(App *app, Box2 rect, FillMode mode, TimePoint since) {
|
|||||||
(int)round(rect.lefttop.y + rect.size.y));
|
(int)round(rect.lefttop.y + rect.size.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_FillCircleW(App *app, Vec2 center, double radius, FillMode mode, TimePoint since) {
|
void render_FillCircleW(App *app, Vec2 center, double radius) {
|
||||||
if (app->camera) {
|
if (app->camera) {
|
||||||
center = camera_TransformVec2(app->camera, center);
|
center = camera_TransformVec2(app->camera, center);
|
||||||
radius = camera_TransformSize(app->camera, vec2(radius, 0)).x; // TODO non-aspect scaling
|
radius = camera_TransformSize(app->camera, vec2(radius, 0)).x; // TODO non-aspect scaling
|
||||||
|
@ -42,6 +42,7 @@ typedef struct {
|
|||||||
// Dissolve the entire screen in an animation in this
|
// Dissolve the entire screen in an animation in this
|
||||||
// amount of time. Overrides rotate, style & hatch
|
// amount of time. Overrides rotate, style & hatch
|
||||||
Duration dissolve;
|
Duration dissolve;
|
||||||
|
bool fadein; // Fade Into being full for true, fade out of otherwise
|
||||||
} FillMode;
|
} FillMode;
|
||||||
|
|
||||||
// Default fill mode.
|
// Default fill mode.
|
||||||
@ -56,12 +57,12 @@ typedef struct _App App;
|
|||||||
void render_SetModes(FillMode mode, TimePoint since);
|
void render_SetModes(FillMode mode, TimePoint since);
|
||||||
|
|
||||||
// Fills the entire screen
|
// Fills the entire screen
|
||||||
void render_FillScreen(FillMode mode, TimePoint since);
|
void render_FillScreen();
|
||||||
|
|
||||||
// Fills a rectangle in world coordinates
|
// Fills a rectangle in world coordinates
|
||||||
void render_FillRectW(App *app, Box2 rect, FillMode mode, TimePoint since);
|
void render_FillRectW(App *app, Box2 rect);
|
||||||
// Fills a circle in world coordinates
|
// Fills a circle in world coordinates
|
||||||
void render_FillCircleW(App *app, Vec2 center, double radius, FillMode mode, TimePoint since);
|
void render_FillCircleW(App *app, Vec2 center, double radius);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
Reference in New Issue
Block a user