SDL_Surface *STT_RightButton_Up::BuildTexture(SDL_Surface *surf, const Uint32 xsize, const Uint32 ysize, const SDL_Color &col) { SDL_Surface *ret = BuildInternal(surf, xsize, ysize, base_col(col), light_col(col), dark_col(col)); int width = xsize / 16; if (width > int(ysize / 16)) width = ysize / 16; if (width < 1) width = 1; SDL_Rect point = {width * 2, width * 2, width, width}; for (Uint32 pos = ysize / 4; pos <= ysize / 2; ++pos) { point.x = xsize / 2; point.y = pos; point.w = (xsize * pos / ysize) - ysize / 4; SDL_FillRect(ret, &point, SDL_MapRGB(ret->format, textcol.r, textcol.g, textcol.b)); point.y = ysize - pos; SDL_FillRect(ret, &point, SDL_MapRGB(ret->format, textcol.r, textcol.g, textcol.b)); } return ret; }
void NodeConnectionControl::draw(GlInterface &gl) { if(visible) { if(fromNode) pFrom = fromNode->getConnectorPoint(fromNc->ioType); if(toNode) pTo = toNode->getConnectorPoint(toNc->ioType); adjustPos(); const float length = (pTo - pFrom).length(), angle = atan2(pTo.y - pFrom.y, pTo.x - pFrom.x), cos_a = cos(angle), sin_a = sin(angle); APoint start = pFrom; AVec step = AVec(cos_a, sin_a); AVec perp = AVec(sin_a, -cos_a); step.normalize(); perp.normalize(); //Multiply color channels by background color Color color_mult = bgStateColors[cState], inactive_col(inactiveColor.r*color_mult.r, inactiveColor.g*color_mult.g, inactiveColor.b*color_mult.b, inactiveColor.a*color_mult.a), base_col(baseColor.r*color_mult.r, baseColor.g*color_mult.g, baseColor.b*color_mult.b, baseColor.a*color_mult.a), arrow_col(arrowColor.r*color_mult.r, arrowColor.g*color_mult.g, arrowColor.b*color_mult.b, arrowColor.a*color_mult.a); std::vector<TVertex> points; //points.reserve(2*ceil((length - ARROW_LENGTH)/spacing)*(length > ARROW_LENGTH)); Color col; /* for(float r = 0.0f; r < length - ARROW_LENGTH; r += spacing, even = !even) { APoint p = start + step*r; float omega_t = SIN_OMEGA*PHYSICS_CLOCK.t, phi = SIN_K*r*0.05f, height1 = amplitude*(sin(omega_t + phi) + 0.5f)*(sin(omega_t + phi*0.25f) + 1.0f)*0.5f, //height of sin wave offset = width*0.0*amplitude*cos(omega_t*1.0 + phi*0.5f), tilt = 0.0f*amplitude*cos(omega_t + phi*0.2), even_mult = even ? lerp(1.0f, 0.5f, height) : 1.0f; //TODO: Make it look more like its rotating // Maybe have a separate height for each line endpoint with different phases? height1 *= even_mult; col = lerp(inactive_col, base_col, height1); AVec height_vec1 = perp*lerp(width, (width + radius)*height, amplitude), height_vec2 = perp*lerp(width tilt_vec = step*tilt, offset_vec = perp*offset; points.push_back(TVertex(p - height_vec - tilt_vec + offset_vec, col)); points.push_back(TVertex(p + height_vec + tilt_vec + offset_vec, col)); } */ //Add rotating line vertices for(float r = 0.0f; r < length - ARROW_LENGTH; r += spacing) { APoint p = start + step*r; float omega_t = SIN_OMEGA*Clock::getGlobalTime(), phi = -SIN_K*r, height = amplitude*sin(omega_t + phi), //height of sin wave offset = 0.0f,//amplitude*cos(omega_t*0.5f + phi*0.05f), tilt = 2.0f*amplitude*cos(-omega_t + phi); //TODO: Make it look more like its rotating col = lerp(inactive_col, base_col, -abs(height)*(1.0f + 2.0f*std::max(0.0f, 8.0f*amplitude*(cos(-omega_t*2.0f + phi*0.01f) - 0.9f)))); //col = lerp(col, Color(0.5f, 0.5f, 0.0f, 1.0f), std::max(0.0f, amplitude*sin(omega_t*40.0f + phi*3.0f))); AVec height_vec = perp*(width + radius*height), tilt_vec = step*tilt, offset_vec = perp*offset; points.push_back(TVertex(p - height_vec - tilt_vec + offset_vec, col)); points.push_back(TVertex(p + height_vec + tilt_vec + offset_vec, col)); } //Draw lines gl.drawShape(GL_LINES, points); points.clear(); col = lerp(inactive_col, arrow_col, amplitude); //Add arrow point vertices points.push_back(TVertex(start + step*(length - ARROW_LENGTH) - perp*width*1.5f, col)); points.push_back(TVertex(start + step*(length - ARROW_LENGTH) + perp*width*1.5f, col)); points.push_back(TVertex(start + step*length, col)); //Draw arrow gl.drawShape(GL_TRIANGLES, points); } }