Esempio n. 1
0
void TextureTrianglesDialog::FillRenderTarget(int32 textureIndex)
{
    SafeRelease(previewSprite);
    
    if(workingPolygonGroup)
    {
        const int32 IndexFlags[] = {EVF_TEXCOORD0, EVF_TEXCOORD1, EVF_TEXCOORD2, EVF_TEXCOORD3};
        
        if(workingPolygonGroup->vertexFormat & IndexFlags[textureIndex])
        {
            Vector2 usedSize = texturePreview->GetSize();
            previewSprite = Sprite::CreateAsRenderTarget(usedSize.x, usedSize.y, FORMAT_RGBA8888);
            
            RenderManager::Instance()->SetRenderTarget(previewSprite);
            RenderManager::Instance()->SetColor(Color::Black());
            RenderHelper::Instance()->FillRect(Rect(0, 0, usedSize.x, usedSize.y));
            
            usedSize.x = Min(usedSize.x, usedSize.y);
            usedSize.y = Min(usedSize.x, usedSize.y);
            
            usedSize /= 2.0f;
            
            RenderManager::Instance()->SetColor(Color(1.f, 0.f, 0.f, 1.f));
            Vector2 lt(0, 0), lb(0, 1), rt(1, 0), rb(1, 1);
            ConvertCoordinates(lt, usedSize);
            ConvertCoordinates(lb, usedSize);
            ConvertCoordinates(rt, usedSize);
            ConvertCoordinates(rb, usedSize);

            
            RenderHelper::Instance()->DrawLine(lt, lb);
            RenderHelper::Instance()->DrawLine(lt, rt);
            RenderHelper::Instance()->DrawLine(lb, rb);
            RenderHelper::Instance()->DrawLine(rt, rb);
            
            
            RenderManager::Instance()->SetColor(Color(0.f, 1.f, 0.f, 1.f));
            int32 indexCount = workingPolygonGroup->GetIndexCount();
            for(int32 i = 0; i < indexCount - 3; i += 3)
            {
                int32 index0 = 0, index1 = 0, index2 = 0;
                workingPolygonGroup->GetIndex(i + 0, index0);
                workingPolygonGroup->GetIndex(i + 1, index1);
                workingPolygonGroup->GetIndex(i + 2, index2);
                
                Vector2 v0, v1, v2;
                workingPolygonGroup->GetTexcoord(textureIndex, index0, v0);
                workingPolygonGroup->GetTexcoord(textureIndex, index1, v1);
                workingPolygonGroup->GetTexcoord(textureIndex, index2, v2);
             
                ConvertCoordinates(v0, usedSize);
                ConvertCoordinates(v1, usedSize);
                ConvertCoordinates(v2, usedSize);

                RenderHelper::Instance()->DrawLine(v0, v1);
                RenderHelper::Instance()->DrawLine(v1, v2);
                RenderHelper::Instance()->DrawLine(v0, v2);
            }
            
            
            RenderManager::Instance()->RestoreRenderTarget();
        }
    }
    
    texturePreview->SetSprite(previewSprite, 0);
}
Esempio n. 2
0
void ControlsFactory::CustomizeFontDark(Font *font)
{
    font->SetSize(12);
    font->SetColor(Color(0.0f, 0.0f, 0.0f, 1.0f));
}
Esempio n. 3
0
void ControlsFactory::CustomizeScreenBack(UIControl *screen)
{
    screen->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
    screen->GetBackground()->SetColor(Color(0.7f, 0.7f, 0.7f, 1.0f));
}
Esempio n. 4
0
void View::SetBackColor(int a, int r, int g, int b)
{
	_backcolor = Color(a, r, g, b);
}
Esempio n. 5
0
void CollisionPolygon2D::_notification(int p_what) {


	switch(p_what) {
		case NOTIFICATION_ENTER_TREE: {
			unparenting=false;
			can_update_body=get_tree()->is_editor_hint();
			if (!get_tree()->is_editor_hint()) {
				//display above all else
				set_z_as_relative(false);
				set_z(VS::CANVAS_ITEM_Z_MAX-1);
			}

		} break;
		case NOTIFICATION_EXIT_TREE: {
			can_update_body=false;
		} break;
		case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {

			if (!is_inside_tree())
				break;
			if (can_update_body) {
				_update_parent();
			} else if (shape_from>=0 && shape_to>=0) {
				CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
				for(int i=shape_from;i<=shape_to;i++) {
					co->set_shape_transform(i,get_transform());
				}
			}


		} break;

		case NOTIFICATION_DRAW: {

			if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
				break;
			}


			for(int i=0;i<polygon.size();i++) {

				Vector2 p = polygon[i];
				Vector2 n = polygon[(i+1)%polygon.size()];
				draw_line(p,n,Color(0.9,0.2,0.0,0.8),3);
			}
//#define DEBUG_DECOMPOSE
#if defined(TOOLS_ENABLED) && defined (DEBUG_DECOMPOSE)

			Vector< Vector<Vector2> > decomp = _decompose_in_convex();

			Color c(0.4,0.9,0.1);
			for(int i=0;i<decomp.size();i++) {

				c.set_hsv( Math::fmod(c.get_h() + 0.738,1),c.get_s(),c.get_v(),0.5);
				draw_colored_polygon(decomp[i],c);
			}
#else
			draw_colored_polygon(polygon,get_tree()->get_debug_collisions_color());
#endif


		} break;
		case NOTIFICATION_UNPARENTED: {
			unparenting = true;
			_update_parent();
		} break;

	}
}
Esempio n. 6
0
void Output::WarningStr(std::string const& warn) {
	WriteLog("Warning", warn, Color(255, 255, 0, 255));
}
Esempio n. 7
0
void Output::DebugStr(std::string const& msg) {
	WriteLog("Debug", msg, Color(128, 128, 128, 255));
}
Esempio n. 8
0
RES Light::_get_gizmo_geometry() const {


    Ref<FixedMaterial> mat_area( memnew( FixedMaterial ));

    mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.7,0.6,0.0,0.05) );
    mat_area->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.7,0.7,0.7) );
    mat_area->set_blend_mode( Material::BLEND_MODE_ADD );
    mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,true);
    mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);

    Ref<FixedMaterial> mat_light( memnew( FixedMaterial ));

    mat_light->set_parameter( FixedMaterial::PARAM_DIFFUSE, Color(1.0,1.0,0.8,0.9) );
    mat_light->set_flag(Material::FLAG_UNSHADED,true);

    Ref< Mesh > mesh;

    Ref<SurfaceTool> surftool( memnew( SurfaceTool ));

    switch(type) {

    case VisualServer::LIGHT_DIRECTIONAL: {


        mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.9,0.8,0.1,0.8) );
        mat_area->set_blend_mode( Material::BLEND_MODE_MIX);
        mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,false);
        mat_area->set_flag(Material::FLAG_UNSHADED,true);

        _make_sphere( 5,5,0.6, surftool );
        surftool->set_material(mat_light);
        mesh=surftool->commit(mesh);

        //		float radius=1;

        surftool->begin(Mesh::PRIMITIVE_TRIANGLES);

        const int arrow_points=5;
        Vector3 arrow[arrow_points]= {
            Vector3(0,0,2),
            Vector3(1,1,2),
            Vector3(1,1,-1),
            Vector3(2,2,-1),
            Vector3(0,0,-3)
        };

        int arrow_sides=4;


        for(int i = 0; i < arrow_sides ; i++) {


            Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/arrow_sides);
            Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/arrow_sides);


            for(int j=0; j<arrow_points-1; j++) {

                Vector3 points[4]= {
                    ma.xform(arrow[j]),
                    mb.xform(arrow[j]),
                    mb.xform(arrow[j+1]),
                    ma.xform(arrow[j+1]),
                };

                Vector3 n = Plane(points[0],points[1],points[2]).normal;

                surftool->add_normal(n);
                surftool->add_vertex(points[0]);
                surftool->add_normal(n);
                surftool->add_vertex(points[1]);
                surftool->add_normal(n);
                surftool->add_vertex(points[2]);

                surftool->add_normal(n);
                surftool->add_vertex(points[0]);
                surftool->add_normal(n);
                surftool->add_vertex(points[2]);
                surftool->add_normal(n);
                surftool->add_vertex(points[3]);


            }


        }

        surftool->set_material(mat_area);
        mesh=surftool->commit(mesh);



    }
    break;
    case VisualServer::LIGHT_OMNI: {


        _make_sphere( 20,20,vars[PARAM_RADIUS],  surftool );
        surftool->set_material(mat_area);
        mesh=surftool->commit(mesh);
        _make_sphere(5,5, 0.1, surftool );
        surftool->set_material(mat_light);
        mesh=surftool->commit(mesh);
    }
    break;

    case VisualServer::LIGHT_SPOT: {

        _make_sphere( 5,5,0.1, surftool );
        surftool->set_material(mat_light);
        mesh=surftool->commit(mesh);

        // make cone
        int points=24;
        float len=vars[PARAM_RADIUS];
        float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;

        surftool->begin(Mesh::PRIMITIVE_TRIANGLES);

        for(int i = 0; i < points; i++) {

            float x0=Math::sin(i * Math_PI * 2 / points);
            float y0=Math::cos(i * Math_PI * 2 / points);
            float x1=Math::sin((i+1) * Math_PI * 2 / points);
            float y1=Math::cos((i+1) * Math_PI * 2 / points);

            Vector3 v1=Vector3(x0*size,y0*size,-len).normalized()*len;
            Vector3 v2=Vector3(x1*size,y1*size,-len).normalized()*len;

            Vector3 v3=Vector3(0,0,0);
            Vector3 v4=Vector3(0,0,v1.z);

            Vector3 n = Plane(v1,v2,v3).normal;


            surftool->add_normal(n);
            surftool->add_vertex(v1);
            surftool->add_normal(n);
            surftool->add_vertex(v2);
            surftool->add_normal(n);
            surftool->add_vertex(v3);

            n=Vector3(0,0,-1);

            surftool->add_normal(n);
            surftool->add_vertex(v1);
            surftool->add_normal(n);
            surftool->add_vertex(v2);
            surftool->add_normal(n);
            surftool->add_vertex(v4);


        }

        surftool->set_material(mat_area);
        mesh=surftool->commit(mesh);


    }
    break;
    }

    return mesh;
}
Esempio n. 9
0
Color Light::get_color(LightColor p_color) const {

    ERR_FAIL_INDEX_V(p_color, 3, Color());
    return colors[p_color];

}
Esempio n. 10
0
void
WndSymbolButton::OnPaint(Canvas &canvas)
{
  PixelRect rc = {
    PixelScalar(0), PixelScalar(0), PixelScalar(canvas.get_width()),
    PixelScalar(canvas.get_height())
  };

  bool pressed = is_down();

  renderer.DrawButton(canvas, rc, HasFocus(), pressed);
  // If button has text on it
  tstring caption = get_text();
  if (caption.empty())
    return;

  rc = renderer.GetDrawingRect(rc, pressed);

  canvas.SelectNullPen();
  if (!IsEnabled())
    canvas.Select(look.button.disabled.brush);
  else if (HasFocus())
    canvas.Select(look.button.focused.foreground_brush);
  else
    canvas.Select(look.button.standard.foreground_brush);

  const char ch = (char)caption[0];

  // Draw arrow symbols instead of < and >
  if (ch == '<' || ch == '>') {
    int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

    RasterPoint Arrow[3];
    Arrow[0].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
    Arrow[0].y = (rc.top + rc.bottom) / 2 + size;
    Arrow[1].x = (rc.left + rc.right) / 2 + (ch == '<' ? -size : size);
    Arrow[1].y = (rc.top + rc.bottom) / 2;
    Arrow[2].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
    Arrow[2].y = (rc.top + rc.bottom) / 2 - size;

    canvas.DrawTriangleFan(Arrow, 3);
  }

  // Draw arrow symbols instead of v and ^
  else if (ch == '^' || ch == 'v') {
    int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

    RasterPoint Arrow[3];
    Arrow[0].x = (rc.left + rc.right) / 2 +
                 size;
    Arrow[0].y = (rc.top + rc.bottom) / 2 +
                 (ch == '^' ? size : -size);
    Arrow[1].x = (rc.left + rc.right) / 2;
    Arrow[1].y = (rc.top + rc.bottom) / 2 +
                 (ch == '^' ? -size : size);
    Arrow[2].x = (rc.left + rc.right) / 2 - size;
    Arrow[2].y = (rc.top + rc.bottom) / 2 +
                 (ch == '^' ? size : -size);

    canvas.DrawTriangleFan(Arrow, 3);
  }

  // Draw symbols instead of + and -
  else if (ch == '+' || ch == '-') {
    int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

    canvas.Rectangle((rc.left + rc.right) / 2 - size,
                     (rc.top + rc.bottom) / 2 - size / 3,
                     (rc.left + rc.right) / 2 + size,
                     (rc.top + rc.bottom) / 2 + size / 3);

    if (ch == '+')
      canvas.Rectangle((rc.left + rc.right) / 2 - size / 3,
                       (rc.top + rc.bottom) / 2 - size,
                       (rc.left + rc.right) / 2 + size / 3,
                       (rc.top + rc.bottom) / 2 + size);
  }

  // Draw Fly bitmap
  else if (caption == _T("Fly")) {
    Bitmap launcher1_bitmap(IDB_LAUNCHER1);
    canvas.ClearWhite();
    if (is_down())
      canvas.invert_stretch_transparent(launcher1_bitmap, COLOR_YELLOW);
    else
      canvas.stretch_transparent(launcher1_bitmap, COLOR_BLUE);
  }

  // Draw Simulator bitmap
  else if (caption == _T("Simulator")) {
    Bitmap launcher2_bitmap(IDB_LAUNCHER2);
    canvas.ClearWhite();
    if (is_down())
      canvas.invert_stretch_transparent(launcher2_bitmap, COLOR_YELLOW);
    else
      canvas.stretch_transparent(launcher2_bitmap, COLOR_BLUE);
  }

  else if (caption == _T("Green")) {
    InflateRect(&rc, -3, -3);
    canvas.DrawFilledRectangle(rc, Color(0x74, 0xFF, 0));
  } else if (caption == _T("Blue")) {
    InflateRect(&rc, -3, -3);
    canvas.DrawFilledRectangle(rc, Color(0, 0x90, 0xFF));
  } else if (caption == _T("Magenta")) {
    InflateRect(&rc, -3, -3);
    canvas.DrawFilledRectangle(rc, Color(0xFF, 0, 0xCB));
  } else if (caption == _T("Yellow")) {
    InflateRect(&rc, -3, -3);
    canvas.DrawFilledRectangle(rc, Color(0xFF, 0xE8, 0));
  }
}
Esempio n. 11
0
	void SceneManager::run()
	{	
		m_devices->setSceneMessenger(this);
#ifdef CGE_MOBILE
       //ALLEGRO_JOYSTICK *joystick = NULL;
       // al_reconfigure_joysticks();
        //joystick=al_get_joystick(al_get_num_joysticks()-1);
#endif
        
		al_start_timer(m_gameTimer);

		//is the event handled?
		bool handled = false;
		ALLEGRO_EVENT next;
		bool skip = false;
		double numFrames = 1;
		double totalDelta = 0.0f;

		int frames = 0;
		double starttime = 0;
		bool first = true;
		float fps = 0.0f;
        
		//main loop
		while(m_gameIsRunning)
		{
			handled = false;
			al_wait_for_event(queue,&evt);

			bool hasNext = al_peek_next_event(queue,&next);
			if(hasNext && next.type == ALLEGRO_EVENT_TIMER)
			{
				al_drop_next_event(queue);
			}
			//render the scene
			if(m_canDraw && m_needsRedraw && al_is_event_queue_empty(queue))
			{
				if(skip)
					skip = false;
				else
				{
					double a = al_get_time();

					if(m_currentScene->canRender())
					{
						m_g.begin();
						m_currentScene->render();
						/*
						m_g.drawText(StringUtil::toString(fps),m_devices->getFontManager()->getDefaultFont(),agui::Color(0,0,0),-2,-2,0);
						m_g.drawText(StringUtil::toString(fps),m_devices->getFontManager()->getDefaultFont(),agui::Color(0,0,0),2,2,0);
						m_g.drawText(StringUtil::toString(fps),m_devices->getFontManager()->getDefaultFont(),agui::Color(255,255,255),0,0,0);
						*/
						if(m_needsTransition)
						{
							m_needsTransition = false;
							m_transitioning = true;
						}
						if(m_transitioning)
							m_g.drawTintedSprite(m_g.getBuffer(),
							Color(m_transitionOpacity,m_transitionOpacity,m_transitionOpacity,m_transitionOpacity),0,0,0);
						m_g.end();
					}

					double t = al_get_time();
					if (first)
					{
						frames = 0;
						starttime = t;
						first = false;
						continue;
					}
					frames++;
					if (t - starttime > 0.25 && frames > 10)
					{
						fps = (double) frames / (t - starttime);
						starttime = t;
						frames = 0;
					}
                    
					m_needsRedraw = false;
                    
                    if(!m_transitioning && m_needFirstRender) {
                        m_needFirstRender = false;
                        m_callOnNextLogic = true;
                        m_nextLogicFrames = 0;
                    }

					double delta = al_get_time() - a;
					totalDelta += delta;
					numFrames++;
					double avgDelta = totalDelta / numFrames;

					if(numFrames > 100)
					{
						numFrames = 0;
						totalDelta = 0;
					}
                    if(avgDelta > (1.0f / 40.0f) || Platf::isMini())
						skip = true;
				}
			}

			defaultBeginEventHandler(&evt);
			m_currentScene->processEvent(&evt,handled);

			//do default behavior if event was not handled by the scene
			if (!handled)
			{
				defaultEndEventHandler(&evt);
			}
			processMessages();
		}
	}
