2013-04-23 43 views
0

我打算開發一個演示應用程序,該應用程序可以激活MS Paint但在網頁上運行(HTML5)。目前我已經實現了筆刷功能(完全像MS Paint),但我想將每個筆刷筆觸存儲在數據庫中。然而我沒有找到一個存儲筆觸的數據結構。你們認爲連續點(x,y)的數組可以保存筆刷信息嗎?如何存儲畫筆描邊信息

class point 
{ 
    float x, y; 
} 

class brush 
{ 
    List<point> data; 
} 

此致敬禮。

+0

[標籤:數據庫設計]和[標籤:數據結構]爲什麼? – Kermit 2013-04-23 03:53:50

+0

我認爲數據結構比數據庫設計更合適。對不起,如果我濫用標籤 – 2013-04-23 03:57:44

回答

0

是的,保存點是一個好辦法。

請記住,你每行的第一點是context.moveTo。然後你可以使用context.lineTo輕鬆地重放剩餘的筆畫。

我假設你也需要每個畫筆描邊的顏色和寬度信息。

這裏的起始模式:

table: Points 
pointId int [primary key] 
strokeID int, [key to table Strokes] 
pointX int, 
pointY int 

table: Strokes 
strokeId int, [primary key] 
fillStyle varchar, 
strokeStyle varchar, 
lineWidth int