Total Pageviews

Saturday, May 31, 2014

នេះជា Type ShapeObject របស់ Corona SDK (detail2)

 Methods
 (Inherits methods from DisplayObject)
 object:setFillColor()
 ប្រើសំរាប់បញ្ចូលនៅ fill color of vector and text objects ដែលវា applied ទៅនឹង tint to image objects
object:setFillColor( gray )
object:setFillColor( gray, alpha )
object:setFillColor( red, green, blue )
object:setFillColor( red, green, blue, alpha )
object:setFillColor( gradient )

gray, red, green, blue, alpha (optional)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the object.


gradient (optional)

Table. See the gradient fill example below.


Gotchas

In builds based on V1 Graphics, continue using setTextColor() to set the fill color for text objects created via display.newText().


Examples


Vector Object Fill
 local vertices = { 0,-110, 27,-35, 105,-35, 43,16, 65,90, 0,45, -65,90, -43,15, -105,-35, -27,-35 }

local star = display.newPolygon( 300, 300, vertices )
star:setFillColor( 1, 0.2, 0.2 )

Text Object Fill
 local myText = display.newText( "hello", 0, 0, native.systemFontBold, 12 )

myText:setFillColor( 1, 0.2, 0.2 )

Gradient Fill
 local rect = display.newRect( 0, 0, 100, 200 )

local gradient = {
    type="gradient",
    color1={ 1, 1, 1 }, color2={ 0.8, 0.8, 0.8 }, direction="down"
}
rect:setFillColor( gradient )

Image Tint
 local image = display.newImage( "image.png" )
image:setFillColor( 0.72, 0.9, 0.16, 0.78 )  -- Tints image green

object:setStrokeColor()
ប្រើសំរាប់បញ្ចូលនៅ stroke (border) color of vector objects
Syntax:
object:setStrokeColor( gray )
object:setStrokeColor( gray, alpha )
object:setStrokeColor( red, green, blue )
object:setStrokeColor( red, green, blue, alpha )

gray, red, green, blue, alpha (required)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the stroke.


សូមមើលកូដះ
 local rect = display.newRect( 150, 150, 100, 100 )
rect:setFillColor( 1, 1, 0.8 )
rect:setStrokeColor( 1, 0, 0 )
rect.strokeWidth = 8

No comments:

Post a Comment