美文网首页
egret-显示对象和显示容器

egret-显示对象和显示容器

作者: iOS小开发 | 来源:发表于2021-12-22 18:15 被阅读0次

DisplayObject:显示对象基类,所有显示对象都继承此类

当前对象 addEventListener   type:touchMove touchBegin touchEnd 等

基本属性:

x :x轴坐标值   y:y轴坐标值  width:宽度  height:高度 

rotation:旋转角度     visible:是否可见  scaleX:横向缩放  scaleY:纵向缩放

anchorOffsetY:对象绝对锚点Y  anchorOffsetX:对象绝对锚点X

skewX:横向斜切       skewY:纵向斜切

Shape 

const shp : egret.Shape = new egret.Shape();

shp.graphics.beginFill(0xff0000,1);

shp.graphics.drawRect(0,0,50,50);

shp.graphics.endFill();

var shp1 = new egret.Shape();

shp1.graphics.lineStyle(2,0x00ff00);

shp1.graphics.beginFill(0xff0000,1);

shp1.graphics.drawEllipse(100,100,50,30);

shp1.graphics.endFill();

var shp2 = new egret.Shape();

shp2.x = 100;

shp2.y = 50;

shp2.graphics.lineStyle(2,0x00ff00);

shp2.graphics.beginFill(0xff00000,1);

shp2.graphics.drawCircle(0,0,50);

shp2.graphics.endFill();

var shp3 = new egret.Shape();

shp3.graphics.lineStyle(2,0x00ff00);

shp3.graphics.moveTo(100,100);

shp3.graphics.lineTo(200,200);

shp3.graphics.lineTo(200,100);

shp3.graphics.endFill();

var shp4 = new egret.Shape();

shp4.graphics.lineStyle(2,0xff00ff);

shp4.graphics.moveTo(100,100);

shp4.graphics.curveTo(150,150,200,50);

shp4.graphics.endFill();

var shp5 = new egret.Shape();

shp5.graphics.beginFill(0x1122cc);

shp5.graphics.drawArc(200,200,100,0,Math.PI,true);

shp5.graphics.endFill();

var shp6 = new  egret.Shape();

shp6.graphics.lineStyle(2,0x561200);

shp6.graphics.drawArc(100,100,59,59,Math.PI/180*30,false);

shp6.graphics.endFill();

var shp7 = new egret.Shape();

shp7.graphics.beginFill(0x455444);

shp7.graphics.drawArc(300,300,100,200,Math.PI/180*60,false);

shp7.graphics.endFill();

const r: number = 50;

const shape: egret.Shape = new egret.Shape();

shape.graphics.lineStyle(3,0x000000);

shape.graphics.beginFill(0xff0000,1);

shape.graphics.moveTo(r, r); //绘制点移动(r, r)点

shape.graphics.lineTo(r * 2, r); //画线到弧的起始点

shape.graphics.drawArc(50, 50, 50, 0, 45* Math.PI / 180, true); //从起始点顺时针画弧到终点

shape.graphics.lineTo(r, r); //从终点画线到圆形。到此扇形的封闭区域形成

shape.graphics.endFill();

mask

var shp = new egret.Shape();

 shp.graphics.beginFill(0x000000,1);

 shp.graphics.drawRect(0,0,100,100);

shp.graphics.endFill();

 this.sceneManger.mainstage.addChild(shp);

var shp1 = new egret.Shape();

shp1.graphics.beginFill(0xffffff,1);

shp1.graphics.drawCircle(50,50,20);

shp1.graphics.endFill();

this.sceneManger.mainstage.addChild(shp1);

 shp.mask = shp1;

textfield

字体引用,需要提前加载资源
egret.registerFontMapping("myFont","resource/assets/font/myFont.ttf");

var lab = new egret.TextField();

lab.fontFamily = "myFont";

lab.text = "this is text ";

this.sceneManger.mainstage.addChild(lab);

var txtInput = new egret.TextField();

txtInput.type = egret.TextFieldType.INPUT;

txtInput.width = 100;

txtInput.height = 40;

txtInput.x = 50;

txtInput.y = 100;

txtInput.textColor = 0x000000;

//txtInput.text = "wqewqewq";

txtInput.setFocus();

this.sceneManger.mainstage.addChild(txtInput);

BitMap

图片显示

var img = new egret.Bitmap();

img.texture = RES.getRes("loading_json.loading_bar1_png");

img.width = 100;

img.height = 50;

img.fillMode = egret.BitmapFillMode.SCALE;

var rect = new egret.Rectangle(2,2,2,2);

img.scale9Grid = rect;

this.sceneManger.mainstage.addChild(img);

var  texture = new egret.RenderTexture();

texture.drawToTexture( img);

img.texture = texture;

var textdata = RES.getRes("loading_json.loading_bar1_png");

textdata.saveToFile("image/png", "a/down.png", new egret.Rectangle(50, 30, 100, 100));

img.texture = textdata;

var img = new egret.Bitmap();

var texture  = RES.getRes("egret_icon_png");

img.texture  = texture;

//混合模式

//img.blendMode = egret.BlendMode.ERASE;

this.sceneManger.mainstage.addChild(img);

//滤镜

const colorMatrix = [

    0.3, 0.6, 0, 0, 0,

    0, 0.6, 0, 0, 0,

    0.3, 0.6, 0, 0, 0,

    0, 0, 0, 1, 0

];

const colorFlilter =  new  egret.ColorMatrixFilter(colorMatrix);

//img.filters = [colorFlilter];

const blurFliter  = new  egret.BlurFilter(1,1);

img.filters = [blurFliter];

相关文章

  • egret-显示对象和显示容器

    DisplayObject:显示对象基类,所有显示对象都继承此类 当前对象 addEventListener t...

  • Egret显示对象与显示容器

    显示对象 1. 基本概念 在Egret中,视觉图形都是由显示对象和显示对象容器组成的。 显示对象,是可以在舞台上显...

  • Egret显示深度

    处于同一显示容器的显示对象,是以类似列表的方式来管理的,每一个显示对象都有其索引,并且索引是从0开始的整数。显示列...

  • Docker常用命令

    1. 显示指定容器IP 2. 显示所有容器IP

  • jQ基础

    JQ元素获取 DOM对象转jQ对象 jQ对象转Dom对象 元素的显示和隐藏(如果显示则隐藏 如果隐藏则显示)

  • barbajs-Transition

    transition 是一个Javascript对象,它将确保隐藏旧的容器并显示新的容器。所有的transitio...

  • Pixi

    安装 概念介绍 Pixi应用 容器 容器是用来装载多个显示对象的, 它可以用 PIXI.Container() 方...

  • Weex组件使用

    一、容器

    基本容器 代码示例: 界面显示: 滚动容器 代码示例: 界面显示: 二、基...

  • 纯CSS制作一张色卡

    一、定义图标容器 定义一个容器: 居中显示: 使用flex布局做左右和垂直居中 给容器定义尺寸,并在页面上显示出来...

  • Css3Two

    文本溢出样式设置 文本超出容器以后: 换行显示 超出容器部分也显示 伪类和伪元素 伪类和伪元素 都是css中的伪类...

网友评论

      本文标题:egret-显示对象和显示容器

      本文链接:https://www.haomeiwen.com/subject/embxqrtx.html