Skip to content

Commit

Permalink
autofill and painterly is working again
Browse files Browse the repository at this point in the history
  • Loading branch information
dipsywong98 committed Feb 28, 2019
1 parent b1796d1 commit afd1358
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
23 changes: 16 additions & 7 deletions PaintView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ void PaintView::draw()
drawWidth = min( m_nWindowWidth, m_pDoc->m_nPaintWidth );
drawHeight = min( m_nWindowHeight, m_pDoc->m_nPaintHeight );

// if (uc_backup)
// {
// memcpy(m_pDoc->m_ucPainting, uc_backup, drawWidth*drawHeight * 3);
// }

startrow = m_pDoc->m_nPaintHeight - (scrollpos.y + drawHeight);
if ( startrow < 0 ) startrow = 0;

Expand All @@ -134,7 +139,7 @@ void PaintView::draw()
if ( m_pDoc->m_ucPainting && !isAnEvent)
{
RestoreContent();
updateViewport();
// updateViewport();
}

bool willSave = false;
Expand All @@ -152,20 +157,20 @@ void PaintView::draw()
switch (eventToDo)
{
case LEFT_MOUSE_DOWN:
updatePainting();
// updatePainting();
m_pDoc->recordHistory();
m_pDoc->m_pCurrentBrush->BrushBegin( source, target );
updateViewport();
// updateViewport();
break;
case LEFT_MOUSE_DRAG:
updatePainting();
// updatePainting();
m_pDoc->m_pCurrentBrush->BrushMove( source, target );
SaveCurrentContent();
updateViewport();
// updateViewport();
break;
case LEFT_MOUSE_UP:
m_pDoc->m_pCurrentBrush->BrushEnd( source, target );
updatePainting();
// updatePainting();
// SaveCurrentContent();
// RestoreContent();
willSave = true;
Expand Down Expand Up @@ -220,7 +225,11 @@ void PaintView::draw()
if(willSave)
{
SaveCurrentContent();
updateViewport();
glFlush();
delete[] uc_backup;
uc_backup = new unsigned char[drawWidth*drawHeight * 3];
memcpy(uc_backup, m_pDoc->m_ucPainting, drawWidth*drawHeight * 3);
// updateViewport();
}


Expand Down
1 change: 1 addition & 0 deletions PaintView.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class PaintView : public Fl_Gl_Window
std::default_random_engine rng = std::default_random_engine(std::chrono::system_clock::now().time_since_epoch().count());
Point scrollpos{0, 0};
int startrow = 0;
unsigned char *uc_backup = NULL;

void updateViewport();
void updatePainting();
Expand Down
Binary file added polygonpainterly.bmp
Binary file not shown.

0 comments on commit afd1358

Please sign in to comment.