Esempio n. 12
0
Color DragData::asColor() const
{
    return Color();
}
Esempio n. 13
0
bool
TextureClientD3D11::Lock(OpenMode aMode)
{
  if (!IsAllocated()) {
    return false;
  }
  MOZ_ASSERT(!mIsLocked, "The Texture is already locked!");

  if (mTexture) {
    MOZ_ASSERT(!mTexture10);
    mIsLocked = LockD3DTexture(mTexture.get());
  } else {
    MOZ_ASSERT(!mTexture);
    mIsLocked = LockD3DTexture(mTexture10.get());
  }
  if (!mIsLocked) {
    return false;
  }

  if (NS_IsMainThread()) {
    // Make sure that successful write-lock means we will have a DrawTarget to
    // write into.
    if (aMode & OpenMode::OPEN_WRITE) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
    }

    if (mNeedsClear) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
      mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
      mNeedsClear = false;
    }
    if (mNeedsClearWhite) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
      mDrawTarget->FillRect(Rect(0, 0, GetSize().width, GetSize().height), ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
      mNeedsClearWhite = false;
    }
  }

  return true;
}
Esempio n. 14
0
	void CGDIPracticeView::OnDraw(CDC* pDC)
	{
		CClientDC dc(this);			//Client DC를 얻는다.

		// Client Rect를 얻는다.
		CRect rClientRect;
		GetClientRect(&rClientRect);

		// Bitmap 생성
		Bitmap mBitmap(rClientRect.Width(), rClientRect.Height());

		// Graphics를 얻는다.
		Graphics graphics(dc);

		// 비트맵을 메모리 내에서 그릴 그래픽 생성
		Graphics memGraphics(&mBitmap);

		// 화면을 흰색 바탕으로 그리기 위한 브러쉬
		SolidBrush drawBrush(Color(255,255,255));

		// 검은색 컬러 지정
		Color drawColor(255,0,0,0);

		// 팬 생성
		Pen drawPen(drawColor, 1);
		drawPen.SetStartCap(LineCapRound);
		drawPen.SetEndCap(LineCapRound);

		// bitmap을 흰색으로 칠한다(line같은 경우 이미지가 남기 때문에)
		memGraphics.FillRectangle(&drawBrush, 0,0,rClientRect.Width(), rClientRect.Height());

		int componentSize = m_components.GetSize();
		CString str;
		str.Format(_T("size : %d\n"), componentSize);
		TRACE(str);
		for (int i = 0; i < componentSize; i++)
		{
			// 컴포넌트의 팬 설정
			drawColor.SetFromCOLORREF(m_components.GetAt(i)->m_colorPen);
			drawPen.SetColor(drawColor);
			drawPen.SetWidth((float)m_components.GetAt(i)->m_nPenSize);

			// 얕은 복사
			CDrawComponent *component = m_components.GetAt(i);

			switch (component->m_nDrawMode)
			{
				// 지우개인 경우
			case DRAW_NONE:
				{
					// 팬의 브러쉬 색을 흰색으로 변경
					drawBrush.SetColor(drawColor);

					// 지우개를 사용한 좌표를 순차적으로 다시 그린다.
					int pointSize = component->m_points.GetSize();
					for (int j = 0; j < pointSize; j++)
					{
						// 흰색의 지우개 사각형을 그린다. 
						memGraphics.FillRectangle(&drawBrush, component->m_points.GetAt(j).X, component->m_points.GetAt(j).Y,
							component->m_nEraserSize * 2, component->m_nEraserSize * 2);
					}
					break;
				}
			case LINE_MODE:
				memGraphics.DrawLine(&drawPen, component->m_ptStart.x, component->m_ptStart.y,
					component->m_ptEnd.x, component->m_ptEnd.y);
				break;
			case RECT_MODE:
			{
				// 우측 아래
				if(component->m_ptStart.x < component->m_ptEnd.x && component->m_ptStart.y < component->m_ptEnd.y)
					memGraphics.DrawRectangle(&drawPen, component->m_ptStart.x, component->m_ptStart.y,
					component->m_ptEnd.x - component->m_ptStart.x, component->m_ptEnd.y - component->m_ptStart.y);
				// 우측 위
				else if(component->m_ptStart.x < component->m_ptEnd.x && component->m_ptStart.y > component->m_ptEnd.y)
					memGraphics.DrawRectangle(&drawPen, component->m_ptStart.x, component->m_ptEnd.y,
					component->m_ptEnd.x - component->m_ptStart.x, component->m_ptStart.y - component->m_ptEnd.y);
				// 좌측 아래
				else if(component->m_ptStart.x > component->m_ptEnd.x && component->m_ptStart.y < component->m_ptEnd.y)
					memGraphics.DrawRectangle(&drawPen, component->m_ptEnd.x, component->m_ptStart.y,
					component->m_ptStart.x - component->m_ptEnd.x, component->m_ptEnd.y - component->m_ptStart.y);
				// 좌측 위
				else
					memGraphics.DrawRectangle(&drawPen, component->m_ptEnd.x, component->m_ptEnd.y,
					component->m_ptStart.x - component->m_ptEnd.x, component->m_ptStart.y - component->m_ptEnd.y);

				break;
			}
			case CIRCLE_MODE:
				memGraphics.DrawEllipse(&drawPen, component->m_ptStart.x, component->m_ptStart.y,
					component->m_ptEnd.x - component->m_ptStart.x, component->m_ptEnd.y - component->m_ptStart.y);
				break;
			case FREE_MODE:
				if (component->m_points.GetSize() > 1)
				{
					// 자유선의 작은 선들을을 순차적으로 하나씩 그린다.
					int pointSize = component->m_points.GetSize();
					for (int j = 1; j < pointSize; j++)
						memGraphics.DrawLine(&drawPen, component->m_points.GetAt(j - 1).X, component->m_points.GetAt(j - 1).Y,
						component->m_points.GetAt(j).X, component->m_points.GetAt(j).Y);
				}
				break;
			case POLY_MODE:
			{
				int pointSize = component->m_points.GetSize();
				for (int j = 1; j < pointSize; j++)
					memGraphics.DrawLine(&drawPen, component->m_points.GetAt(j-1).X, component->m_points.GetAt(j-1).Y,
					component->m_points.GetAt(j).X, component->m_points.GetAt(j).Y);

				// 처음 점과 마지막점을 이어준다.
				memGraphics.DrawLine(&drawPen, component->m_points.GetAt(component->m_points.GetSize() - 1).X,
					component->m_points.GetAt(component->m_points.GetSize() - 1).Y,
					component->m_points.GetAt(0).X, component->m_points.GetAt(0).Y);

				break;
			}
			default:
				break;
			}
		}

		//현재 그리고 있는 것

		drawColor.SetFromCOLORREF(m_colorPen);
		drawPen.SetColor(drawColor);
		drawPen.SetWidth(m_nPenSize);

		// 왼쪽 버튼 클릭시 || 지우개인경우 | 다각형인 경우(삭제)
		if (m_nDrawMode == DRAW_NONE || m_nDrawMode == POLY_MODE || m_bLButtonDown)
		{
			switch (m_nDrawMode)
			{
			case DRAW_NONE:
				{
					// 브러쉬 흰색 설정
					drawColor.SetFromCOLORREF(RGB(255, 255, 255));
					drawBrush.SetColor(drawColor);
					// 팬 컬러 검정색 설정
					drawColor.SetFromCOLORREF(RGB(0, 0, 0));
					drawPen.SetColor(drawColor);
					drawPen.SetWidth(1);

					int pointSize = m_points.GetSize()-1;
					for (int i = 0; i < pointSize; i++)
					{
						memGraphics.FillRectangle(&drawBrush, m_points.GetAt(i).X, m_points.GetAt(i).Y,
							m_nEraserSize * 2, m_nEraserSize * 2);
					}
					memGraphics.FillRectangle(&drawBrush, m_points.GetAt(m_points.GetSize() - 1).X, m_points.GetAt(m_points.GetSize() - 1).Y,
						m_nEraserSize * 2, m_nEraserSize * 2);
					memGraphics.DrawRectangle(&drawPen, m_points.GetAt(m_points.GetSize() - 1).X, m_points.GetAt(m_points.GetSize() - 1).Y,
						m_nEraserSize * 2, m_nEraserSize * 2);

					break;
				}
			case LINE_MODE:
				memGraphics.DrawLine(&drawPen, m_ptPrev.x, m_ptPrev.y,
					m_ptDrawing.x, m_ptDrawing.y);
				break;
			case RECT_MODE:
			{
				memGraphics.DrawRectangle(&drawPen, m_ptPrev.x, m_ptPrev.y,
					m_ptDrawing.x - m_ptPrev.x, m_ptDrawing.y - m_ptPrev.y);

				// 우측 아래
				if(m_ptPrev.x < m_ptDrawing.x && m_ptPrev.y < m_ptDrawing.y)
					memGraphics.DrawRectangle(&drawPen, m_ptPrev.x, m_ptPrev.y,
					m_ptDrawing.x - m_ptPrev.x, m_ptDrawing.y - m_ptPrev.y);
				// 우측 위
				else if(m_ptPrev.x < m_ptDrawing.x && m_ptPrev.y > m_ptDrawing.y)
					memGraphics.DrawRectangle(&drawPen, m_ptPrev.x, m_ptDrawing.y,
					m_ptDrawing.x - m_ptPrev.x, m_ptPrev.y - m_ptDrawing.y);
				// 좌측 아래
				else if(m_ptPrev.x > m_ptDrawing.x && m_ptPrev.y < m_ptDrawing.y)
					memGraphics.DrawRectangle(&drawPen, m_ptDrawing.x, m_ptPrev.y,
					m_ptPrev.x - m_ptDrawing.x, m_ptDrawing.y - m_ptPrev.y);
				// 좌측 위
				else
					memGraphics.DrawRectangle(&drawPen, m_ptDrawing.x, m_ptDrawing.y,
					m_ptPrev.x - m_ptDrawing.x, m_ptPrev.y - m_ptDrawing.y);

				break;
			}
			case CIRCLE_MODE:
				memGraphics.DrawEllipse(&drawPen, m_ptPrev.x, m_ptPrev.y,
					m_ptDrawing.x - m_ptPrev.x, m_ptDrawing.y - m_ptPrev.y);
				break;
			case FREE_MODE:
				if (m_points.GetSize() > 1)
				{
					for (int i = 1; i < m_points.GetSize(); i++)
						memGraphics.DrawLine(&drawPen, m_points.GetAt(i - 1).X, m_points.GetAt(i - 1).Y,
						m_points.GetAt(i).X, m_points.GetAt(i).Y);
				}
				break;
			case POLY_MODE:
				if (m_points.GetSize() > 1)
				{
					for (int i = 1; i < m_points.GetSize(); i++)
						memGraphics.DrawLine(&drawPen, m_points.GetAt(i-1).X, m_points.GetAt(i-1).Y,
						m_points.GetAt(i).X, m_points.GetAt(i).Y);

					// 처음 점과 마지막점을 이어준다.
					memGraphics.DrawLine(&drawPen, m_points.GetAt(m_points.GetSize() - 1).X, m_points.GetAt(m_points.GetSize() - 1).Y,
						m_ptDrawing.x, m_ptDrawing.y);
				}
				else if (m_points.GetSize() == 1)
					memGraphics.DrawLine(&drawPen, m_points.GetAt(0).X, m_points.GetAt(0).Y, m_ptDrawing.x, m_ptDrawing.y);
				break;
			default:
				break;
			}
		}
		graphics.DrawImage(&mBitmap, 0, 0);
	}
