コード例 #1
0
ファイル: graphics.c プロジェクト: leoagomes/LovePotion
static int graphicsRectangle(lua_State *L) { // love.graphics.rectangle()

	if (sf2d_get_current_screen() == currentScreen) {

		char *mode = luaL_checkstring(L, 1);

		int x = luaL_checkinteger(L, 2);
		int y = luaL_checkinteger(L, 3);

		translateCoords(&x, &y);

		int w = luaL_checkinteger(L, 4);
		int h = luaL_checkinteger(L, 5);

		if (strcmp(mode, "fill") == 0) {
			sf2d_draw_rectangle(x, y, w, h, getCurrentColor());
		} else if (strcmp(mode, "line") == 0) {
			sf2d_draw_line(x, y, x, y + h, currentLineWidth, getCurrentColor());
			sf2d_draw_line(x, y, x + w, y, currentLineWidth, getCurrentColor());

			sf2d_draw_line(x + w, y, x + w, y + h, currentLineWidth, getCurrentColor());
			sf2d_draw_line(x, y + h, x + w, y + h, currentLineWidth, getCurrentColor());
		}

	}

	return 0;

}
コード例 #2
0
void FlowContextController::newRoutePoint(QPoint location)
{
    if (getCurrentColor() == -1) return;
    if (!isInRange(location)) return;

    // don't link to terminal dots of other colors
    if (isTerminalDotsOfOthers(location)) return;

    truncateCurrentRoute(location);

    if (m_current_route.size() == 0)
        // first time or over-truncated?
        m_current_route.append(location);
    else if (!isOutOfTerminal(location)) {
        // or satisfy the conditions to complete route
        for (int i = 1; i <= MAX_FIND_ROUTE; i++)
            if (makeReachableBy(m_current_route.back(), location, i)) {
                m_current_route.append(location);
                break;
            }
    }

    m_stable->cloneTo(*m_beta, false); // update later
    m_beta->addRoute(getCurrentColor(), m_current_route);
    // i.e. addRoute here will update view
}
コード例 #3
0
void FlowContextController::startRoute(QPoint location)
{
    if (!isInRange(location)) return;

    int dot_color = m_board->getColorAt(location);
    int context_color = m_stable->getColorAt(location);
    int color = dot_color != -1 ?
                dot_color : context_color;

    setCurrentColor(color);

    if (getCurrentColor() == -1)
        // on the board
        return;

    // update moves count
    if (getCurrentColor() != m_previous_legal_color) {
        setMoves(getMoves() + 1);
        // save for undo
        m_undo.push(new FlowContext(m_board, this));
        m_stable->cloneTo(*m_undo.top());
    }
    m_previous_legal_color = getCurrentColor();

    if (dot_color != -1)
        // is a terminal
        m_current_route.clear();
    else
        // is on a existing route
        m_current_route = m_stable->getRouteOf(color);
    m_stable->clearRouteOf(color);

    newRoutePoint(location);
}
コード例 #4
0
//draw your keyframes into bounds
void ofxTLEmptyKeyframes::draw(){
	
	ofPushStyle();
	
	ofFill();
	//show the current color as background based on the playhead position
	ofSetColor(getCurrentColor(), 100);
	ofDrawRectangle(bounds);

	for(int i = 0; i < keyframes.size(); i++){
		//make sure it's on screen
		if(isKeyframeIsInBounds(keyframes[i])){
			//we know the type because we created it in newKeyframe()
			//so we can safely cast
			ofxTLEmptyKeyframe* emptyKeyframe = (ofxTLEmptyKeyframe*)keyframes[i];
			if(hoverKeyframe == emptyKeyframe){
				ofSetColor(timeline->getColors().highlightColor);
			}
			else if(isKeyframeSelected(emptyKeyframe)){
				ofSetColor(timeline->getColors().textColor);
			}
			else{
				ofSetColor(timeline->getColors().keyColor);
			}
			ofVec2f screenPoint = screenPositionForKeyframe(emptyKeyframe);
			ofDrawCircle(screenPoint, 7);
			ofSetColor(emptyKeyframe->color);
			ofDrawCircle(screenPoint, 5);
		}
	}
	
	ofPopStyle();
}
コード例 #5
0
bool FlowContextController::isOutOfTerminal(QPoint location)
{
    // check if it's out of terminal to avoid overflowing
    QPoint last_point = m_current_route.back();
    return m_board->getColorAt(last_point) == getCurrentColor()
            && m_current_route.size() > 1;
}
コード例 #6
0
void ofxAnimatableOfColor::animateToAlpha( float a ) {

    originalColor_ = getCurrentColor();
    targetColor_ = originalColor_;
    targetColor_.a = a;
    ofxAnimatable::startAnimation();
}
コード例 #7
0
ファイル: graphics.c プロジェクト: leoagomes/LovePotion
static int graphicsLine(lua_State *L) { // love.graphics.line() -- Semi-Broken

	if (sf2d_get_current_screen() == currentScreen) {

		int argc = lua_gettop(L);
		int i = 0;

		if ((argc/2)*2 == argc) {
			for( i; i < argc / 2; i++) {

				int t = i * 4;

				int x1 = luaL_checkinteger(L, t + 1);
				int y1 = luaL_checkinteger(L, t + 2);
				int x2 = luaL_checkinteger(L, t + 3);
				int y2 = luaL_checkinteger(L, t + 4);

				translateCoords(&x1, &y1);
				translateCoords(&x2, &y2);

				sf2d_draw_line(x1, y1, x2, y2, currentLineWidth, getCurrentColor());

			}
		}

	}

	return 0;

}
コード例 #8
0
void ofxAnimatableOfColor::setAlphaOnly( float a ) {

    originalColor_ = getCurrentColor();
    originalColor_.a = a;
    targetColor_ = originalColor_;
    ofxAnimatable::reset();
}
コード例 #9
0
ファイル: colorframe.cpp プロジェクト: StrayEddy/ErogeWorld
void ColorFrame::mousePressEvent(QMouseEvent *event)
{
    isPressed_ = true;
    selectedPoint_ = event->pos();
    event->accept();
    getCurrentColor();
    update();
}
コード例 #10
0
const float * ColorGenerator::getNextColor()
{
    index++;
    if (index >= noColors) {
        index = 0;
    }
    return getCurrentColor();
}
コード例 #11
0
void PenProcessor::processImage(QImage *image) const
{
  if (valid)
  {
    QPainter *painter = new QPainter(image);
    QPen pen;
    if (getCurrentColor().isValid())
      pen = QPen(getCurrentColor());
    else
      pen = QPen(_color);
    pen.setWidth(_width);
    painter->setPen(pen);
    painter->drawPoints(positions);
    painter->end();
    delete painter;
  }
}
コード例 #12
0
QImage *PenProcessor::processImage(const QImage& image) const
{
  QImage *result = new QImage(image);
  if (valid)
  {
    QPainter *painter = new QPainter(result);
    QPen pen;
    if (getCurrentColor().isValid())
      pen = QPen(getCurrentColor());
    else
      pen = QPen(_color);
    pen.setWidth(_width);
    painter->setPen(pen);
    painter->drawPoints(positions);
    painter->end();
    delete painter;
  }
  return result;
}
コード例 #13
0
void ofxAnimatableOfColor::startBlinking( float blinkDuration) {

    setRepeatType(LOOP_BACK_AND_FORTH);
    setCurve(EASE_IN_EASE_OUT);
    setAlphaOnly(0.0f);
    setDuration( blinkDuration );
    ofColor c = getCurrentColor();
    c.a = 255;
    animateTo( c );
}
コード例 #14
0
void KisVisualEllipticalSelectorShape::drawCursor()
{
    //qDebug() << this << "KisVisualEllipticalSelectorShape::drawCursor: image needs update" << imagesNeedUpdate();
    QPointF cursorPoint = convertShapeCoordinateToWidgetCoordinate(getCursorPosition());
    QImage fullSelector = getImageMap();
    QColor col = getColorFromConverter(getCurrentColor());
    QPainter painter;
    painter.begin(&fullSelector);
    painter.setRenderHint(QPainter::Antialiasing);
    QRect innerRect(m_barWidth, m_barWidth, width()-(m_barWidth*2), height()-(m_barWidth*2));

    painter.save();
    painter.setCompositionMode(QPainter::CompositionMode_Clear);
    QPen pen;
    pen.setWidth(5);
    painter.setPen(pen);
    painter.drawEllipse(QRect(0,0,width(),height()));

    if (getDimensions()==KisVisualColorSelectorShape::onedimensional) {
        painter.setBrush(Qt::SolidPattern);
        painter.drawEllipse(innerRect);
    }
    painter.restore();

    QBrush fill;
    fill.setStyle(Qt::SolidPattern);

    int cursorwidth = 5;

    if (m_type==KisVisualEllipticalSelectorShape::borderMirrored) {
        painter.setPen(Qt::white);
        fill.setColor(Qt::white);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
        QPoint mirror(innerRect.center().x()+(innerRect.center().x()-cursorPoint.x()),cursorPoint.y());
        painter.drawEllipse(mirror, cursorwidth, cursorwidth);
        fill.setColor(col);
        painter.setPen(Qt::black);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth-1, cursorwidth-1);
        painter.drawEllipse(mirror, cursorwidth-1, cursorwidth-1);

    } else {
        painter.setPen(Qt::white);
        fill.setColor(Qt::white);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
        fill.setColor(col);
        painter.setPen(Qt::black);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0);
    }
    painter.end();
    setFullImage(fullSelector);
}
コード例 #15
0
void ofxAnimatableOfColor::animateToAlphaAfterDelay( float a, float delay ) {

    if (delay <= 0.0f) {
        animateToAlpha(a);
    } else {
        originalColor_ = getCurrentColor();
        targetTempColor_ = originalColor_;
        targetTempColor_.a = a;
        animateToAfterDelay(targetTempColor_, delay);
    }
}
コード例 #16
0
ファイル: graphics.c プロジェクト: leoagomes/LovePotion
static int graphicsCircle(lua_State *L) { // love.graphics.circle()

	if (sf2d_get_current_screen() == currentScreen) {

		int step = 15;

		char *mode = luaL_checkstring(L, 1);
		int x = luaL_checkinteger(L, 2);
		int y = luaL_checkinteger(L, 3);
		int r = luaL_checkinteger(L, 4);

		translateCoords(&x, &y);

		sf2d_draw_line(x, y, x, y, 1, getCurrentColor()); // Fixes weird circle bug.
		sf2d_draw_fill_circle(x, y, r, getCurrentColor());

	}

	return 0;

}
コード例 #17
0
void ofxAnimatableOfColor::fadeIn() {

    ofColor targetC = getCurrentColor();

    if ( sizeof(targetC.r) == sizeof(float) )
        targetC.a = (float)1.0f;
    else if ( sizeof(targetC.r) == sizeof(unsigned char) )
        targetC.a = (unsigned char) numeric_limits<unsigned char>::max();
    else if ( sizeof(targetC.r) == sizeof(unsigned short) )
        targetC.a = (unsigned char) numeric_limits<unsigned short>::max();

    animateTo( targetC );
}
コード例 #18
0
ファイル: graphics.c プロジェクト: leoagomes/LovePotion
static int graphicsDraw(lua_State *L) { // love.graphics.draw()

	if (sf2d_get_current_screen() == currentScreen) {

		love_image *img = luaobj_checkudata(L, 1, LUAOBJ_TYPE_IMAGE);
		love_quad *quad = NULL;

		int x, y;
		float rad;

		if (!lua_isnone(L, 2) && lua_type(L, 2) != LUA_TNUMBER) {

			quad = luaobj_checkudata(L, 2, LUAOBJ_TYPE_QUAD);
			x = luaL_optnumber(L, 3, 0);
			y = luaL_optnumber(L, 4, 0);
			rad = luaL_optnumber(L, 5, 0);

		} else {

			x = luaL_optnumber(L, 2, 0);
			y = luaL_optnumber(L, 3, 0);
			rad = luaL_optnumber(L, 4, 0);

		}

		translateCoords(&x, &y);

		if (rad == 0) {

			if (!quad) {

				if (img) {
					sf2d_draw_texture_blend(img->texture, x, y, getCurrentColor());
				}
				
			} else {
				sf2d_draw_texture_part_blend(img->texture, x, y, quad->x, quad->y, quad->width, quad->height, getCurrentColor());
			}

		} else {

			sf2d_draw_texture_rotate_blend(img->texture, x + img->texture->width / 2, y + img->texture->height / 2, rad, getCurrentColor());

		}

	}

	return 0;

}
コード例 #19
0
ファイル: colorframe.cpp プロジェクト: StrayEddy/ErogeWorld
void ColorFrame::mouseMoveEvent(QMouseEvent *event)
{
    if(this->rect().contains(event->pos().x(), event->pos().y()))
    {
        event->accept();
        if(isPressed_ && isInside_)
        {
            selectedPoint_ = event->pos();
            event->accept();
            getCurrentColor();
            update();
        }
    }
    else
        event->ignore();
}
コード例 #20
0
void PaletteWidget::paintEvent(QPaintEvent *event)
{
    auto state = State::getInstance();

    QPainter painter;
    painter.begin(this);

    // paint with default background color
    painter.fillRect(event->rect(), QWidget::palette().color(QWidget::backgroundRole()));


    int currentColor = state->getCurrentColor();
    int selectedPen = state->getSelectedPen();


    QPen pen;
    pen.setColor(Qt::red);
    pen.setWidth(3);
    pen.setStyle(Qt::PenStyle::DotLine);

    for (int y=0; y<2; y++) {
        for (int x=0; x<8; x++) {
            int c = 8 * y + x;

            if (c==currentColor) {
                painter.setPen(pen);
            } else {
                painter.setPen(Qt::PenStyle::NoPen);
            }

            if (selectedPen == State::PEN_FOREGROUND && state->isMulticolorMode())
                c %= 8;
            painter.setBrush(Palette::getColor(c));

            painter.drawRect(x * PIXEL_SIZE_X, y * PIXEL_SIZE_Y,
                             PIXEL_SIZE_X-1, PIXEL_SIZE_Y-1);
        }
    }

    painter.end();
}
コード例 #21
0
ファイル: graphics.c プロジェクト: leoagomes/LovePotion
static int graphicsPrintFormat(lua_State *L) {

	if (sf2d_get_current_screen() == currentScreen) {

		if (currentFont) {

			char *printText = luaL_checkstring(L, 1);
			int x = luaL_checkinteger(L, 2);
			int y = luaL_checkinteger(L, 3);
			int limit = luaL_checkinteger(L, 4);
			char *align = luaL_optstring(L, 5, "left");

			int width = sftd_get_text_width(currentFont->font, currentFont->size, printText);

			if (strcmp(align, "center") == 0) {

				if (width < limit) {
					x += (limit / 2) - (width / 2);
				}

			} else if (strcmp(align, "right") == 0) {

				if (width < limit) {
					x += limit - width;
				}

			}

			translateCoords(&x, &y);

			if (x > 0) limit += x; // Quick text wrap fix, needs removing once sf2dlib is updated.

			sftd_draw_text_wrap(currentFont->font, x, y, getCurrentColor(), currentFont->size, limit, printText);

		}

	}

	return 0;

}
コード例 #22
0
ファイル: graphics.c プロジェクト: leoagomes/LovePotion
static int graphicsPrint(lua_State *L) { // love.graphics.print()

	if (sf2d_get_current_screen() == currentScreen) {

		if (currentFont) {

			char *printText = luaL_checkstring(L, 1);
			int x = luaL_checkinteger(L, 2);
			int y = luaL_checkinteger(L, 3);

			translateCoords(&x, &y);

			sftd_draw_text(currentFont->font, x, y, getCurrentColor(), currentFont->size, printText);

		}

	}

	return 0;

}
コード例 #23
0
bool FlowContextController::isTerminalDotsOfOthers(QPoint location)
{
    int dot_color = m_board->getColorAt(location);
    return dot_color != -1 && dot_color != getCurrentColor();
}
コード例 #24
0
ファイル: cursor.cpp プロジェクト: RapdElzo/Flask
void Cursor::render(float translateValue)
{
	if (sf2d_get_current_screen() == getCurrentScreen()) 
	{
		setColor(41, 105, 176, 160 * this->sineValue);

		sf2d_draw_rectangle(this->x, ceil(this->y - translateValue), this->width, this->height, getCurrentColor());

		setColor(255, 255, 255, 255);
	}
}
コード例 #25
0
void ofxAnimatableOfColor::applyCurrentColor() {
    ofSetColor( getCurrentColor() );
}
コード例 #26
0
void ofxAnimatableOfColor::animateTo( ofColor col ) {

    originalColor_ = getCurrentColor();
    targetColor_ = col;
    ofxAnimatable::startAnimation();
}
コード例 #27
0
void ofxAnimatableOfColor::fadeOut() {

    ofColor targetC = getCurrentColor();
    targetC.a = 0.0f;
    animateTo( targetC );
}