Skip to main content

Image

ClassTypeName
StretchModeEnumFit
FitWidth
FitHeight
Stretch
Fill
FillAndCut
ClassTypeNameInterface Description
Image : RendererVariablestexture: Texture | null

Main Texture of Image Component

Example

const texture = image.texture;

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private count : number = 0;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
console.log("Image width", this.image.texture.getWidth());
console.log("Image height", this.image.texture.getHeight());
}

//inherted more for your logic
}

use case

ClassTypeNameInterface Description
Image : RendererVariablesopacity: number

Transparency of Image

Example

image.opacity = 0.5;

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private direction : number = -1;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
let opacity = this.imageRenderer.opacity;
if (opacity < 0.1)
{
this.direction = 1;
}
else if (opacity > 0.9)
{
this.direction = -1;
}
this.image.opacity = opacity + 0.01 * this.direction;
}

//inherted more for your logic
}

use case

ClassTypeNameInterface Description
Image : RendererVariablescolor: Color

The overlay color of Image, calculated in the shader as vec4 imageColor = baseColor u_color u_opacity

Example

image.color = new APJS.Color(1, 0, 0, 1);

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private direction : number = -1;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
let color = this.imageRenderer.color;
if (color.r < 0.1)
{
this.direction = 1;
}
else if (color.r > 0.9)
{
this.direction = -1;
}
this.image.color = new APJS.Color(color.r + 0.01 * this.direction, 0, 0, color.a);
}

//inherted more for your logic
}

use case

ClassTypeNameInterface Description
Image : RendererVariablessize: Vector2f

Width and height of Image

Example

image.size = new APJS.Vector2f(5, 5);

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private direction : number = -1;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
let size = this.imageRenderer.size;
if (size.x < 10)
{
this.direction = 1;
}
else if (size.x > 20)
{
this.direction = -1;
}
this.image.size = new APJS.Vector2f(size.x + 0.1 * this.direction, size.y + 0.1 * this.direction);
}

//inherted more for your logic
}

use case

ClassTypeNameInterface Description
Image : RendererVariablespivot: Vector2f

Rotation point of Image

Example

image.pivot = new APJS.Vector2f(0.5, 0.5);

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private direction : number = -1;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
let pivot = this.image.pivot;
if (pivot.x < 0.1)
{
this.direction = 1;
}
else if (pivot.x > 0.9)
{
this.direction = -1;
}
this.image.pivot = new APJS.Vector2f(pivot.x + 0.01 * this.direction, pivot.y + 0.01 * this.direction);
}

//inherted more for your logic
}

use case

ClassTypeNameInterface Description
Image : RendererVariablesstretchMode: ImageStretchMode

Texture Fill Mode for Image's Size Area

Example

image.stretchMode = APJS.StretchMode.Stretch;

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private count : number = 0;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
this.count = this.count + 1;
if (this.count > 30)
{
this.count = 0;
const mode = this.image.stretchMode;
if (mode === APJS.StretchMode.Fit)
{
this.image.stretchMode = APJS.StretchMode.Stretch;
}
else
{
this.image.stretchMode = APJS.StretchMode.Fit;
}
}
}

//inherted more for your logic
}

use case

ClassTypeNameInterface Description
Image : RendererVariablesflipX: boolean

Whether the Image is horizontally flipped

Example

image.flipX = true;

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private count : number = 0;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
this.count = this.count + 1;
if (this.count > 30)
{
this.count = 0;
this.image.flipX = !this.imageRenderer.flipX;
}
}

//inherted more for your logic
}

use case

ClassTypeNameInterface Description
Image : RendererVariablesflipY: boolean

Whether the Image is vertically flipped

Example

image.flipY = true;

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

private image : APJS.Image;
private count : number = 0;
//called before the first frame update
onStart() {
this.image = this.getSceneObject().getComponent("Image") as APJS.Image;

}

//called once per frame
onUpdate(deltaTime: number) {
this.count = this.count + 1;
if (this.count > 30)
{
this.count = 0;
this.image.flipY = !this.imageRenderer.flipY;
}
}

//inherted more for your logic
}

use case

Copyright © 2025 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalCookies