Example #1
0
/** @brief We drag our finger on the screen to another location.
 *  @param p [in] New location of our finger.
 *  @return true on success.
 */
bool ChandWriter::onPaintingMove( const Cpoint &point)
{
	Cpoint p =point-(m_rect.leftTop()*8);
	if ( m_surface ==NULL)
	{
		return false;
	}
	if ( !m_started)
	{
		m_started =true;
		addPoint( p.x, p.y);
#ifdef USE_SDL2
		m_graphics->setRenderArea( m_surface);
		m_graphics->pixel( p.x, p.y);
		m_graphics->setRenderArea( NULL);
#else
		CtextSurface::pixel( m_surface, p);
#endif
		m_lastPoint =p;
		m_index =1;
	}
	else
	{
		// Not for small distances.
		if ( p.distance( m_lastPoint) >m_minimum_distance && ++m_index<1000)
		{
			// New line detected.
			addPoint( p.x, p.y);
#ifdef USE_SDL2
			m_graphics->setRenderArea( m_surface);
			m_graphics->line( m_lastPoint.x, m_lastPoint.y, p.x, p.y);
			m_graphics->setRenderArea( NULL);
#else
			CtextSurface::line( m_surface, m_lastPoint, p);
#endif
			// pixel(%d,%d) to (%d,%d)", m_lastPoint.x, m_lastPoint.y, p.x, p.y);
			m_lastPoint =p;
		}
	}
	Cimage::onPaint(0);
	onUpdate();
	return true;
}