Esempio n. 15
0
void RenderTarget::Draw(GLint x, GLint y, GLfloat rotation, GLfloat scaleX, GLfloat scaleY, GLfloat alpha, GLint xx, GLint yy, GLint w, GLint h)
{
	Draw(x, y, rotation, scaleX, scaleY, Color(255, 255, 255), alpha, xx, yy, w, h);
}
Esempio n. 16
0
	  1060000, 10, 17, 0, true, 0
	},{
	  Lang::SMALL_PLASMA_ACCEL,0,
	  Equip::SLOT_LASER, 9, {},
	  12000000, 22, 50, 0, true, 0
	},{
	  Lang::LARGE_PLASMA_ACCEL,0,
	  Equip::SLOT_LASER, 10, {},
	  39000000, 50, 100, 0, true, 0
	}
};

const LaserType Equip::lasers[] = {
	{
		0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0,
		Color(0.0f, 0.0f, 0.0f, 0.0f),
	},{		// 1mw pulse
		1.0f, 10000.0f, 1000.0f, 0.25f, 30.0f, 5.0f, 0,
		Color(1.0f, 0.2f, 0.2f, 1.0f),
	},{		// 1mw df pulse
		1.0f, 10000.0f, 1000.0f, 0.25f, 30.0f, 5.0f, Equip::LASER_DUAL,
		Color(1.0f, 0.2f, 0.2f, 1.0f),
	},{	// 2mw pulse
		1.0f, 10000.0f, 2000.0f, 0.25f, 30.0f, 5.0f, 0,
		Color(1.0f, 0.5f, 0.2f, 1.0f),
	},{	// 2mw rf pulse
		1.0f, 10000.0f, 2000.0f, 0.13f, 30.0f, 5.0f, 0,
		Color(1.0f, 0.5f, 0.2f, 1.0f),
	},{		// 4mw pulse
		1.0f, 10000.0f, 4000.0f, 0.25f, 30.0f, 5.0f, 0,
		Color(1.0f, 1.0f, 0.2f, 1.0f),
Esempio n. 17
0
static void WriteLog(std::string const& type, std::string const& msg, Color const& c = Color()) {
// Skip logging to file in the browser
#ifndef EMSCRIPTEN
	if (!Main_Data::GetSavePath().empty()) {
		// Only write to file when project path is initialized
		// (happens after parsing the command line)
		for (std::string& log : log_buffer) {
			output_time() << log << std::endl;
		}
		log_buffer.clear();

		// Every new message is written once to the file.
		// When it is repeated increment a counter until a different message appears,
		// then write the buffered message with the counter.
		if (msg == last_message.msg) {
			last_message.repeat++;
		} else {
			if (last_message.repeat > 0) {
				output_time() << last_message.type << ": " << last_message.msg << " [" << last_message.repeat + 1 << "x]" << std::endl;
				output_time() << type << ": " << msg << std::endl;
			} else {
				output_time() << type << ": " << msg << std::endl;
			}
			last_message.repeat = 0;
			last_message.msg = msg;
			last_message.type = type;
		}
	} else {
		// buffer log messages until file system is ready
		log_buffer.push_back(type + ": " + msg);
	}
#endif

#ifdef __ANDROID__
	__android_log_print(type == "Error" ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "EasyRPG Player", "%s", msg.c_str());
#else
	std::cerr << type << ": " << msg << std::endl;
#endif

	if (type != "Debug") {
		Graphics::GetMessageOverlay().AddMessage(msg, c);
	}
}
Esempio n. 18
0
Color ColorEsc(EscValue v)
{
	return v.IsVoid() ? Color(Null) : Color(v.GetFieldInt("r"), v.GetFieldInt("g"), v.GetFieldInt("b"));
}
Esempio n. 19
0
void Output::PostStr(std::string const& msg) {
	WriteLog("Info", msg, Color(255, 255, 255, 255));
}
Esempio n. 20
0
Color get_display_color(unsigned int i) {
  // from http://colorbrewer2.org/
  static const Color all[] = {Color(166 / 255., 206. / 255., 227. / 255.),
                              Color(31. / 255., 120. / 255., 180. / 255.),
                              Color(178. / 255., 223. / 255., 138. / 255.),
                              Color(51. / 255., 160. / 255., 44. / 255.),
                              Color(251. / 255., 154. / 255., 153. / 255.),
                              Color(227. / 255., 26. / 255., 28. / 255.),
                              Color(253. / 255., 191. / 255., 111. / 255.),
                              Color(255. / 255., 127. / 255., 0. / 255.),
                              Color(202. / 255., 178. / 255., 214. / 255.),
                              Color(106. / 255., 61. / 255., 154. / 255.),
                              Color(255. / 255., 255. / 255., 153. / 255.)};
  static const int size = sizeof(all) / sizeof(Color);
  return all[i % size];
}
Esempio n. 21
0
void CGeneralWindow::Paint(float x, float y, float w, float h)
{
	if (m_flFadeToBlack)
	{
		float flAlpha = (float)RemapVal(GameServer()->GetGameTime(), m_flFadeToBlack, m_flFadeToBlack+1.5f, 0.0, 1.0);
		glgui::CRootPanel::PaintRect(0, 0, glgui::CRootPanel::Get()->GetWidth(), glgui::CRootPanel::Get()->GetHeight(), Color(0, 0, 0, (int)(255*flAlpha)));
		return;
	}

	Rect recAntivirus = m_hAntivirus.GetArea("Antivirus");
	glgui::CBaseControl::PaintSheet(m_hAntivirus.GetSheet("Antivirus"), x, y, w, h, recAntivirus.x, recAntivirus.y, recAntivirus.w, recAntivirus.h, m_hAntivirus.GetSheetWidth("Antivirus"), m_hAntivirus.GetSheetHeight("Antivirus"));

	BaseClass::Paint(x, y, w, h);

	if (!m_sEmotion.length())
		return;

	CGameRenderingContext c(GameServer()->GetRenderer(), true);
	c.SetBlend(BLEND_ALPHA);
	c.SetColor(Color(255, 255, 255, 255));

	Rect recEmotion = m_hGeneral.GetArea(m_sEmotion);
	glgui::CBaseControl::PaintSheet(m_hGeneral.GetSheet(m_sEmotion), x, y, 256, 256, recEmotion.x, recEmotion.y, recEmotion.w, recEmotion.h, m_hGeneral.GetSheetWidth(m_sEmotion), m_hGeneral.GetSheetHeight(m_sEmotion));

	if ((m_bHelperSpeaking || m_bProgressBar) && Oscillate((float)GameServer()->GetGameTime(), 0.2f) > 0.5)
	{
		Rect recMouth = m_hGeneralMouth.GetArea(m_sEmotion);
		glgui::CBaseControl::PaintSheet(m_hGeneralMouth.GetSheet(m_sEmotion), x, y, 256, 256, recMouth.x, recMouth.y, recMouth.w, recMouth.h, m_hGeneralMouth.GetSheetWidth(m_sEmotion), m_hGeneralMouth.GetSheetHeight(m_sEmotion));
	}

	if (m_bProgressBar)
	{
		double flTime = 3;
		glgui::CBaseControl::PaintRect(x + m_pText->GetLeft(), y + 160, m_pText->GetWidth(), 10, Color(255, 255, 255, 255));
		glgui::CBaseControl::PaintRect(x + m_pText->GetLeft() + 2, y + 160 + 2, ((m_pText->GetWidth() - 4) * (float)RemapValClamped(GameServer()->GetGameTime(), m_flStartTime, m_flStartTime+flTime, 0.0, 1.0)), 10 - 4, Color(42, 65, 122, 255));

		static tstring sEstimate;
		static double flLastEstimateUpdate = 0;

		if (!sEstimate.length() || GameServer()->GetGameTime() - flLastEstimateUpdate > 1)
		{
			int iRandomTime = RandomInt(0, 5);
			tstring sRandomTime;
			if (iRandomTime == 0)
				sRandomTime = "centuries";
			else if (iRandomTime == 1)
				sRandomTime = "minutes";
			else if (iRandomTime == 2)
				sRandomTime = "hours";
			else if (iRandomTime == 3)
				sRandomTime = "days";
			else
				sRandomTime = "seconds";

			sEstimate = tsprintf(tstring("Estimated time remaining: %d %s"), RandomInt(2, 100), sRandomTime.c_str());

			flLastEstimateUpdate = GameServer()->GetGameTime();
		}

		float flWidth = glgui::RootPanel()->GetTextWidth(sEstimate, sEstimate.length(), "sans-serif", 12);
		glgui::CLabel::PaintText(sEstimate, sEstimate.length(), "sans-serif", 12, x + m_pText->GetLeft() + m_pText->GetWidth()/2 - flWidth/2, (float)y + 190, Color(0, 0, 0, 255));
	}
}
Esempio n. 22
0
Color get_gray_color(double f) {
  static Color colors[] = {Color(0, 0, 0), Color(1, 1, 1)};
  return get_color_map_color(f, colors, sizeof(colors) / sizeof(Color));
}
Esempio n. 23
0
void ButtonGadget::onRender( RenderContext & context, const RectInt & window )
{
	WindowButton::onRender( context, window );

	// get a pointer to our gadget
	NounGadget * pGadget = m_Gadget;
	if ( pGadget != NULL )
	{
		DisplayDevice * pDisplay = context.display();
		ASSERT( pDisplay );
		GameDocument * pDoc = (GameDocument *)document();
		ASSERT( pDoc );
		WindowStyle * pStyle = windowStyle();
		ASSERT( pStyle );
		Font * pFont = pStyle->font();
		ASSERT( pFont );

		// display bar if gadget has delay before usabled
		int delay = pGadget->usableWhen();
		if ( delay > 0 )
		{
			if ( (pDoc->tick() % 10) < 6 )		// make the bar blink
			{
				RectInt bar( window.left, window.top, 
					window.right - ((window.width() * delay) / 100), window.top + 16 );

				PrimitiveMaterial::push( pDisplay, PrimitiveMaterial::ADDITIVE );
				PrimitiveWindow::push( pDisplay, bar, WINDOW_UV, Color(0,0,255,255) );
			}			
		}

		// draw the gadget icon
		Material * pIcon = pGadget->icon();
		if ( pIcon != NULL )
		{
			RectInt iconBox( PointInt( window.left, window.top ), SizeInt( 32, 16 ) );

			Material::push( context, pIcon );
			PrimitiveWindow::push( pDisplay, iconBox, WINDOW_UV, m_IconColor );
		}

		// display any gadget status text
		WideString sStatus( pGadget->status() );
		if ( sStatus.length() > 0 )
		{
			SizeInt stringSize( pFont->size( sStatus ) );
			Font::push( pDisplay, pFont, PointInt( window.m_Right - stringSize.width, window.top ), sStatus, YELLOW );
		}

		// display hotkey in lower-left corner of button
		CharString sHotKey;
		if ( pGadget->hotkey() != 0 && pGadget->hotkey() != HK_SPACE )
			sHotKey += keyText( Keyboard::unmap( pGadget->hotkey() ) );

		if ( m_Gadget->group() != 0 )
			sHotKey += CharString().format(" %c", m_Gadget->group() );

		if ( WidgetCast<GadgetBeamWeapon>( pGadget ) && ((GadgetBeamWeapon *)pGadget)->pointDefense() )
			sHotKey += " PD";

		if ( sHotKey.length() > 0 )
		{
			WideString sWide = sHotKey;
			SizeInt stringSize( pFont->size( sWide ) );

			Font::push( pDisplay, pFont, PointInt( window.m_Right - stringSize.width, window.m_Bottom - stringSize.height ), 
				sWide, YELLOW );
		}

		// display the damage bar
		if ( pGadget->damage() > 0 )
		{
			if ( (pDoc->tick() % 10) < 6 )		// make the bar blink
			{
				float damage = pGadget->damageRatioInv();
				RectInt bar( window.m_Left, window.m_Bottom + 1, 
					window.m_Right - (window.width() * (1.0f - damage)), window.m_Bottom + 3 );

				Color barColor( 255 * (1.0f - damage), 255 * damage,0,255 );
				PrimitiveMaterial::push( pDisplay, PrimitiveMaterial::NONE );
				PrimitiveWindow::push( pDisplay, bar, WINDOW_UV, barColor );
			}
		}

		// blink a white border if this is the current target
		if ( pDoc->target() == m_Gadget && (pDoc->tick() % 10) < 6 )
			renderGlow( context );
	}
}
Esempio n. 24
0
Color get_gnuplot_color(double f) {
  static Color colors[] = {Color(0, 0, 0),   Color(.5, 0, 1),
                           Color(.6, 0, .6), Color(.75, .25, 0),
                           Color(.9, .5, 0), Color(1, 1, 0)};
  return get_color_map_color(f, colors, sizeof(colors) / sizeof(Color));
}
Esempio n. 25
0
void ControlsFactory::CustomizeFontLight(Font *font)
{
    font->SetSize(12);
    font->SetColor(Color(1.0f, 1.0f, 1.0f, 1.0f));
}
Esempio n. 26
0
void Init( HWND hWnd )				// Note: init gets called before window is created so need to pass hWnd
{
	int i;
	Contour *contour;
	Point *p;
														// debugging variables/flags
	totalTime1 = 0;
	nTime1 = 0;
	totalTime2 = 0;
	nTime2 = 0;
	totalTime3 = 0;
	nTime3 = 0;
	debugit = 0;
	debugLogFile = INVALID_HANDLE_VALUE;				// disable debug logging
	
	srand(GetTickCount());			// randomize seed of random number generator

	appWnd = hWnd;					// remember main Window handle
	WindowWasMaximized = false;

	InitCommonControls();			// common controls used: PropertySheet, ListView, ImageList, HotKey, ColorDialog
	
	AbortRender = false;
	AbortThumbs = false;
	AbortObject = false;
	AbortDistances = false;
	Abort3D = false;
	hRenderThread = NULL;			// clear thread handles while not active
	hThumbsThread = NULL;
	hObjectListThread = NULL;
	hDistanceListThread = NULL;
	hGenerate3DThread = NULL;

	strcpy(BaseName,"aSeries\0");
	strcpy(FindString,"\0");
	ExpandEnvironmentStrings("%HOMEPATH%",WorkingPath,MAX_PATH);
	SkipAllMissing = false;
	HideAllDomains = false;
	CurrSeries = NULL;
	CurrSectionsInfo = NULL;
	CurrSection = NULL;
	CurrView = NULL;
	PrevSection = NULL;
	PrevView = NULL;
	DomainSection = NULL;
	DomainView = NULL;
	FrontView = NULL;
	BackView = NULL;
	BlendView = NULL;
	CurrContour = NULL;
	CurrDomain = NULL;
	ClipboardTransform = NULL;

	toolbarWindow = NULL;								// tool window variables
	ToolButtons = NULL;									// buttons are created when window is created
	highlightedToolButton = NULL;						// none highlighted initially
	CurrentTool = ARROW_TOOL;
	RToolActive = false;
	LToolActive = false;
	ToolContour = NULL;
	EditContour = NULL;
	statusbarWindow = NULL;
	dragPen = NULL;

	CmRestoreToolbar();									// create toolbar and statusbar windows...
	CmStatusBar();

	openGLWindow = NULL;								// ...but not openGL...
	openGL_LToolActive = false;
	openGL_RToolActive = false;
	openGL_ortho = false;
	openGLanimated = true;
	CurrScene = NULL;
	distanceWindow = NULL;
	zTraceWindow = NULL;
	objectWindow = NULL;
	CurrObjects = NULL;
	InterObjectDistances = NULL;
	sectionWindow = NULL;								// ...or other doubleing windows or dialogs
	thumbnailWindow = NULL;
	ThumbButtons = NULL;
	PassbackButtons = NULL;
	domainWindow = NULL;
	traceWindow = NULL;
	CurrContours = NULL;
	paletteWindow = NULL;
	PaletteButtons = NULL;
	DefaultPaletteButtons = NULL;
	highlightedPaletteButton = NULL;
	PaintingViews = false;
	ImagePixelSize = 0.00254;							// more dialog elements defaults
	ImageBrightness = 0.0;
	ImageContrast = 1.0;
	RenderWindow = false;
	RenderJPEG = false;
	RenderFill = false;
	RenderTraces = false;
	JPEGquality = 80;
	CopyFiles = true;									// initialize custom colors (will load these later from Series)
	for (i=0; i<16; i++)
		CustomColors[i] = RGB( 0, 0, 0 );
	GlobalId = 0;
	Precision = 6;
	LastOptionTab = 0;
	CalibrationScope = APPLY_TRACES;
														// use fullsize buttons at 120 dpi
	appDC = GetDC( appWnd );
	ButtonSize = BUTTON_SIZE*GetDeviceCaps( appDC, LOGPIXELSX )/120;
	ReleaseDC( appWnd, appDC );

	ScrollOccurred = false;
	Scrolling = false;
	AutoSimplify = true;
	AutoShrinkBack = false;
	UsePrecisionCursor = false;
	AutoTrace = 0;
	AutoAdjustThreshold = false;
	
	SimplifyResolution = -ImagePixelSize;
	ApplyZOffset3D = false;
	OffsetZTrace1 = NULL;
	OffsetZTrace2 = NULL;
														// load lock/unlock bitmaps for status bar
	lockBitmap = LoadBitmap(appInstance, "LockBitmap");
	unlockBitmap = LoadBitmap(appInstance, "UnlockBitmap");

														// keyboard movement options
	LastAdjustment = NULL;
	Recording = NULL;
	UseDeformKeys = false;
												// set strings for list row limits to allow all names
	strcpy(limitSectionList,"*\0");
	strcpy(limitDomainList,"*\0");
	strcpy(limitTraceList,"*\0");
	strcpy(limitObjectList,"*\0");
	strcpy(limitLeftDistanceList,"*\0");
	strcpy(limitRightDistanceList,"*\0");
	strcpy(limitZTraceList,"*\0");

	PointContours = new Contours();				// set pixel offset values for stamp tool contours
	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"a$+");						// orange
	contour->mode = R2_COPYPEN;
	contour->simplified = true;
	contour->border = Color( 1.0, 0.5, 0.0 );
	contour->fill = Color( 1.0, 0.5, 0.0 );
	contour->points = new Points();						// hexagonal shape
	int hexagon[] = { -3, 1, -3, -1, -1, -3, 1, -3, 3, -1, 3, 1, 1, 3, -1, 3 };
	for ( i=0; i<16; i=i+2 )
		{
		p = new Point((double)hexagon[i],(double)hexagon[i+1],0.0);
		contour->points->Add(p);
		}

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"b$+");						// purple
	contour->mode = R2_COPYPEN;
	contour->simplified = true;
	contour->border = Color( 0.5, 0.0, 1.0 );
	contour->fill = Color( 0.5, 0.0, 1.0 );
	contour->points = new Points();						// 8-star shape
	int star[] = { -4, 4, -1, 2, 0, 5, 1, 2, 4, 4, 2, 1, 5, 0, 2, -1, 4, -4, 1, -2, 0, -5, -1, -2, -4, -4, -2, -1, -5, 0, -2, 1 };
	for ( i=0; i<32; i=i+2 )
		{
		p = new Point((double)star[i],(double)star[i+1],0.0);
		contour->points->Add(p);
		}
	contour->Reverse();									// make for clockwise creation

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"pink$+");					// pink
	contour->mode = -R2_COPYPEN;
	contour->simplified = true;
	contour->border = Color( 1.0, 0.0, 0.5 );
	contour->fill = Color( 1.0, 0.0, 0.5 );
	contour->points = new Points();						// trianglar shape
	int triangle[] = { -6, -6, 6, -6, 0, 5 };
	for ( i=0; i<6; i=i+2 )
		{
		p = new Point((double)triangle[i],(double)triangle[i+1],0.0);
		contour->points->Add(p);
		}

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"X$+");
	contour->mode = -R2_COPYPEN;
	contour->simplified = true;
	contour->border = Color( 1.0, 0.0, 0.0 );			// red
	contour->fill = Color( 1.0, 0.0, 0.0 );
	contour->points = new Points();						// x shape
	int x[] = { -7, 7, -2, 0, -7, -7, -4, -7, 0, -1, 4, -7, 7, -7, 2, 0, 7, 7, 4, 7, 0, 1, -4, 7 };
	for ( i=0; i<24; i=i+2 )
		{
		p = new Point((double)x[i],(double)x[i+1],0.0);
		contour->points->Add(p);
		}

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"yellow$+");					// yellow
	contour->mode = -R2_COPYPEN;
	contour->simplified = true;
	contour->border = Color( 1.0, 1.0, 0.0 );
	contour->fill = Color( 1.0, 1.0, 0.0 );
	contour->points = new Points();						// square annulus shape
	int square[] = { -4, 4, -5, 5, 5, 5, 5, -5, -5, -5, -5, 4, -4, 3, -4, -4, 4, -4, 4, 4 };
	for ( i=0; i<20; i=i+2 )
		{
		p = new Point((double)square[i],(double)square[i+1],0.0);
		contour->points->Add(p);
		}
	contour->Reverse();									// make for clockwise creation
	contour->Scale( 2.0 );								// double in size

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"blue$+");					// blue
	contour->mode = R2_MASKPEN;
	contour->simplified = true;
	contour->border = Color( 0.0, 0.0, 1.0 );
	contour->fill = Color( 0.0, 0.0, 1.0 );
	contour->points = new Points();						// diamond shape
	int diamond[] = { 0, 7, -7, 0, 0, -7, 7, 0 };
	for ( i=0; i<8; i=i+2 )
		{
		p = new Point((double)diamond[i],(double)diamond[i+1],0.0);
		contour->points->Add(p);
		}

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"magenta$+");
	contour->mode = R2_MASKPEN;
	contour->simplified = true;
	contour->border = Color( 1.0, 0.0, 1.0 );			// magenta
	contour->fill = Color( 1.0, 0.0, 1.0 );
	contour->points = new Points();						// larger hexagonal shape
	for ( i=0; i<16; i=i+2 )
		{
		p = new Point((double)hexagon[i],(double)hexagon[i+1],0.0);
		contour->points->Add(p);
		}
	contour->Scale( 2.0 );								// double in size

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"red$+");						// red
	contour->mode = R2_MASKPEN;
	contour->simplified = true;
	contour->border = Color( 1.0, 0.0, 0.0 );
	contour->fill = Color( 1.0, 0.0, 0.0 );
	contour->points = new Points();						// curved arrow shape
	int curved[] = { -1, -4, -4, -2, -2, -2, -2, 0, -1, 2, 1, 4, 2, 2, 4, 1, 1, 0, 0, -1, 0, -2, 2, -2 };
	for ( i=0; i<24; i=i+2 )
		{
		p = new Point((double)curved[i],(double)curved[i+1],0.0);
		contour->points->Add(p);
		}
	contour->Reverse();									// make for clockwise creation
	contour->Scale( 3.0 );								// triple in size

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"green$+");
	contour->mode = R2_MASKPEN;
	contour->simplified = true;
	contour->border = Color( 0.0, 1.0, 0.0 );			// yellow
	contour->fill = Color( 0.0, 1.0, 0.0 );
	contour->points = new Points();						// large cross shape
	int cross[] = { -3, 1, -3, -1, -1, -1, -1, -3, 1, -3, 1, -1, 3, -1, 3, 1, 1, 1, 1, 3, -1, 3, -1, 1 };
	for ( i=0; i<24; i=i+2 )
		{
		p = new Point((double)cross[i],(double)cross[i+1],0.0);
		contour->points->Add(p);
		}
	contour->Scale( 4.0 );								// double in size

	contour = new Contour();
	PointContours->Add( contour );
	sprintf(contour->name,"cyan$+");
	contour->mode = R2_MASKPEN;
	contour->simplified = true;
	contour->border = Color( 0.0, 1.0, 1.0 );			// green
	contour->fill = Color( 0.0, 1.0, 1.0 );
	contour->points = new Points();						// large arrow shape
	int arrow[] = { 0, 3, 1, 2, -3, -2, -2, -3, 2, 1, 3, 0, 3, 3 };
	for ( i=0; i<14; i=i+2 )
		{
		p = new Point((double)arrow[i],(double)arrow[i+1],0.0);
		contour->points->Add(p);
		}
	contour->Scale( 4.0 );								// quadruple in size

														// finally setup stamp tool contour and cursor
	StampContour = new Contour( *(PointContours->first) );
	StampCursor = MakeStampCursor( StampContour );
}
Esempio n. 27
0
void ControlsFactory::CustomizeFontError(Font *font)
{
    font->SetSize(20);
    font->SetColor(Color(1.0f, 0.0f, 0.0f, 0.8f));
}
Esempio n. 28
0
void CanvasItem::_bind_methods() {

	ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children);
	ObjectTypeDB::bind_method(_MD("_raise_self"),&CanvasItem::_raise_self);
	ObjectTypeDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback);
	ObjectTypeDB::bind_method(_MD("_set_visible_"),&CanvasItem::_set_visible_);
	ObjectTypeDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_);

	ObjectTypeDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state);
	ObjectTypeDB::bind_method(_MD("edit_get"),&CanvasItem::edit_get_state);
	ObjectTypeDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect);
	ObjectTypeDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate);

	ObjectTypeDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect);
	//ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
	ObjectTypeDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item);

	ObjectTypeDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible);
	ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden);
	ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show);
	ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide);

	ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update);

	ObjectTypeDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel);
	ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel);

	ObjectTypeDB::bind_method(_MD("set_blend_mode","blend_mode"),&CanvasItem::set_blend_mode);
	ObjectTypeDB::bind_method(_MD("get_blend_mode"),&CanvasItem::get_blend_mode);

	ObjectTypeDB::bind_method(_MD("set_opacity","opacity"),&CanvasItem::set_opacity);
	ObjectTypeDB::bind_method(_MD("get_opacity"),&CanvasItem::get_opacity);
	ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity);
	ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity);

	ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enabe"),&CanvasItem::set_draw_behind_parent);
	ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled);

	ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
	ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top);
