implement GCIRCLE X,Y,R,C
This commit is contained in:
@@ -321,10 +321,18 @@ class BuiltinFunction
|
|||||||
color.setDefaultValue(p.gcolor);
|
color.setDefaultValue(p.gcolor);
|
||||||
p.gfill(p.useGRP, x, y, x2, y2, cast(int)color);
|
p.gfill(p.useGRP, x, y, x2, y2, cast(int)color);
|
||||||
}
|
}
|
||||||
static void GCIRCLE(PetitComputer p, Value[])
|
//X,Y,R[,COLOR]
|
||||||
|
//X,Y,R,SR,ER[,COLOR]
|
||||||
|
static void GCIRCLE(PetitComputer p, int x, int y, int r, DefaultValue!(int, false) color)
|
||||||
{
|
{
|
||||||
//color.setDefaultValue(p.gcolor);
|
color.setDefaultValue(p.gcolor);
|
||||||
//p.gfill(p.useGRP, x, y, x2, y2, cast(int)color);
|
p.gcircle(p.useGRP, x, y, r, 0, 360, 0, cast(int)color);
|
||||||
|
}
|
||||||
|
static void GCIRCLE(PetitComputer p, int x, int y, int r, int sr, int er, DefaultValue!(int, false) flag, DefaultValue!(int, false) color)
|
||||||
|
{
|
||||||
|
color.setDefaultValue(p.gcolor);
|
||||||
|
flag.setDefaultValue(0);
|
||||||
|
p.gcircle(p.useGRP, x, y, r, sr, er, cast(int)flag, cast(int)color);
|
||||||
}
|
}
|
||||||
static void GCOLOR(PetitComputer p, int color)
|
static void GCOLOR(PetitComputer p, int color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import std.file;
|
|||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.c.stdio;
|
import core.stdc.stdio;
|
||||||
import core.sync.mutex;
|
import core.sync.mutex;
|
||||||
import core.sync.condition;
|
import core.sync.condition;
|
||||||
import otya.smilebasic.sprite;
|
import otya.smilebasic.sprite;
|
||||||
@@ -674,6 +674,18 @@ class PetitComputer
|
|||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, w, h, 0, 1024, -2048);
|
glOrtho(0, w, h, 0, 1024, -2048);
|
||||||
}
|
}
|
||||||
|
void drawCircle(int x, int y, int r, int startr, int endr, int flag)
|
||||||
|
{
|
||||||
|
import std.math : sin, cos, PI;
|
||||||
|
int count = r;
|
||||||
|
glBegin(GL_LINE_LOOP);
|
||||||
|
for (int i = 0; i <= r; i++)
|
||||||
|
{
|
||||||
|
//float a = i * (360f / r);
|
||||||
|
glVertex2f(sin(cast(float)i / count * 2f * PI) * r + x, cos(cast(float)i / count * 2f * PI) * r + y);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
void renderGraphic()
|
void renderGraphic()
|
||||||
{
|
{
|
||||||
if(!drawMessageLength) return;
|
if(!drawMessageLength) return;
|
||||||
@@ -773,6 +785,12 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case DrawType.CIRCLE:
|
||||||
|
{
|
||||||
|
glColor4ubv(cast(ubyte*)&dm.color);
|
||||||
|
drawCircle(dm.x, dm.y, dm.circle.r, dm.circle.startr, dm.circle.endr, dm.circle.flag);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
dt = dm.type;
|
dt = dm.type;
|
||||||
@@ -1622,6 +1640,11 @@ class PetitComputer
|
|||||||
TRI,
|
TRI,
|
||||||
PAINT,
|
PAINT,
|
||||||
}
|
}
|
||||||
|
struct Circle
|
||||||
|
{
|
||||||
|
short r, startr, endr;
|
||||||
|
short flag;
|
||||||
|
}
|
||||||
struct DrawMessage
|
struct DrawMessage
|
||||||
{
|
{
|
||||||
DrawType type;
|
DrawType type;
|
||||||
@@ -1631,13 +1654,14 @@ class PetitComputer
|
|||||||
uint color;
|
uint color;
|
||||||
short x2;
|
short x2;
|
||||||
short y2;
|
short y2;
|
||||||
|
Circle circle;
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
static const int dmqqueuelen = 8192;
|
static const int dmqqueuelen = 8192;
|
||||||
DrawMessage[] drawMessageQueue = new DrawMessage[dmqqueuelen];
|
DrawMessage[] drawMessageQueue = new DrawMessage[dmqqueuelen];
|
||||||
int drawMessageLength;
|
int drawMessageLength;
|
||||||
bool drawflag;
|
bool drawflag;
|
||||||
void sendDrawMessage(DrawType type, byte page, short x, short y, uint color)
|
void sendDrawMessage(DrawMessage dm)
|
||||||
{
|
{
|
||||||
//grpmutex.lock();
|
//grpmutex.lock();
|
||||||
//scope(exit)
|
//scope(exit)
|
||||||
@@ -1650,30 +1674,31 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(drawflag){}
|
while(drawflag){}
|
||||||
drawMessageQueue[drawMessageLength].type = type;
|
dm.color = toGLColor(this.GRP[0].textureFormat, dm.color & 0xFFF8F8F8);
|
||||||
drawMessageQueue[drawMessageLength].page = page;
|
drawMessageQueue[drawMessageLength] = dm;
|
||||||
drawMessageQueue[drawMessageLength].x = x;
|
|
||||||
drawMessageQueue[drawMessageLength].y = y;
|
|
||||||
drawMessageQueue[drawMessageLength].color = toGLColor(this.GRP[0].textureFormat, color & 0xFFF8F8F8);
|
|
||||||
drawMessageLength++;
|
drawMessageLength++;
|
||||||
}
|
}
|
||||||
|
void sendDrawMessage(DrawType type, byte page, short x, short y, uint color)
|
||||||
|
{
|
||||||
|
DrawMessage dm;
|
||||||
|
dm.type = type;
|
||||||
|
dm.page = page;
|
||||||
|
dm.x = x;
|
||||||
|
dm.y = y;
|
||||||
|
dm.color = color;
|
||||||
|
sendDrawMessage(dm);
|
||||||
|
}
|
||||||
void sendDrawMessage(DrawType type, byte page, short x, short y, short x2, short y2, uint color)
|
void sendDrawMessage(DrawType type, byte page, short x, short y, short x2, short y2, uint color)
|
||||||
{
|
{
|
||||||
if(drawMessageLength >= dmqqueuelen)
|
DrawMessage dm;
|
||||||
{
|
dm.type = type;
|
||||||
while(drawMessageLength)
|
dm.page = page;
|
||||||
{
|
dm.x = x;
|
||||||
SDL_Delay(1);
|
dm.y = y;
|
||||||
}
|
dm.x2 = x2;
|
||||||
}
|
dm.y2 = y2;
|
||||||
drawMessageQueue[drawMessageLength].type = type;
|
dm.color = color;
|
||||||
drawMessageQueue[drawMessageLength].page = page;
|
sendDrawMessage(dm);
|
||||||
drawMessageQueue[drawMessageLength].x = x;
|
|
||||||
drawMessageQueue[drawMessageLength].y = y;
|
|
||||||
drawMessageQueue[drawMessageLength].x2 = x2;
|
|
||||||
drawMessageQueue[drawMessageLength].y2 = y2;
|
|
||||||
drawMessageQueue[drawMessageLength].color = toGLColor(this.GRP[0].textureFormat, color & 0xFFF8F8F8);
|
|
||||||
drawMessageLength++;
|
|
||||||
}
|
}
|
||||||
//TODO:範囲チェック
|
//TODO:範囲チェック
|
||||||
void gpset(int page, int x, int y, uint color)
|
void gpset(int page, int x, int y, uint color)
|
||||||
@@ -1696,6 +1721,20 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
sendDrawMessage(DrawType.PAINT, cast(byte)page, cast(short)x, cast(short)y, color);
|
sendDrawMessage(DrawType.PAINT, cast(byte)page, cast(short)x, cast(short)y, color);
|
||||||
}
|
}
|
||||||
|
void gcircle(int page, int x, int y, int r, int startr, int endr, int flag, uint color)
|
||||||
|
{
|
||||||
|
DrawMessage dm;
|
||||||
|
dm.page = cast(byte)page;
|
||||||
|
dm.x = cast(short)x;
|
||||||
|
dm.y = cast(short)y;
|
||||||
|
dm.circle.r = cast(short)r;
|
||||||
|
dm.circle.startr = cast(short)startr;
|
||||||
|
dm.circle.endr = cast(short)endr;
|
||||||
|
dm.circle.flag = cast(short)flag;
|
||||||
|
dm.color = color;
|
||||||
|
dm.type = DrawType.CIRCLE;
|
||||||
|
sendDrawMessage(dm);
|
||||||
|
}
|
||||||
int gprio;
|
int gprio;
|
||||||
void renderGraphicPage(int display, float w, float h)
|
void renderGraphicPage(int display, float w, float h)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user