本文整理汇总了C++中ImpressionistDoc::getAlpha方法的典型用法代码示例。如果您正苦于以下问题:C++ ImpressionistDoc::getAlpha方法的具体用法?C++ ImpressionistDoc::getAlpha怎么用?C++ ImpressionistDoc::getAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImpressionistDoc
的用法示例。
在下文中一共展示了ImpressionistDoc::getAlpha方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BrushMove
void TriangleBrush::BrushMove(const Point source, const Point target) {
ImpressionistDoc* pDoc = GetDocument();
if (pDoc == NULL) {
printf("TriangleBrush::BrushMove document is NULL\n");
return;
}
int size = pDoc->getSize(); // get brush size
float alphaValue = pDoc->getAlpha();
glPushMatrix();
glTranslatef(target.x, target.y, 0); // move (0, 0) to the tip of mouse cursor
glBegin(GL_POLYGON);
SetColor(source, alphaValue);
for (int i = 0; i < 3; i++) {
float theta = -M_PI / 6 + 2.0f * M_PI * float(i) / float(3); // get the current angle (start from -30 degree)
float x = cosf(theta) * size / 2; // calculate the x component
float y = sinf(theta) * size / 2; // calculate the y component
glVertex2f(x, y); // output vertex
}
glEnd();
glPopMatrix();
}
示例2: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
color[3] = (GLubyte)pDoc->getAlpha(); //Set the alpha channel to whatever the slider says
glColor4ubv( color );
}
示例3: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
float alpha = pDoc->getAlpha();
float* colorBlend = pDoc->getColorBlend();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
color[0] = static_cast<GLubyte> (color[0] * colorBlend[0]);
color[1] = static_cast<GLubyte> (color[1] * colorBlend[1]);
color[2] = static_cast<GLubyte> (color[2] * colorBlend[2]);
color[3] = static_cast<GLubyte>(alpha * 255.f);
glColor4ubv( color );
}
示例4: BrushMove
void ScatteredLineBrush::BrushMove(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
if (pDoc == NULL) {
printf("LineBrush::BrushMove document is NULL\n");
return;
}
const int size = pDoc->getSize();
const float half_size = size / 2.0f;
const int width = pDoc->getWidth();
const int angle = pDoc->getAngle();
const float half_line_width = width / 2.0f;
float alpha = pDoc->getAlpha();
float x, y;
//glBegin(GL_POINTS);
for (int i = 0; i < 3; i++)
{
x = target.x - size / 2 + irand(size);
y = target.y - size / 2 + irand(size);
Point random = Point(x, y);
glPushMatrix();
glTranslatef(random.x, random.y, 0.0f);
glRotatef(angle, 0, 0, 1.0f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_LINES);
SetColor(random, alpha);
glVertex2f(-half_size, 0);
glVertex2f(half_size, 0);
glEnd();
glPopMatrix();
}
}
示例5: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const ImpBrush::Point source)
{
ImpressionistDoc* pDoc = GetDocument();
GLfloat alpha = pDoc->getAlpha();
GLubyte color[3];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
//
// Setup the alpha settings
//
GLfloat color_r = ((GLfloat)color[0]/255);
GLfloat color_g = ((GLfloat)color[1]/255);
GLfloat color_b = ((GLfloat)color[2]/255);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(color_r, color_g, color_b, alpha);
}
示例6: BrushMove
void PointBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "PointBrush::BrushMove document is NULL\n" );
return;
}
int alpha = pDoc->getAlpha();
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin( GL_POINTS );
SetColor( source, alpha );
glVertex2d( target.x, target.y );
glEnd();
}
示例7: BrushMove
void CircleBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "CircleBrush::BrushMove document is NULL\n" );
return;
}
int size = pDoc->getSize();
int alpha = pDoc->getAlpha();
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin( GL_POLYGON );
SetColor( source, alpha );
for (int i = 0;i<360;i++)
glVertex2d( target.x +0.5*size*cos(6.28*i/360) , target.y+0.5*size*sin(6.28*i/360));
glEnd();
}
示例8: BrushMove
void ScatteredPointBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "PointBrush::BrushMove document is NULL\n" );
return;
}
int size = pDoc->getSize();
float alpha = pDoc->getAlpha();
int angle = pDoc->getAngle();
if(dlg->getDirMode()==1)
angle = pDoc->getDirAngle();
float cos_angle,sin_angle;
float rad_angle = (angle*PI)/180;
cos_angle = cos(-rad_angle);
sin_angle = sin(-rad_angle);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
float orig_x,orig_y,x,y;
SetColor( source, alpha );
glBegin( GL_POINTS );
for(int i = 0;i<0.05*size*size;i++)
while(true){
orig_x=-(size/2)+size*frand();
orig_y=-(size/2)+size*frand();
x = orig_x*cos_angle-orig_y*sin_angle;
y = orig_x*sin_angle+orig_y*cos_angle;
glVertex2d( target.x+x, target.y+y );
break;
}
glEnd();
}
示例9: BrushMove
void CsprayBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "CsprayBrush::BrushMove document is NULL\n" );
return;
}
int size = pDoc->getSize();
int density = pDoc->getDensity();
int alpha = pDoc->getAlpha();
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
SetColor( source , alpha);
for (int i = 0;i<density;i++){
float r = rand() %10 ;
r = r*size/10;
oneCircle(target.x+r*cos(6.28*i/density) , target.y+r*sin(6.28*i/density), rand()%3);
}
}
示例10: BrushMove
void CircleBrush::BrushMove(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
if (pDoc == NULL) {
printf("PointBrush::BrushMove document is NULL\n");
return;
}
float radius = (float)pDoc->getSize();
float alpha = pDoc->getAlpha();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_POLYGON);
SetColor(source, alpha);
for (double i = 0; i < 2 * PI; i += PI / INTERVAL) {
glVertex2d(target.x + cos(i)*radius, target.y + sin(i)*radius);
}
glEnd();
glFlush();
}
示例11: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
int r, g, b;
ucolor32 col = pDoc->getBlendColor();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
// Blend the color
UNPACK_COLOR(r, g, b, col);
color[0] = (unsigned)((r * color[0]) / 255);
color[1] = (unsigned)((g * color[1]) / 255);
color[2] = (unsigned)((b * color[2]) / 255);
//Alpha
color[3] = (int)(pDoc->getAlpha() * 255);
glColor4ubv( color );
}
示例12: BrushMove
void LineBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "LineBrush::BrushMove document is NULL\n" );
return;
}
int size = pDoc->getSize();
int ax,ay,bx,by;
int alpha = pDoc->getAlpha();
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
double angle = pDoc->getStrokeAngle();
glBegin( GL_LINES );
SetColor( source, alpha );
glVertex2d( target.x, target.y );
glVertex2d( target.x + cos(angle)*size, target.y + sin(angle)*size );
glEnd();
}
示例13: BrushMove
void SprayBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "SprayBrush::BrushMove document is NULL\n" );
return;
}
int size = pDoc->getSize();
int density = pDoc->getDensity();
int alpha = pDoc->getAlpha();
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (int i = 0; i<density; i++)
{
glPointSize( rand()%5+1 );
glBegin( GL_POINTS );
SetColor( source , alpha );
glVertex2d( target.x - size/2 + rand()%size, target.y -size/2 + rand()%size);
glEnd();
}
}
示例14: BrushMove
void CurvedBrush::BrushMove(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
if (pDoc == NULL) {
printf("PointBrush::BrushMove document is NULL\n");
return;
}
int width = pDoc->m_nWidth;
int height = pDoc->m_nHeight;
radius = pDoc->getSize();
minStrokeLength = pDoc->m_pUI->getMinStrokeLength();
maxStrokeLength = pDoc->m_pUI->getMaxStrokeLength();
curvatureFilter = pDoc->m_pUI->getCurvatureFilter();
unsigned char* imageSource = (pDoc->m_ucBitmapBlurred == NULL) ? pDoc->m_ucBitmap : pDoc->m_ucBitmapBlurred;
if (target.x < 0 || target.x >= width || target.y < 0 || target.y >= height)
{
return;
}
vector<pair< pair<int, int>, tuple<unsigned char, unsigned char, unsigned char> > > centers = CurvedBrushHelper::getCurvedBrushPoints(imageSource, pDoc->m_iGradient, pDoc->m_ucPreservedPainting, width, height, target.x, target.y, radius, minStrokeLength, maxStrokeLength, curvatureFilter);
GLubyte color[4];
color[3] = pDoc->getAlpha() * 255;
auto color3 = centers[0].second;
color[0] = get<0>(color3) * pDoc->m_pUI->m_colorSelector->r();
color[1] = get<1>(color3) * pDoc->m_pUI->m_colorSelector->g();
color[2] = get<2>(color3) * pDoc->m_pUI->m_colorSelector->b();
glColor4ubv(color);
if (centers.size() >= 3)
{
//calculate curves tangent
double* tangentX = new double[centers.size()];
double* tangentY = new double[centers.size()];
tangentX[0] = centers[1].first.first - centers[0].first.first;
tangentY[0] = centers[1].first.second - centers[0].first.second;
tangentX[centers.size() - 1] = centers[centers.size() - 1].first.first - centers[centers.size() - 2].first.first;
tangentY[centers.size() - 1] = centers[centers.size() - 1].first.second - centers[centers.size() - 2].first.second;
for (int i = 1; i < centers.size() - 1; ++i)
{
tangentX[i] = centers[i].first.first - centers[i - 1].first.first;
tangentY[i] = centers[i].first.second - centers[i - 1].first.second;
}
//calculate normal directions
double* normalX = new double[centers.size()];
double* normalY = new double[centers.size()];
for (int i = 0; i < centers.size(); ++i)
{
double unit = sqrt(pow(tangentX[i], 2) + pow(tangentY[i], 2));
normalX[i] = tangentY[i] / unit;
normalY[i] = -tangentX[i] / unit;
}
//calculate boundary points and draw
for (int i = 1; i < centers.size(); ++i)
{
glBegin(GL_POLYGON);
glVertex2d(centers[i - 1].first.first + radius*normalX[i], centers[i - 1].first.second + radius*normalY[i]);
glVertex2d(centers[i].first.first + radius*normalX[i], centers[i].first.second + radius*normalY[i]);
glVertex2d(centers[i].first.first - radius*normalX[i], centers[i].first.second - radius*normalY[i]);
glVertex2d(centers[i - 1].first.first - radius*normalX[i], centers[i - 1].first.second - radius*normalY[i]);
glEnd();
}
delete tangentX;
delete tangentY;
delete normalX;
delete normalY;
}
for (auto c : centers)
{
auto point = c.first;
auto color3 = c.second;
color[0] = get<0>(color3) * pDoc->m_pUI->m_colorSelector->r();
color[1] = get<1>(color3) * pDoc->m_pUI->m_colorSelector->g();
color[2] = get<2>(color3) * pDoc->m_pUI->m_colorSelector->b();
glColor4ubv(color);
glBegin(GL_POLYGON);
for (int i = 0; i < 36; ++i)
{
double theta = i * 10 * 3.14159 / 180;
glVertex2d(point.first - radius * cos(theta), point.second - radius * sin(theta));
}
glEnd();
}
}