Ejemplo n.º 1
0
Label::Label(string lText, int x_, int y_, int width_, int height_, const Font *font_, bool animation_, float animationSpeed_, int indent_, bool align_)
{
    // Coords
    setX(x_);
    setY(y_);

    // Width / Height
    setWidth(width_);
    setHeight(height_);

    // Texts
    setText(lText);

    // Indent
    setIndent(indent_);

    // Animation
    setAnimation(animation_);

    // Invisible
    setAnimatonValue(0.0f);

    if(animation_)
    {
        // Speed
        setAnimationSpeed(animationSpeed_);
    }
    else
    {
        // Speed
        setAnimationSpeed(0.0f);
    }

    // Align
    setAlign(align_);

    // Font Id
    font = (Font*)font_;

    // Timer
    animationTimer = new Timer(animationSpeed_);
}
Ejemplo n.º 2
0
void Texture::create2DTexture() {
	// Bind the texture
	glBindTexture(GL_TEXTURE_2D, _textureID);

	// Edge wrap mode
	setWrap(GL_TEXTURE_2D, GL_REPEAT, GL_REPEAT);

	// Pixel row alignment
	setAlign();

	// Filter method
	setFilter(GL_TEXTURE_2D);

	// Mip map parameters
	setMipMaps(GL_TEXTURE_2D);

	// Texture image data
	for (size_t i = 0; i < _image->getMipMapCount(); i++)
		setMipMapData(GL_TEXTURE_2D, 0, i);
}
Ejemplo n.º 3
0
void LinkLabel::setLook(LinkLook *look) // FIXME: called externaly (so, without setLink()) it's buggy (icon not
{
    m_look = look;

    QFont font;
    font.setBold(look->bold());
    font.setUnderline(look->underlineOutside());
    font.setItalic(look->italic());
    m_title->setFont(font);
    QPalette palette;
    if (m_isSelected)
        palette.setColor(m_title->foregroundRole(), KApplication::palette().color(QPalette::Text));
    else
        palette.setColor(m_title->foregroundRole(), look->effectiveColor());

    m_title->setPalette(palette);


    m_icon->setVisible(m_icon->pixmap() && ! m_icon->pixmap()->isNull());

    setAlign(m_hAlign, m_vAlign);
}
Ejemplo n.º 4
0
void Element::xmlConfigure(xmlNode *fNode)
{
    while (fNode) {
       if (!strcmp((char *) fNode->name, "Dimensions") && fNode->children) {
          xmlNode *t = fNode->children->next;
          while (t) {
             if (!strcmp((char *) t->name, "Width") && t->children) {
                mDimensions.w = atoi((char *) t->children->content);
             } else if (!strcmp((char *) t->name, "Height") && t->children) {
                mDimensions.h = atoi((char *) t->children->content);
             } else if (!strcmp((char *) t->name, "Top") && t->children) {
                mDimensions.y = atoi((char *) t->children->content);
             } else if (!strcmp((char *) t->name, "Left") && t->children) {
                mDimensions.x = atoi((char *) t->children->content);
             }
             t = t->next;
          }
       } else if (!strcmp((char *) fNode->name, "Layer") && fNode->children) {
          setLayer(atoi((char *) fNode->children->content));
       } else if (!strcmp((char *) fNode->name, "SkinID") && fNode->children) {
          setSkinID((char *) fNode->children->content);
       } else if (!strcmp((char *) fNode->name, "Resource") && fNode->children) {
          setResourceName((char *) fNode->children->content);
       } else if (!strcmp((char *) fNode->name, "Content") && fNode->children && fNode->children->content) {
          if (!strcmp((char *) fNode->children->content, "BackgroundImage")) {
             setContent(CONTENT_BACKGROUND_IMAGE);
          } else if (!strcmp((char *) fNode->children->content, "MenuEntryBG")) {
             setContent(CONTENT_MENUENTRY_BG);
          } else if (!strcmp((char *) fNode->children->content, "MenuEntrySelectedBG")) {
             setContent(CONTENT_MENUENTRY_SELECTED_BG);
          } else if (!strcmp((char *) fNode->children->content, "MenuFont")) {
             setContent(CONTENT_MENUFONT);
          } else if (!strcmp((char *) fNode->children->content, "MenuSelectedFont")) {
             setContent(CONTENT_MENUFONT_SELECTED);
          } else if (!strcmp((char *) fNode->children->content, "MenuBrowseSound")) {
             setContent(CONTENT_MENUBROWSE_SOUND);
          } else if (!strcmp((char *) fNode->children->content, "MenuSelectSound")) {
             setContent(CONTENT_MENUSELECT_SOUND);
          } else if (!strcmp((char *) fNode->children->content, "Menu")) {
             setContent(CONTENT_MENU);
          } else if (!strcmp((char *) fNode->children->content, "BoardTemp")) {
	     setContent(CONTENT_BOARDTEMP);
	  } else if (!strcmp((char *) fNode->children->content, "CPUTemp")) {
	     setContent(CONTENT_CPUTEMP);
	  } else if (!strcmp((char *) fNode->children->content, "TrayState")) {
	     setContent(CONTENT_TRAYSTATE);
	  } else if (!strcmp((char *) fNode->children->content, "FanSpeed")) {
	     setContent(CONTENT_FANSPEED);
	  } else if (!strcmp((char *) fNode->children->content, "MessageText")) {
             setContent(CONTENT_MESSAGETEXT);
          } else if (!strcmp((char *) fNode->children->content, "MessageTitle")) {
             setContent(CONTENT_MESSAGETITLE);
          } else if (!strcmp((char *) fNode->children->content, "MessageBackground")) {
             setContent(CONTENT_MESSAGEBACKGROUND);
          } else if (!strcmp((char *) fNode->children->content, "QuestionText")) {
             setContent(CONTENT_QUESTIONTEXT);
          } else if (!strcmp((char *) fNode->children->content, "QuestionTitle")) {
             setContent(CONTENT_QUESTIONTITLE);
          } else if (!strcmp((char *) fNode->children->content, "QuestionBackground")) {
             setContent(CONTENT_QUESTIONBACKGROUND);
          } else if (!strcmp((char *) fNode->children->content, "QuestionTimer")) {
	     setContent(CONTENT_QUESTIONTIMER);
	  } else if (!strcmp((char *) fNode->children->content, "Status")) {
             setContent(CONTENT_STATUS);
          } else if (!strcmp((char *) fNode->children->content, "ProgressBarBackground")) {
	     setContent(CONTENT_PROGRESSBACKGROUND);
	  } else if (!strcmp((char *) fNode->children->content, "ProgressBarPercent")) {
	     setContent(CONTENT_PROGRESSTEXT);
	  } else if (!strcmp((char *) fNode->children->content, "ProgressBarTitle")) {
	     setContent(CONTENT_PROGRESSTITLE);
	  } else if (!strcmp((char *) fNode->children->content, "ProgressBar")) {
	     setContent(CONTENT_PROGRESSBAR);
	  } else if (!strcmp((char *) fNode->children->content, "ProgressBarText")) {
	     setContent(CONTENT_PROGRESSMESSAGE);
	  }
       } else if (!strcmp((char *) fNode->name, "Color") && fNode->children) {
          xmlNode *t = fNode->children->next;
	  SDL_Color j;
	  memset(&j, 0x00, sizeof(SDL_Color));
	  while (t) {
	     if (!strcmp((char *) t->name, "Red") && t->children) {
	        j.r = atoi((char *) t->children->content);
             } else if (!strcmp((char *) t->name, "Green") && t->children) {
	        j.g = atoi((char *) t->children->content);
             } else if (!strcmp((char *) t->name, "Blue") && t->children) {
	        j.b = atoi((char *) t->children->content);
             } else if (!strcmp((char *) t->name, "Alpha") && t->children) {
	        j.unused = atoi((char *) t->children->content);
             }
	     t = t->next;
	  }
	  
	  
          setColor(j);
       } else if (!strcmp((char *) fNode->name, "Align") && fNode->children) {
          if (!strcmp((char *) fNode->children->content, "Center") || !strcmp((char *) fNode->children->content, "Centre")) {
             setAlign(Align_Center);
          } else if (!strcmp((char *) fNode->children->content, "Left")) {
             setAlign(Align_Left);
          } else if (!strcmp((char *) fNode->children->content, "Right")) {
             setAlign(Align_Right);
          }
       } else if (!strcmp((char *) fNode->name, "Rotation") && fNode->children) {
          setRotation(atoi((char *) fNode->children->content));
       }
       fNode = fNode->next;
    }
}
Ejemplo n.º 5
0
RadioButton::RadioButton(const std::string& text, int radioGroup, WidgetType drawType)
  : ButtonBase(text, kRadioWidget, kRadioWidget, drawType)
{
  setAlign(LEFT | MIDDLE);
  setRadioGroup(radioGroup);
}
Ejemplo n.º 6
0
CheckBox::CheckBox(const std::string& text, WidgetType drawType)
  : ButtonBase(text, kCheckWidget, kCheckWidget, drawType)
{
  setAlign(LEFT | MIDDLE);
}
Ejemplo n.º 7
0
Button::Button(const std::string& text)
  : ButtonBase(text, kButtonWidget, kButtonWidget, kButtonWidget)
{
  setAlign(CENTER | MIDDLE);
}
Ejemplo n.º 8
0
ImageView::ImageView(BITMAP* bmp, int align)
 : Widget(kImageViewWidget)
{
  setAlign(align);
}
Ejemplo n.º 9
0
Alert* Alert::create()
{
    //usual cocos create, note that I'm skipping handling errors. should fix that
    Alert* alert = new (std::nothrow) Alert();
    if (alert && alert->init())
    {
        alert->autorelease();
    }

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Size node_size = visibleSize*0.80f;
    alert->setContentSize(node_size);
    alert->setLayoutType(ui::Layout::Type::RELATIVE);

    //alert->setBackGroundColor(Color3B::BLACK);
    //alert->setBackGroundColorOpacity(255/1.5);
    //alert->setBackGroundColorType(ui::LayoutBackGroundColorType::SOLID);

    alert->setBackGroundImage("main_UI_export_10_x4.png", TextureResType::PLIST);
    alert->setBackGroundImageScale9Enabled(true);
    alert->setBackGroundImageColor(Color3B(114, 160, 72));
    //alert->setBackGroundImageOpacity(200.0f);
    //layout->setClippingEnabled(true);

    auto create_txt = [&](std::string msg, ui::RelativeLayoutParameter* param) {
        auto txt = ui::Text::create(msg, DEFAULT_FONT, sx(25.0f));
        Label* lbl = (Label*)txt->getVirtualRenderer();
        lbl->getFontAtlas()->setAliasTexParameters();
        txt->setTextColor(Color4B::BLACK);
        //txt->enableOutline(Color4B::BLACK, 2);

        txt->ignoreContentAdaptWithSize(false); //word wrap or something

        alert->addChild(txt);

        txt->setLayoutParameter(param);
        return txt;
    };

    auto header_param = ui::RelativeLayoutParameter::create();
    header_param->setRelativeName("header_param");
    header_param->setAlign(ui::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL);
    header_param->setMargin(ui::Margin(sx(10), sy(30), sx(10), sy(10)));

    alert->header_txt = create_txt("Title Here", header_param);

    auto sub_header_param = ui::RelativeLayoutParameter::create();
    sub_header_param->setRelativeName("sub_header_param");
    sub_header_param->setAlign(ui::RelativeAlign::LOCATION_BELOW_CENTER);
    sub_header_param->setMargin(ui::Margin(sx(10), sy(10), sx(10), sy(10)));

    alert->sub_header_txt = create_txt("Sub header", sub_header_param);
    sub_header_param->setRelativeToWidgetName("header_param");

    auto body_param = ui::RelativeLayoutParameter::create();
    body_param->setAlign(ui::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL);
    body_param->setMargin(ui::Margin(sx(30), sy(10), sx(10), sy(10)));
    alert->body_txt = create_txt("Body content", body_param);

    Size body_size = alert->body_txt->getAutoRenderSize();
    alert->body_txt->setTextAreaSize(Size(
        body_size.width,
        body_size.height
    ));


    auto close_btn = ui::Button::create();
    close_btn->addTouchEventListener([alert](Ref*, TouchEventType type)
    {
        if (type == TouchEventType::ENDED)
        {
            Size visibleSize = Director::getInstance()->getVisibleSize();
            Vec2 origin = Director::getInstance()->getVisibleOrigin();

            Vec2 pos = Vec2(
                origin.x + visibleSize.width - 20,
                origin.y + 20
                );
            alert->shrink_close(pos);
        };

    });

    close_btn->setTitleText("X");
    close_btn->setTitleColor(Color3B::RED);
    close_btn->setTitleFontSize(sx(40.0f));
    close_btn->getTitleRenderer()->enableOutline(Color4B::GRAY, 10);
    close_btn->setScaleX(sx(1.0f));
    close_btn->setScaleY(sy(1.0f));
    alert->close_btn = close_btn;

    ui::RelativeLayoutParameter* close_param = ui::RelativeLayoutParameter::create();
    close_param->setAlign(ui::RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT);
    close_param->setMargin(ui::Margin(sx(30), sy(20), sx(30), sy(30)));
    alert->close_btn->setLayoutParameter(close_param);
    alert->addChild(alert->close_btn);

    auto done_btn = ui::Button::create();
    done_btn->addTouchEventListener([alert](Ref*, TouchEventType type)
    {
        if (type == TouchEventType::ENDED)
        {
            Size visibleSize = Director::getInstance()->getVisibleSize();
            Vec2 origin = Director::getInstance()->getVisibleOrigin();

            Vec2 pos = Vec2(
                origin.x + visibleSize.width - 20,
                origin.y + 20
                );
            alert->shrink_close(pos);
        };

    });

    done_btn->setScale9Enabled(true);
    done_btn->loadTextureNormal("main_UI_export_10_scale9_x4.png", ui::TextureResType::PLIST);
    done_btn->setTitleText("Done");
    done_btn->setTitleFontSize(40.0f);
    done_btn->setTitleFontName(DEFAULT_FONT);
    auto lbl_size = done_btn->getTitleRenderer()->getContentSize();
    done_btn->setContentSize(
            Size(
                lbl_size.width * 1.5f,
                lbl_size.height * 1.5f
                )
            );

    done_btn->ignoreContentAdaptWithSize(false); //word wrap or something

    done_btn->setTitleColor(Color3B::BLACK);
    done_btn->setScaleX(sx(1.0f));
    done_btn->setScaleY(sy(1.0f));
    alert->done_btn = done_btn;


    ui::RelativeLayoutParameter* done_param = ui::RelativeLayoutParameter::create();
    done_param->setAlign(ui::RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL);
    done_param->setMargin(ui::Margin(sx(30), sy(20), sx(30), sy(30)));
    done_param->setRelativeName("done_btn");
    alert->done_btn->setLayoutParameter(done_param);
    alert->addChild(alert->done_btn);

    auto listener = EventListenerTouchOneByOne::create();
    listener->setSwallowTouches(true);

    listener->onTouchBegan = CC_CALLBACK_2(Alert::onTouchBegan, alert);
    listener->onTouchEnded = CC_CALLBACK_2(Alert::onTouchEnded, alert);

    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, alert);

    return alert;
};
Ejemplo n.º 10
0
ImageView::ImageView(BITMAP* bmp, int align)
 : Widget(JI_IMAGE_VIEW)
{
  setAlign(align);
}
Ejemplo n.º 11
0
void GroundBase::setup(float realY)
{
        //ci::app::getAssetPath("floor.png").string();
  
  
    
    texture  = ph::loadTexture(  ci::app::getAssetPath("floor.png").string());
    height =(float) texture.getHeight();
    width =(float) texture.getWidth();
    setHitRect(width , height);
    setAlign(al_int);
    vector<uint32_t> indices;
    vector<Vec2f> texCoords;
    vector<Vec3f> vertices;
    vector<Vec3f> normals;
    int indicesPos =0;
    float step=10;
    float nScale=180.1;
   float mScale=-40;
    int mMod=10;
    float nFactor =10;
    float minZ =-4;
    for(int x=0;x <100;x++)
    {
        for(int y=0;y<100;y++)
        {
            
            indices.push_back( indicesPos++);
            indices.push_back( indicesPos++);
            indices.push_back( indicesPos++);
            indices.push_back( indicesPos++ );
            
           
            
            float xp =x*step ;
            float yp=y*step;
            
            float zp=pNoise->noise (xp/nScale, (yp+realY)/nScale)*nFactor;
            
            if(zp<minZ) zp=minZ;
            Vec3f p1 =Vec3f(xp,yp,(int)zp%mMod *mScale );
            vertices.push_back( p1 );
            
            
            xp =x*step+step ;
            yp=y*step;
            zp=pNoise->noise (xp/nScale,(yp+realY)/nScale)*nFactor;
            
           if(zp<minZ) zp=minZ;
            
            
            Vec3f p2 =Vec3f(xp,yp,(int)zp%mMod *mScale);
            vertices.push_back( p2);
            
            xp =x*step +step;
            yp=y*step+step;
            
            
            zp=pNoise->noise (xp/nScale, (yp+realY)/nScale)*nFactor;
            
            if(zp<minZ) zp=minZ;
            Vec3f p3 =Vec3f(xp,yp,(int)zp%mMod*mScale);
            vertices.push_back( p3);
            
            xp =x*step ;
            yp=y*step+step;
            zp=pNoise->noise (xp/nScale, (yp+realY)/nScale)*nFactor;
            if(zp<minZ) zp=minZ;
            Vec3f p4 =Vec3f(xp,yp,(int)zp%mMod *mScale );
            vertices.push_back( p4 );
          
            
            float u =(float)((int)zp%mMod +4)/mMod ;
            float v =(float) (rand()%100)/100.0f;
            texCoords.push_back( Vec2f(u,v ) );
            //texCoords.push_back( Vec2f(u,v ) );
            //texCoords.push_back( Vec2f(u,v ) );
            //texCoords.push_back( Vec2f(u,v ) );
           texCoords.push_back( Vec2f(u+0.01,v ) );
            texCoords.push_back( Vec2f(u+0.01,v+0.01 ) );
            texCoords.push_back( Vec2f(u,v+0.01 ) );
            
            
            Vec3f n1 =p2-p1;
            Vec3f n2 =p4-p1;
           
        
            Vec3f n = n1.cross(n2);
         
            n.normalize();
            
            
       
            normals.push_back( n );
            normals.push_back( n );
            normals.push_back( n );
            normals.push_back( n );
        }
        
    }
  
    
  
    
    gl::VboMesh::Layout layout;
	layout.setStaticIndices();
	layout.setStaticPositions();
    layout.setStaticNormals();
	layout.setStaticTexCoords2d();
    
    
    
	mVboMesh = gl::VboMesh::create( indices.size(), indices.size(), layout, GL_QUADS );
	
    
    
    
    mVboMesh->bufferIndices( indices );
	mVboMesh->bufferTexCoords2d( 0, texCoords );
    mVboMesh->bufferPositions(vertices);
    mVboMesh->bufferNormals(normals);



};
Ejemplo n.º 12
0
int
CKLBUIScore::commandUI(CLuaState& lua, int argc, int cmd)
{
	int ret = 0;
	switch(cmd)
	{
	case UI_SCORE_RESET:
		setValue(0);
		m_bScoreUpdate = true;
		break;
	case UI_SCORE_SET:
		{
			if(argc != 3) {
				lua.retNil();
				ret = 1;
				break;
			}
			int value = lua.getInt(3);
			if(m_bCountClip && value >= m_maxvalue) value = m_maxvalue - 1;
			setValue(value);
		}
		break;
	case UI_SCORE_SETFLOAT:
		{
			if(argc != 4) {
				lua.retNil();
				ret = 1;
				break;
			}
			float value = lua.getFloat(3);
			int pos = lua.getInt(4);
			if(m_bCountClip && value >= m_maxvalue) value = m_maxvalue - 1;
			setValueFloat(value, pos);
		}
		break;
	case UI_SCORE_SETDOT:
		{
			if(argc != 5) {
				lua.retNil();
				ret = 1;
				break;
			}

			setDot(lua.getString(3), lua.getInt(4), lua.getInt(5));
		}
		break;
	case UI_SCORE_GET:
		{	
			int value = getValue();
			lua.retInt(value);
			ret = 1;
		}
		break;
	case UI_SCORE_ENTERANIM:
		{
			if(argc != 8) {
				lua.retBoolean(false);
				ret = 1;
				break;
			}
			s32  mspt       = lua.getInt(3);
			s32  tshift     = lua.getInt(4);
			bool onlychg    = lua.getBool(5);
			int  type       = lua.getInt(6);
			u32  affected   = lua.getInt(7);
			float mat[8];
			klb_assert(type > 0, "UI_Score: UI_SCORE_ENTERANIM type == 0");

			// 配列を読む
			lua.retValue(8);
			lua.retNil();
			while(lua.tableNext()) {
				lua.retValue(-2);
				int idx = lua.getInt(-1) - 1;
				klb_assert((idx >= 0 && idx < 8), "%s(%d): bad array index. UI_SCORE_ENTERANIM", lua.getScriptName(), lua.getNumLine());
				mat[idx] = lua.getFloat(-2);
				lua.pop(2);
			}
			lua.pop(1);

			klb_assert(type != 0, "Custom animation is not authorized (type 0)");
			m_pScoreNode->setEnterAnimation(mspt, tshift, onlychg, type, affected, mat);
		}
		break;
	case UI_SCORE_EXITANIM:
		{
			if(argc != 8) {
				lua.retBoolean(false);
				ret = 1;
				break;
			}
			s32  mspt       = lua.getInt(3);
			s32  tshift     = lua.getInt(4);
			bool onlychg    = lua.getBool(5);
			int  type       = lua.getInt(6);
			u32  affected   = lua.getInt(7);
			float mat[4];
			klb_assert(type > 0, "UI_Score: UI_SCORE_ENTERANIM type == 0");

			// 配列を読む
			lua.retValue(8);
			lua.retNil();
			while(lua.tableNext()) {
				lua.retValue(-2);
				int idx = lua.getInt(-1) - 1;
				mat[idx] = lua.getFloat(-2);
				lua.pop(2);
			}
			lua.pop(1);

			klb_assert(type != 0, "Custom animation is not authorized (type 0)");
			m_pScoreNode->setExitAnimation(mspt, tshift, onlychg, type, affected, mat);
		}
		break;
	case UI_SCORE_ALIGN:
		{
			bool bResult = false;
			if(argc == 3) {
				int align = lua.getInt(3);
				setAlign(align);
				bResult = true;
			}
			lua.retBool(bResult);
			ret = 1;
		}
		break;
	}
	return ret;
}
Ejemplo n.º 13
0
ImageView::ImageView(she::Surface* sur, int align)
 : Widget(kImageViewWidget)
 , m_sur(sur)
{
  setAlign(align);
}
Ejemplo n.º 14
0
bool SVGPreserveAspectRatio::parseInternal(const CharType*& ptr, const CharType* end, bool validate)
{
    SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
    SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;

    setAlign(align);
    setMeetOrSlice(meetOrSlice);

    if (!skipOptionalSVGSpaces(ptr, end))
        return false;

    if (*ptr == 'd') {
        if (!skipString(ptr, end, "defer"))
            return false;

        // FIXME: We just ignore the "defer" here.
        if (ptr == end)
            return true;

        if (!skipOptionalSVGSpaces(ptr, end))
            return false;
    }

    if (*ptr == 'n') {
        if (!skipString(ptr, end, "none"))
            return false;
        align = SVG_PRESERVEASPECTRATIO_NONE;
        skipOptionalSVGSpaces(ptr, end);
    } else if (*ptr == 'x') {
        if ((end - ptr) < 8)
            return false;
        if (ptr[1] != 'M' || ptr[4] != 'Y' || ptr[5] != 'M')
            return false;
        if (ptr[2] == 'i') {
            if (ptr[3] == 'n') {
                if (ptr[6] == 'i') {
                    if (ptr[7] == 'n')
                        align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
                    else if (ptr[7] == 'd')
                        align = SVG_PRESERVEASPECTRATIO_XMINYMID;
                    else
                        return false;
                } else if (ptr[6] == 'a' && ptr[7] == 'x') {
                    align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
                } else {
                    return false;
                }
            } else if (ptr[3] == 'd') {
                if (ptr[6] == 'i') {
                    if (ptr[7] == 'n')
                        align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
                    else if (ptr[7] == 'd')
                        align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
                    else
                        return false;
                } else if (ptr[6] == 'a' && ptr[7] == 'x') {
                    align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else if (ptr[2] == 'a' && ptr[3] == 'x') {
            if (ptr[6] == 'i') {
                if (ptr[7] == 'n')
                    align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
                else if (ptr[7] == 'd')
                    align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
                else
                    return false;
            } else if (ptr[6] == 'a' && ptr[7] == 'x') {
                align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
            } else {
                return false;
            }
        } else {
            return false;
        }
        ptr += 8;
        skipOptionalSVGSpaces(ptr, end);
    } else {
        return false;
    }

    if (ptr < end) {
        if (*ptr == 'm') {
            if (!skipString(ptr, end, "meet"))
                return false;
            skipOptionalSVGSpaces(ptr, end);
        } else if (*ptr == 's') {
            if (!skipString(ptr, end, "slice"))
                return false;
            skipOptionalSVGSpaces(ptr, end);
            if (align != SVG_PRESERVEASPECTRATIO_NONE)
                meetOrSlice = SVG_MEETORSLICE_SLICE;
        }
    }

    if (end != ptr && validate)
        return false;

    setAlign(align);
    setMeetOrSlice(meetOrSlice);

    return true;
}