#ifdef TOOLS_ENABLED
	ObjectTypeDB::bind_method(_MD("_shader_changed"),&CanvasItem::_shader_changed);
#endif
	//ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);

	ObjectTypeDB::bind_method(_MD("draw_line","from","to","color","width"),&CanvasItem::draw_line,DEFVAL(1.0));
	ObjectTypeDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect);
	ObjectTypeDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle);
	ObjectTypeDB::bind_method(_MD("draw_texture","texture:Texture","pos"),&CanvasItem::draw_texture);
	ObjectTypeDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate"),&CanvasItem::draw_texture_rect,DEFVAL(false),DEFVAL(Color(1,1,1)));
	ObjectTypeDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)));
	ObjectTypeDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box);
	ObjectTypeDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Array()),DEFVAL(Ref<Texture>()),DEFVAL(1.0));
	ObjectTypeDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(Array()),DEFVAL(Ref<Texture>()));
	ObjectTypeDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(Array()),DEFVAL(Ref<Texture>()));
	ObjectTypeDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1));
	ObjectTypeDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1)));

	ObjectTypeDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform);
	ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
	ObjectTypeDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform);
	ObjectTypeDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
	ObjectTypeDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
	ObjectTypeDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas);
	ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
	//ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);

	ObjectTypeDB::bind_method(_MD("set_shader","shader"),&CanvasItem::set_shader);
	ObjectTypeDB::bind_method(_MD("get_shader"),&CanvasItem::get_shader);
	ObjectTypeDB::bind_method(_MD("set_use_parent_shader","enable"),&CanvasItem::set_use_parent_shader);
	ObjectTypeDB::bind_method(_MD("get_use_parent_shader"),&CanvasItem::get_use_parent_shader);

	BIND_VMETHOD(MethodInfo("_draw"));

	ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
	ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") );
	ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") );
	ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
	ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility

	ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
	ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"shader/shader",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph"), _SCS("set_shader"),_SCS("get_shader") );
	ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"shader/use_parent"), _SCS("set_use_parent_shader"),_SCS("get_use_parent_shader") );
	//exporting these two things doesn't really make much sense i think
	//ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
	//ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));

	ADD_SIGNAL( MethodInfo("draw") );
	ADD_SIGNAL( MethodInfo("visibility_changed") );
	ADD_SIGNAL( MethodInfo("hide") );
	ADD_SIGNAL( MethodInfo("item_rect_changed") );



	BIND_CONSTANT( BLEND_MODE_MIX );
	BIND_CONSTANT( BLEND_MODE_ADD );
	BIND_CONSTANT( BLEND_MODE_SUB );
	BIND_CONSTANT( BLEND_MODE_MUL );
	BIND_CONSTANT( BLEND_MODE_PREMULT_ALPHA );


	BIND_CONSTANT( NOTIFICATION_DRAW);
	BIND_CONSTANT( NOTIFICATION_VISIBILITY_CHANGED );
	BIND_CONSTANT( NOTIFICATION_ENTER_CANVAS );
	BIND_CONSTANT( NOTIFICATION_EXIT_CANVAS );
	BIND_CONSTANT( NOTIFICATION_TRANSFORM_CHANGED );


}
Esempio n. 29
0
UIControl * ControlsFactory::CreateLine(const Rect & rect)
{
    return CreateLine(rect, Color(0.8f, 0.8f, 0.8f, 1.0f));
}
	/** Converts @a color to a max color. @a color must be valid.*/
	Color toMaxColor( const COLLADAFW::Color& color )
	{
		assert(color.isValid());
		return Color(color.getRed(), color.getGreen(), color.getBlue());
	}