提交 bc3828c4 编写于 作者: T tianwenzhe

add ;

Signed-off-by: Ntian-wenzhe411 <tianwenzhe2@huawei.com>
上级 3993995c
......@@ -27,11 +27,11 @@ path1 = path + '/report1';
@Entry
@Component
struct IndexPage {
@State BackColor: string = '#ff808080'
@State ClearAll : boolean = false
private current : number = undefined
@State count : number = 0
@State result : string = ''
@State BackColor: string = '#ff808080';
@State ClearAll : boolean = false;
private current : number = undefined;
@State count : number = 0;
@State result : string = '';
private TestCaseList = [
{title:'Scroll List',uri:'pages/ArkUI/ScrollListTest'},
{title:'TouchMove',uri:'pages/ArkUI/TouchMoveTest'},
......@@ -57,7 +57,6 @@ struct IndexPage {
{title:'CanvasShadowOffsetX',uri:'pages/ArkUI/CanvasShadowOffsetX'},
{title:'CanvasShadowOffsetY',uri:'pages/ArkUI/CanvasShadowOffsetY'},
{title:'CanvasImageSmoothingEnabled',uri:'pages/ArkUI/CanvasImageSmoothingEnabled'},
// {title:'',uri:'',bgc:Color.Black},
]
@State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080',
'#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080',
......@@ -74,10 +73,10 @@ struct IndexPage {
}
else if (this.result === 'Fail'){
this.ColorObject[this.current] = '#ffff0000';
filewrite(name1,results,titles)
filewrite(name1,results,titles);
}
else if (this.result === 'None'){
this.ColorObject[this.current] = this.ColorObject[this.current]
this.ColorObject[this.current] = this.ColorObject[this.current];
}
}
......@@ -89,7 +88,7 @@ struct IndexPage {
Image($r('app.media.ic_public_back')).width('20vp').height('18vp')
}.backgroundColor(Color.Black)
.onClick(() => {
router.back()
router.back();
})
Row(){
Text('ArkUI SubSystem')
......@@ -105,12 +104,12 @@ struct IndexPage {
.onClick(() => {
this.ClearAll = true;
this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080'
this.ColorObject[index] = '#ff808080';
});
this.ClearText();
prompt.showToast({
message: '结果已删除', duration: 1000
})
});
})
Button(){
Image($r('app.media.ic_public_save'))
......@@ -134,9 +133,9 @@ struct IndexPage {
Text(this.BackColor.toString()).visibility(Visibility.None)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index])
.onClick(( )=>{
this.count = 1
this.ClearAll=false
this.current = index
this.count = 1;
this.ClearAll=false;
this.current = index;
router.push({
url: item.uri,
})
......@@ -199,7 +198,7 @@ struct IndexPage {
}finally{
fileIO.closeSync(xmlfd);
}
return
return;
}
}
}
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -31,24 +31,24 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('Red').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(100, 160, 150, 100)
this.FillColor = '#FFFF0000'
this.context.fillStyle = this.FillColor
this.context.fillRect(100, 160, 150, 100)
this.context.clearRect(100, 160, 150, 100);
this.FillColor = '#FFFF0000';
this.context.fillStyle = this.FillColor;
this.context.fillRect(100, 160, 150, 100);
})
Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(100, 160, 150, 100)
this.FillColor = '#fffffc3c'
this.context.fillStyle = this.FillColor
this.context.fillRect(100, 160, 150, 100)
this.context.clearRect(100, 160, 150, 100);
this.FillColor = '#fffffc3c';
this.context.fillStyle = this.FillColor;
this.context.fillRect(100, 160, 150, 100);
})
Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(100, 160, 150, 100)
this.FillColor = '#ff19fa00'
this.context.fillStyle = this.FillColor
this.context.fillRect(100, 160, 150, 100)
this.context.clearRect(100, 160, 150, 100);
this.FillColor = '#ff19fa00';
this.context.fillStyle = this.FillColor;
this.context.fillRect(100, 160, 150, 100);
})
}.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......@@ -57,8 +57,8 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.fillStyle = this.FillColor
this.context.fillRect(100, 160, 150, 100)
this.context.fillStyle = this.FillColor;
this.context.fillRect(100, 160, 150, 100);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -33,156 +33,150 @@ struct SetCircle {
}
Row({space:10}){
Text('font-style').fontSize(13).border({width:0}).size({width:'24%',height:'18%'})
Text('normal').fontSize(13).border({width:2}).size({width:'24%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('italic').fontSize(13).border({width:2}).size({width:'24%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'italic normal 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'italic normal 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
}
Row({space:8}) {
Text('font-weight').fontSize(13).border({ width: 0 }).size({ width: '24%', height: '18%' })
Text('normal').fontSize(13).border({ width: 2 }).size({ width: '16%', height: '18%' })
.onClick(() => {
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('bold').fontSize(13).border({width:2}).size({width:'16%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal bold 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal bold 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('bolder').fontSize(13).border({width:2}).size({width:'16%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal bolder 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal bolder 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('lighter').fontSize(13).border({width:2}).size({width:'16%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal lighter 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal lighter 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
}
Row({space:5}) {
Text('100').fontSize(13).border({ width: 2 }).size({ width: '10%', height: '18%' })
.onClick(() => {
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 100 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 100 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('200').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 200 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 200 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('300').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 300 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 300 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('400').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 400 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 400 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('500').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 500 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 500 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('600').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 600 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 600 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('700').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 700 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 700 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('800').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 800 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 800 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('900').fontSize(13).border({width:2}).size({width:'10%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal 900 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal 900 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
}
Row({space:10}){
Text('font-family').fontSize(13).border({width:0}).size({width:'24%',height:'18%'})
Text('sans-serif').fontSize(13).border({width:2}).size({width:'24%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('serif').fontSize(13).border({width:2}).size({width:'24%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 120px serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 120px serif';
this.context.fillText("Hello World", 80, 120);
})
Text('monospace').fontSize(13).border({width:2}).size({width:'24%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 120px monospace'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 120px monospace';
this.context.fillText("Hello World", 80, 120);
})
}
Row({space:10}) {
Text('font-size').fontSize(13).border({ width: 0 }).size({ width: '18%', height: '18%' })
Text('small').fontSize(13).border({ width: 2 }).size({ width: '18%', height: '18%' })
.onClick(() => {
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 10px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 10px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('medium').fontSize(13).border({width:2}).size({width:'18%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 50px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 50px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('large').fontSize(13).border({width:2}).size({width:'18%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 80px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 80px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
Text('extra').fontSize(13).border({width:2}).size({width:'18%',height:'18%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.font = 'normal normal 120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.font = 'normal normal 120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
}
}.width('90%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
......@@ -190,8 +184,8 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.font = '120px sans-serif'
this.context.fillText("Hello World", 80, 120)
this.context.font = '120px sans-serif';
this.context.fillText("Hello World", 80, 120);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -35,14 +35,14 @@ struct SetCircle {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
this.context.clearRect(100, 100, 250, 200)
console.info('Pan start')
this.context.clearRect(100, 100, 250, 200);
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.X = event.offsetX;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('透明度: ' + (this.X)*0.005 )
......@@ -53,11 +53,11 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalAlpha = (this.X)*0.005
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(200, 200, 50, 50)
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalAlpha = (this.X)*0.005;
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(200, 200, 50, 50);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -34,106 +34,106 @@ struct SetCircle {
Row({space:10}){
Text('s-over').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'source-over'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'source-over';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('s-atop').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'source-atop'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'source-atop';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('s-in').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'source-in'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'source-in';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('s-out').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'source-out'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'source-out';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
}
Row({space:10}){
Text('d-over').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'destination-over'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'destination-over';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('d-atop').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'destination-atop'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'destination-atop';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('d-in').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'destination-in'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'destination-in';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('d-out').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'destination-out'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'destination-out';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
}
Row({space:10}){
Text('lighter').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'lighter'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'lighter';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('copy').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'copy'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'copy';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('xor').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'xor'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.clearRect(0, 10, 350, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'xor';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
Text('').fontSize(0).border({width:0}).size({width:'18%',height:'20%'})
}
......@@ -144,11 +144,11 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 50, 50)
this.context.globalCompositeOperation = 'source-over'
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(180, 180, 50, 50)
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50);
this.context.globalCompositeOperation = 'source-over';
this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(180, 180, 50, 50);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -32,15 +32,15 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('True').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(10, 100, 400, 300)
this.context.imageSmoothingEnabled = true
this.context.drawImage( this.img,0,0,400,200)
this.context.clearRect(10, 100, 400, 300);
this.context.imageSmoothingEnabled = true;
this.context.drawImage( this.img,0,0,400,200);
})
Text('False').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(10, 100, 400, 300)
this.context.imageSmoothingEnabled = false
this.context.drawImage( this.img,0,0,400,200)
this.context.clearRect(10, 100, 400, 300);
this.context.imageSmoothingEnabled = false;
this.context.drawImage( this.img,0,0,400,200);
})
}.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......@@ -49,8 +49,8 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.imageSmoothingEnabled = false
this.context.drawImage( this.img,0,0,200,200)
this.context.imageSmoothingEnabled = false;
this.context.drawImage( this.img,0,0,200,200);
})
}.width('100%').height('60%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -30,33 +30,33 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('butt').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 90, 170, 120)
this.context.lineWidth = 8
this.context.beginPath()
this.context.lineCap = 'butt'
this.context.moveTo(100, 100)
this.context.lineTo(250, 100)
this.context.stroke()
this.context.clearRect(90, 90, 170, 120);
this.context.lineWidth = 8;
this.context.beginPath();
this.context.lineCap = 'butt';
this.context.moveTo(100, 100);
this.context.lineTo(250, 100);
this.context.stroke();
})
Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 90, 170, 120)
this.context.lineWidth = 8
this.context.beginPath()
this.context.lineCap = 'round'
this.context.moveTo(100, 100)
this.context.lineTo(250, 100)
this.context.stroke()
this.context.clearRect(90, 90, 170, 120);
this.context.lineWidth = 8;
this.context.beginPath();
this.context.lineCap = 'round';
this.context.moveTo(100, 100);
this.context.lineTo(250, 100);
this.context.stroke();
})
Text('square').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 90, 170, 120)
this.context.lineWidth = 8
this.context.beginPath()
this.context.lineCap = 'square'
this.context.moveTo(100, 100)
this.context.lineTo(250, 100)
this.context.stroke()
this.context.clearRect(90, 90, 170, 120);
this.context.lineWidth = 8;
this.context.beginPath();
this.context.lineCap = 'square';
this.context.moveTo(100, 100);
this.context.lineTo(250, 100);
this.context.stroke();
})
}.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......@@ -65,12 +65,12 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.lineWidth = 8
this.context.beginPath()
this.context.lineCap = 'round'
this.context.moveTo(100, 100)
this.context.lineTo(250, 100)
this.context.stroke()
this.context.lineWidth = 8;
this.context.beginPath();
this.context.lineCap = 'round';
this.context.moveTo(100, 100);
this.context.lineTo(250, 100);
this.context.stroke();
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -34,14 +34,14 @@ struct SetCircle {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
this.context.clearRect(100, 100, 250, 200)
console.info('Pan start')
this.context.clearRect(100, 100, 250, 200);
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.X = event.offsetX;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('虚线偏移量: ' + (this.X)*0.1 )
......@@ -52,8 +52,8 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.arc(180, 150, 50, 0, 6.28)
this.context.setLineDash([20,30])
this.context.arc(180, 150, 50, 0, 6.28);
this.context.setLineDash([20,30]);
this.context.lineDashOffset = (this.X)*0.1;
this.context.stroke();
})
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -30,36 +30,36 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 90, 170, 120)
this.context.beginPath()
this.context.lineWidth = 8
this.context.lineJoin = 'round'
this.context.moveTo(120, 100)
this.context.lineTo(210, 130)
this.context.lineTo(120, 180)
this.context.stroke()
this.context.clearRect(90, 90, 170, 120);
this.context.beginPath();
this.context.lineWidth = 8;
this.context.lineJoin = 'round';
this.context.moveTo(120, 100);
this.context.lineTo(210, 130);
this.context.lineTo(120, 180);
this.context.stroke();
})
Text('bevel').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 90, 170, 120)
this.context.beginPath()
this.context.lineWidth = 8
this.context.lineJoin = 'bevel'
this.context.moveTo(120, 100)
this.context.lineTo(210, 130)
this.context.lineTo(120, 180)
this.context.stroke()
this.context.clearRect(90, 90, 170, 120);
this.context.beginPath();
this.context.lineWidth = 8;
this.context.lineJoin = 'bevel';
this.context.moveTo(120, 100);
this.context.lineTo(210, 130);
this.context.lineTo(120, 180);
this.context.stroke();
})
Text('miter').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 90, 170, 120)
this.context.beginPath()
this.context.lineWidth = 8
this.context.lineJoin = 'miter'
this.context.moveTo(120, 100)
this.context.lineTo(210, 130)
this.context.lineTo(120, 180)
this.context.stroke()
this.context.clearRect(90, 90, 170, 120);
this.context.beginPath();
this.context.lineWidth = 8;
this.context.lineJoin = 'miter';
this.context.moveTo(120, 100);
this.context.lineTo(210, 130);
this.context.lineTo(120, 180);
this.context.stroke();
})
}.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......@@ -68,13 +68,13 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.beginPath()
this.context.lineWidth = 8
this.context.lineJoin = 'miter'
this.context.moveTo(120, 100)
this.context.lineTo(210, 130)
this.context.lineTo(120, 180)
this.context.stroke()
this.context.beginPath();
this.context.lineWidth = 8;
this.context.lineJoin = 'miter';
this.context.moveTo(120, 100);
this.context.lineTo(210, 130);
this.context.lineTo(120, 180);
this.context.stroke();
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -34,14 +34,14 @@ struct SetCircle {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
this.context.clearRect(100, 100, 250, 200)
console.info('Pan start')
this.context.clearRect(100, 100, 250, 200);
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.X = event.offsetX;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('边框粗细: ' + (this.X)*0.05 )
......@@ -52,8 +52,8 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.lineWidth = (this.X)*0.05
this.context.strokeRect(120, 120, 120, 120)
this.context.lineWidth = (this.X)*0.05;
this.context.strokeRect(120, 120, 120, 120);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -34,14 +34,14 @@ struct SetCircle {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
this.context.clearRect(100, 100, 250, 200)
console.info('Pan start')
this.context.clearRect(100, 100, 250, 200);
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.X = event.offsetX;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('边框粗细: ' + (this.X)*0.05 )
......@@ -52,13 +52,13 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.lineWidth = 8
this.context.lineJoin = 'miter'
this.context.miterLimit = (this.X)*0.05
this.context.moveTo(160, 100)
this.context.lineTo(190, 105)
this.context.lineTo(160, 107)
this.context.stroke()
this.context.lineWidth = 8;
this.context.lineJoin = 'miter';
this.context.miterLimit = (this.X)*0.05;
this.context.moveTo(160, 100);
this.context.lineTo(190, 105);
this.context.lineTo(160, 107);
this.context.stroke();
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -34,16 +34,16 @@ struct SetCircle {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
this.context.clearRect(10, 50, 400, 300)
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
console.info('Pan start')
this.context.clearRect(10, 50, 400, 300);
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.X = event.offsetX;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('阴影模糊: ' + this.X )
......@@ -54,10 +54,10 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.shadowBlur = this.X
this.context.shadowColor = 'rgb(0,0,0)'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
this.context.shadowBlur = this.X;
this.context.shadowColor = 'rgb(0,0,0)';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -31,41 +31,39 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('Blue').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(10, 100, 400, 300)
this.context.shadowBlur = 30
this.context.shadowColor = 'rgb(0,0,255)'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
this.context.clearRect(10, 100, 400, 300);
this.context.shadowBlur = 30;
this.context.shadowColor = 'rgb(0,0,255)';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
})
Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(10, 100, 400, 300)
this.context.shadowBlur = 30
this.context.shadowColor = '#fffffc3c'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
this.context.clearRect(10, 100, 400, 300);
this.context.shadowBlur = 30;
this.context.shadowColor = '#fffffc3c';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
})
Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(10, 100, 400, 300)
this.context.shadowBlur = 30
this.context.shadowColor = '#ff19fa00'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
this.context.clearRect(10, 100, 400, 300);
this.context.shadowBlur = 30;
this.context.shadowColor = '#ff19fa00';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
})
}.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.shadowBlur = 30
this.context.shadowColor = 'rgb(0,0,255)'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
this.context.shadowBlur = 30;
this.context.shadowColor = 'rgb(0,0,255)';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
})
}.width('100%').height('60%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -34,17 +34,17 @@ struct SetCircle {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
this.context.clearRect(10, 50, 400, 300)
this.context.shadowColor = 'rgb(0,0,0)'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
console.info('Pan start')
this.context.clearRect(10, 50, 400, 300);
this.context.shadowColor = 'rgb(0,0,0)';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.X = event.offsetX;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('阴影偏移: ' + (this.X)*0.05 )
......@@ -55,11 +55,11 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.shadowBlur = 10
this.context.shadowOffsetX = (this.X)*0.05
this.context.shadowColor = 'rgb(0,0,0)'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
this.context.shadowBlur = 10;
this.context.shadowOffsetX = (this.X)*0.05;
this.context.shadowColor = 'rgb(0,0,0)';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -34,17 +34,17 @@ struct SetCircle {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
this.context.clearRect(10, 50, 400, 300)
this.context.shadowColor = 'rgb(0,0,0)'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
console.info('Pan start')
this.context.clearRect(10, 50, 400, 300);
this.context.shadowColor = 'rgb(0,0,0)';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.X = event.offsetX;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('阴影偏移: ' + (this.X)*0.05 )
......@@ -55,11 +55,11 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.shadowBlur = 10
this.context.shadowOffsetY = (this.X)*0.05
this.context.shadowColor = 'rgb(0,0,0)'
this.context.fillStyle = 'rgb(255,0,0)'
this.context.fillRect(150, 150, 100, 100)
this.context.shadowBlur = 10;
this.context.shadowOffsetY = (this.X)*0.05;
this.context.shadowColor = 'rgb(0,0,0)';
this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -30,27 +30,27 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('Red').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 150, 170, 120)
this.FillColor = '#FFFF0000'
this.context.lineWidth = 10
this.context.strokeStyle = '#FFFF0000'
this.context.strokeRect(100, 160, 150, 100)
this.context.clearRect(90, 150, 170, 120);
this.FillColor = '#FFFF0000';
this.context.lineWidth = 10;
this.context.strokeStyle = '#FFFF0000';
this.context.strokeRect(100, 160, 150, 100);
})
Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 150, 170, 120)
this.FillColor = '#fffffc3c'
this.context.lineWidth = 10
this.context.strokeStyle = '#fffffc3c'
this.context.strokeRect(100, 160, 150, 100)
this.context.clearRect(90, 150, 170, 120);
this.FillColor = '#fffffc3c';
this.context.lineWidth = 10;
this.context.strokeStyle = '#fffffc3c';
this.context.strokeRect(100, 160, 150, 100);
})
Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(90, 150, 170, 120)
this.FillColor = '#ff19fa00'
this.context.lineWidth = 10
this.context.strokeStyle = '#ff19fa00'
this.context.strokeRect(100, 160, 150, 100)
this.context.clearRect(90, 150, 170, 120);
this.FillColor = '#ff19fa00';
this.context.lineWidth = 10;
this.context.strokeStyle = '#ff19fa00';
this.context.strokeRect(100, 160, 150, 100);
})
}.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......@@ -59,9 +59,9 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.lineWidth = 10
this.context.strokeStyle = this.FillColor
this.context.strokeRect(100, 160, 150, 100)
this.context.lineWidth = 10;
this.context.strokeStyle = this.FillColor;
this.context.strokeRect(100, 160, 150, 100);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -30,53 +30,53 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('start').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.lineWidth = 2
this.context.moveTo(180, 10)
this.context.lineTo(180, 310)
this.context.stroke()
this.context.textAlign = 'start'
this.context.fillText('textAlign=start', 180, 160)
this.context.clearRect(0, 10, 350, 300);
this.context.lineWidth = 2;
this.context.moveTo(180, 10);
this.context.lineTo(180, 310);
this.context.stroke();
this.context.textAlign = 'start';
this.context.fillText('textAlign=start', 180, 160);
})
Text('end').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.lineWidth = 2
this.context.moveTo(180, 10)
this.context.lineTo(180, 310)
this.context.stroke()
this.context.textAlign = 'end'
this.context.fillText('textAlign=end', 180, 160)
this.context.clearRect(0, 10, 350, 300);
this.context.lineWidth = 2;
this.context.moveTo(180, 10);
this.context.lineTo(180, 310);
this.context.stroke();
this.context.textAlign = 'end';
this.context.fillText('textAlign=end', 180, 160);
})
Text('left').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.lineWidth = 2
this.context.moveTo(180, 10)
this.context.lineTo(180, 310)
this.context.stroke()
this.context.textAlign = 'left'
this.context.fillText('textAlign=left', 180, 160)
this.context.clearRect(0, 10, 350, 300);
this.context.lineWidth = 2;
this.context.moveTo(180, 10);
this.context.lineTo(180, 310);
this.context.stroke();
this.context.textAlign = 'left';
this.context.fillText('textAlign=left', 180, 160);
})
Text('center').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.lineWidth = 2
this.context.moveTo(180, 10)
this.context.lineTo(180, 310)
this.context.stroke()
this.context.textAlign = 'center'
this.context.fillText('textAlign=center', 180, 160)
this.context.clearRect(0, 10, 350, 300);
this.context.lineWidth = 2;
this.context.moveTo(180, 10);
this.context.lineTo(180, 310);
this.context.stroke();
this.context.textAlign = 'center';
this.context.fillText('textAlign=center', 180, 160);
})
Text('right').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.lineWidth = 2
this.context.moveTo(180, 10)
this.context.lineTo(180, 310)
this.context.stroke()
this.context.textAlign = 'right'
this.context.fillText('textAlign=right', 180, 160)
this.context.clearRect(0, 10, 350, 300);
this.context.lineWidth = 2;
this.context.moveTo(180, 10);
this.context.lineTo(180, 310);
this.context.stroke();
this.context.textAlign = 'right';
this.context.fillText('textAlign=right', 180, 160);
})
}.width('90%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......@@ -85,15 +85,13 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.lineWidth = 2
this.context.moveTo(180, 10)
this.context.lineTo(180, 310)
this.context.stroke()
this.context.font = '60px sans-serif'
this.context.textAlign = 'start'
this.context.fillText('textAlign=start', 180, 160)
this.context.lineWidth = 2;
this.context.moveTo(180, 10);
this.context.lineTo(180, 310);
this.context.stroke();
this.context.font = '60px sans-serif';
this.context.textAlign = 'start';
this.context.fillText('textAlign=start', 180, 160);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer1'
import FirstDialog from '../model/FirstDialog'
import {CustomContainer} from '../common/CanvasCustomContainer1';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
......@@ -30,58 +30,58 @@ struct SetCircle {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('Top').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.strokeStyle = '#0000ff'
this.context.lineWidth = 2
this.context.moveTo(0, 120)
this.context.lineTo(400, 120)
this.context.stroke()
this.context.textBaseline = 'top'
this.context.fillText('Top', 160, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.strokeStyle = '#0000ff';
this.context.lineWidth = 2;
this.context.moveTo(0, 120);
this.context.lineTo(400, 120);
this.context.stroke();
this.context.textBaseline = 'top';
this.context.fillText('Top', 160, 120);
})
Text('Bottom').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.strokeStyle = '#0000ff'
this.context.lineWidth = 2
this.context.moveTo(0, 120)
this.context.lineTo(400, 120)
this.context.stroke()
this.context.textBaseline = 'bottom'
this.context.fillText('Bottom', 160, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.strokeStyle = '#0000ff';
this.context.lineWidth = 2;
this.context.moveTo(0, 120);
this.context.lineTo(400, 120);
this.context.stroke();
this.context.textBaseline = 'bottom';
this.context.fillText('Bottom', 160, 120);
})
Text('Middle').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.strokeStyle = '#0000ff'
this.context.lineWidth = 2
this.context.moveTo(0, 120)
this.context.lineTo(400, 120)
this.context.stroke()
this.context.textBaseline = 'middle'
this.context.fillText('Middle', 160, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.strokeStyle = '#0000ff';
this.context.lineWidth = 2;
this.context.moveTo(0, 120);
this.context.lineTo(400, 120);
this.context.stroke();
this.context.textBaseline = 'middle';
this.context.fillText('Middle', 160, 120);
})
Text('Alphabetic').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{
this.context.clearRect(0, 10, 350, 300)
this.context.strokeStyle = '#0000ff'
this.context.lineWidth = 2
this.context.moveTo(0, 120)
this.context.lineTo(400, 120)
this.context.stroke()
this.context.textBaseline = 'alphabetic'
this.context.fillText('Alphabetic', 160, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.strokeStyle = '#0000ff';
this.context.lineWidth = 2;
this.context.moveTo(0, 120);
this.context.lineTo(400, 120);
this.context.stroke();
this.context.textBaseline = 'alphabetic';
this.context.fillText('Alphabetic', 160, 120);
})
Text('Hanging').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=> {
this.context.clearRect(0, 10, 350, 300)
this.context.strokeStyle = '#0000ff'
this.context.lineWidth = 2
this.context.moveTo(0, 120)
this.context.lineTo(400, 120)
this.context.stroke()
this.context.textBaseline = 'hanging'
this.context.fillText('Hanging', 160, 120)
this.context.clearRect(0, 10, 350, 300);
this.context.strokeStyle = '#0000ff';
this.context.lineWidth = 2;
this.context.moveTo(0, 120);
this.context.lineTo(400, 120);
this.context.stroke();
this.context.textBaseline = 'hanging';
this.context.fillText('Hanging', 160, 120);
})
}.width('90%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......@@ -90,16 +90,14 @@ struct SetCircle {
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.strokeStyle = '#0000ff'
this.context.lineWidth = 2
this.context.moveTo(0, 120)
this.context.lineTo(400, 120)
this.context.stroke()
this.context.font = '60px sans-serif'
this.context.textBaseline = 'top'
this.context.fillText('Top', 160, 120)
this.context.strokeStyle = '#0000ff';
this.context.lineWidth = 2;
this.context.moveTo(0, 120);
this.context.lineTo(400, 120);
this.context.stroke();
this.context.font = '60px sans-serif';
this.context.textBaseline = 'top';
this.context.fillText('Top', 160, 120);
})
}.width('100%').height('70%')
}.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -33,11 +33,11 @@ struct LongPressGestureExample {
LongPressGesture({ repeat: true })
.onAction((event: GestureEvent) => {
if (event.repeat) {
this.X++
this.X++;
}
})
.onActionEnd(() => {
this.X = 0
this.X = 0;
})
)
Text('长按动作连续触发:' + this.X).fontColor(Color.Black)
......
......@@ -34,14 +34,14 @@ struct PanGestureExample {
.gesture(
PanGesture({})
.onActionStart((event: GestureEvent) => {
console.info('Pan start')
console.info('Pan start');
})
.onActionUpdate((event: GestureEvent) => {
this.X = event.offsetX
this.Y = event.offsetY
this.X = event.offsetX;
this.Y = event.offsetY;
})
.onActionEnd(() => {
console.info('Pan end')
console.info('Pan end');
})
)
Text('偏移坐标x: ' + this.X + '\n' + '偏移坐标y: ' + this.Y)
......
......@@ -33,7 +33,7 @@ struct PinchGuestureTest {
.gesture(
PinchGesture()
.onActionUpdate((event: GestureEvent) => {
this.X = event.scale
this.X = event.scale;
})
)
Text('捏合放缩比例:'+this.X).fontColor(Color.Black)
......
......@@ -34,7 +34,7 @@ struct RotationGuestureTest {
.gesture(
RotationGesture()
.onActionUpdate((event: GestureEvent) => {
this.X = event.angle
this.X = event.angle;
})
)
Text('旋转角度:' + this.X)
......
......@@ -17,7 +17,7 @@ import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct CustomContainerUser {
private listArr: number[] = Array.from(new Array(50).keys())
private listArr: number[] = Array.from(new Array(50).keys());
@State name: string = 'ScrollingList';
@State StepTips: string = '操作步骤:滑动列表观察是否能正常滑动'+'\n'+'预期结果:列表滑动正常';
async aboutToAppear(){
......
......@@ -34,8 +34,8 @@ struct SwipeGestureTest {
.gesture(
SwipeGesture({fingers: 1, direction: SwipeDirection.Vertical})
.onAction((event: GestureEvent) => {
this.Y = event.speed
this.X = event.angle
this.Y = event.speed;
this.X = event.angle;
})
)
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
......
......@@ -32,7 +32,7 @@ struct TapGestureExample {
.gesture(
TapGesture({ count: 2 })
.onAction(() => {
this.value = 'TapGesture onAction'
this.value = 'TapGesture onAction';
})
)
Text(this.value)
......
......@@ -20,8 +20,8 @@ import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import FirstDialog from '../model/FirstDialog';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
const TAG = '[Screenshot]'
let path = globalThis.dir
const TAG = '[Screenshot]';
let path = globalThis.dir;
@Component
struct CustomContainer1 {
@Link x: number;
......@@ -36,28 +36,28 @@ struct CustomContainer1 {
PassBtn(text: Resource, isFullScreen: boolean) {
Button() {
Image($r('app.media.ic_public_pass')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey) //Pass Button
}.width('30%').height('30vp').backgroundColor(Color.Grey)
.onClick(()=>{
router.back({
url:this.Url,
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
FailBtn(text: Resource, isFullScreen: boolean) {
Button(){
Image($r('app.media.ic_public_fail')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey) //Fail Button
}.width('30%').height('30vp').backgroundColor(Color.Grey)
.onClick(()=>{
router.back({
url:this.Url,
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -75,10 +75,10 @@ struct CustomContainer1 {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -95,7 +95,7 @@ struct CustomContainer1 {
}
)
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
......@@ -103,27 +103,27 @@ struct CustomContainer1 {
Logger.info(TAG, `savePicture`)
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '图片保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -131,7 +131,7 @@ struct CustomContainer1 {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -140,13 +140,13 @@ struct CustomContainer1 {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
......@@ -168,24 +168,20 @@ struct SetCircle {
.width('20vp').height('20vp').position({ x: this.x, y: this.y }).visibility(this.isshow)
.fill(Color.Red)
}.onTouch((event: TouchEvent) => {
//console.info('11')
// x坐标
let x = event.touches[0].x
// y坐标
let y = event.touches[0].y
//console.info('this is ' + JSON.stringify(this))
let x = event.touches[0].x;
let y = event.touches[0].y;
if (event.type === TouchType.Down) {
this.x = x
this.y = y
this.isshow = Visibility.Visible
this.x = x;
this.y = y;
this.isshow = Visibility.Visible;
}
else if (event.type === TouchType.Move) {
this.x = x
this.y = y
this.isshow = Visibility.Visible
this.x = x;
this.y = y;
this.isshow = Visibility.Visible;
}
else if (event.type === TouchType.Up) {
this.isshow = Visibility.None
this.isshow = Visibility.None;
}
})
.width('100%').height('80%').backgroundColor(Color.White)
......
......@@ -27,11 +27,11 @@ path1 = path + '/report2';
@Entry
@Component
struct IndexPage {
@State BackColor: string = '#ff808080'
@State ClearAll : boolean = false
private current : number = undefined
@State count : number = 0
@State result : string = ''
@State BackColor: string = '#ff808080';
@State ClearAll : boolean = false;
private current : number = undefined;
@State count : number = 0;
@State result : string = '';
private TestCaseList = [
{title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_PR_0100',uri:'pages/MediaLibrary/startImagePreviewPromise1'},
{title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_PR_0200',uri:'pages/MediaLibrary/startImagePreviewPromise2'},
......@@ -61,7 +61,6 @@ struct IndexPage {
{title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_CB_0200',uri:'pages/MediaLibrary/storeMediaAssetCallback2'},
{title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_CB_0300',uri:'pages/MediaLibrary/storeMediaAssetCallback3'},
{title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_CB_0400',uri:'pages/MediaLibrary/storeMediaAssetCallback4'},
{title:'',uri:'',bgc:Color.Black},
]
@State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080',
'#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080',
......@@ -74,14 +73,14 @@ struct IndexPage {
let results = this.result;
if (this.result === 'Pass'){
this.ColorObject[this.current] = '#ff008000';
filewrite(name1,results,titles)
filewrite(name1,results,titles);
}
else if (this.result === 'Fail'){
this.ColorObject[this.current] = '#ffff0000';
filewrite(name1,results,titles)
filewrite(name1,results,titles);
}
else if (this.result === 'None'){
this.ColorObject[this.current] = this.ColorObject[this.current]
this.ColorObject[this.current] = this.ColorObject[this.current];
}
}
......@@ -93,7 +92,7 @@ struct IndexPage {
Image($r('app.media.ic_public_back')).width('20vp').height('18vp')
}.backgroundColor(Color.Black)
.onClick(() => {
router.back()
router.back();
})
Row(){
Text('MediaLibrary')
......@@ -107,14 +106,14 @@ struct IndexPage {
.height('30vp')
}.backgroundColor(Color.Black)
.onClick(() => {
this.ClearAll = true
this.ClearAll = true;
this.TestCaseList.forEach((value, index) => {
this.ColorObject[index] = '#ff808080'
});
this.ColorObject[index] = '#ff808080';
})
this.ClearText();
prompt.showToast({
message: '结果已删除', duration: 1000
})
});
})
Button(){
Image($r('app.media.ic_public_save'))
......@@ -126,7 +125,7 @@ struct IndexPage {
this.ReadTextParseXml();
prompt.showToast({
message: '报告已生成', duration: 1000
})
});
})
}
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black)
......@@ -138,17 +137,16 @@ struct IndexPage {
Text(this.BackColor.toString()).visibility(Visibility.None)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index])
.onClick(( )=>{
this.count = 1
this.ClearAll=false
this.current = index
console.info('current:'+this.current+'当前背景色:'+this.TestCaseList[index].bgc+'Index:'+index)
this.count = 1;
this.ClearAll=false;
this.current = index;
router.push({
url: item.uri,
})
});
})
}
},item => item.title)
}.width('100%')
}.width('100%').height('92%')
}.width('100%').height('100%').backgroundColor(Color.Black)
}
ClearText(){
......@@ -165,11 +163,9 @@ struct IndexPage {
let RD = fileio.readSync(OP,buf);
console.info("ddddd"+RD);
let report;
function ab2str(buf) {
return report = String.fromCharCode.apply(null, new Uint8Array(buf));
}
ab2str(buf);
let str1 = report.split(";");
let title = [];
......@@ -206,7 +202,7 @@ struct IndexPage {
} finally {
fileIO.closeSync(xmlfd);
}
return
return;
}
}
}
......
......@@ -20,8 +20,8 @@ import image from '@ohos.multimedia.image';
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
const TAG = '[Screenshot]'
let path = globalThis.dir;
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
......@@ -43,7 +43,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -57,7 +57,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -75,10 +75,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -95,35 +95,35 @@ export struct CustomContainer {
}
)
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -131,7 +131,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -140,13 +140,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
......@@ -17,12 +17,12 @@ import prompt from '@ohos.prompt';
import router from '@ohos.router';
import screenshot from '@ohos.screenshot';
import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
let path = globalThis.dir;
const TAG = '[Screenshot]'
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
......@@ -45,7 +45,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -59,7 +59,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -77,10 +77,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -97,35 +97,35 @@ export struct CustomContainer {
}
)
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -133,7 +133,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -142,13 +142,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
......@@ -17,12 +17,12 @@ import fileio from '@ohos.fileio';
import router from '@ohos.router';
import screenshot from '@ohos.screenshot';
import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
let path = globalThis.dir;
const TAG = '[Screenshot]'
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
@Link name : string;
......@@ -41,7 +41,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -55,7 +55,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -73,10 +73,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -91,35 +91,35 @@ export struct CustomContainer {
}
})
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -127,7 +127,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -136,13 +136,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
......@@ -17,11 +17,11 @@ import prompt from '@ohos.prompt';
import router from '@ohos.router';
import screenshot from '@ohos.screenshot';
import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
const TAG = '[Screenshot]'
let path = globalThis.dir;
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
@Link X: number;
......@@ -41,7 +41,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -55,7 +55,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -73,10 +73,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -93,35 +93,35 @@ export struct CustomContainer {
}
)
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -129,7 +129,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -138,13 +138,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
\ No newline at end of file
......@@ -17,11 +17,11 @@ import prompt from '@ohos.prompt';
import router from '@ohos.router';
import screenshot from '@ohos.screenshot';
import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
const TAG = '[Screenshot]'
let path = globalThis.dir;
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
@Link X: number;
......@@ -42,7 +42,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -56,7 +56,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -74,10 +74,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -94,35 +94,35 @@ export struct CustomContainer {
}
)
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -130,7 +130,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -139,13 +139,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
\ No newline at end of file
......@@ -17,11 +17,11 @@ import prompt from '@ohos.prompt';
import router from '@ohos.router';
import screenshot from '@ohos.screenshot';
import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
const TAG = '[Screenshot]'
let path = globalThis.dir;
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
@Link value: string;
......@@ -41,7 +41,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -55,7 +55,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -73,10 +73,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -91,35 +91,35 @@ export struct CustomContainer {
}
})
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -127,7 +127,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -136,13 +136,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
\ No newline at end of file
......@@ -17,11 +17,11 @@ import prompt from '@ohos.prompt';
import router from '@ohos.router';
import screenshot from '@ohos.screenshot';
import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
const TAG = '[Screenshot]'
let path = globalThis.dir;
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
@Link X: number;
......@@ -43,7 +43,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -57,7 +57,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -75,10 +75,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -95,35 +95,35 @@ export struct CustomContainer {
}
)
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -131,7 +131,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -140,13 +140,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
......@@ -17,11 +17,11 @@ import prompt from '@ohos.prompt';
import router from '@ohos.router';
import screenshot from '@ohos.screenshot';
import image from '@ohos.multimedia.image';
import Logger from '../model/Logger'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import Logger from '../model/Logger';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
let path = globalThis.dir
const TAG = '[Screenshot]'
let path = globalThis.dir;
const TAG = '[Screenshot]';
@Component
export struct CustomContainer {
@Link FillColor: string;
......@@ -41,7 +41,7 @@ export struct CustomContainer {
params: {result : 'Pass', title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
@Builder
......@@ -55,7 +55,7 @@ export struct CustomContainer {
params: {result : 'Fail',title : this.name,
}
})
this.getScreen(isFullScreen)
this.getScreen(isFullScreen);
})
}
build() {
......@@ -73,10 +73,10 @@ export struct CustomContainer {
Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'})
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
this.content()
this.content();
Blank()
Row() {
this.PassBtn($r('app.string.btn_fullscreen'), true)
this.PassBtn($r('app.string.btn_fullscreen'), true);
Button(){
Image($r('app.media.ic_public_help')).width('20vp').height('20vp')
}.width('30%').height('30vp').backgroundColor(Color.Grey)
......@@ -93,35 +93,35 @@ export struct CustomContainer {
}
)
})
this.FailBtn($r('app.string.btn_fullscreen'), true)
this.FailBtn($r('app.string.btn_fullscreen'), true);
}.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black)
}.height('98%').width('100%')
}
async savePicture(data: image.PixelMap, context: any) {
Logger.info(TAG, `savePicture`)
Logger.info(TAG, `savePicture`);
let packOpts: image.PackingOption = {
format: "image/jpeg", quality: 100
}
};
let info = {
prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE
}
let name = this.name
let displayName = `${info.prefix}${name}${info.suffix}`
};
let name = this.name;
let displayName = `${info.prefix}${name}${info.suffix}`;
let dirPath = path + '/' + displayName;
let imagePackerApi = image.createImagePacker()
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
let imagePackerApi = image.createImagePacker();
let arrayBuffer = await imagePackerApi.packing(data, packOpts);
let fd = fileio.openSync(dirPath,0o102,0o666);
imagePackerApi.release()
imagePackerApi.release();
try {
await fileio.write(fd, arrayBuffer)
await fileio.write(fd, arrayBuffer);
} catch (err) {
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`write failed, code is ${err.code}, message is ${err.message}`);
}
await fileio.close(fd)
Logger.info(TAG, `write done`)
await fileio.close(fd);
Logger.info(TAG, `write done`);
prompt.showToast({
message: '结果保存成功', duration: 1000
})
});
}
getScreen = (isFullScreen: boolean) => {
let screenshotOptions: screenshot.ScreenshotOptions = {
......@@ -129,7 +129,7 @@ export struct CustomContainer {
imageSize: { width: 400, height: 400 },
rotation: 0,
displayId: 0
}
};
if (isFullScreen) {
screenshotOptions = {
rotation: 0
......@@ -138,13 +138,13 @@ export struct CustomContainer {
try {
screenshot.save(screenshotOptions, (err, data: image.PixelMap) => {
if (err) {
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`)
Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`);
}
Logger.info(TAG, 'save callback')
this.savePicture(data, getContext(this) as any)
Logger.info(TAG, 'save callback');
this.savePicture(data, getContext(this) as any);
})
} catch (err) {
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`)
Logger.error(`save failed, code is ${err.code}, message is ${err.message}`);
}
}
}
......@@ -56,7 +56,7 @@ struct IndexPage {
this.ClearText();
prompt.showToast({
message: '所有结果已删除', duration: 1000
})
});
})
Button(){
Image($r('app.media.ic_public_save'))
......@@ -68,7 +68,7 @@ struct IndexPage {
this.SaveXml();
prompt.showToast({
message: '总报告已生成', duration: 1000
})
});
})
}
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%')
......
......@@ -24,12 +24,12 @@ export default class FirstDialog{
let promise = data_preferences.getPreferences(context,'mystore');
await promise.then((object) => {
preferences = object;
})
});
promise = preferences.get(name, 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'startup'. Data: " + data);
})
});
if(Test != 1) {
AlertDialog.show(
{
......@@ -41,11 +41,11 @@ export default class FirstDialog{
let promise = preferences.put(name, 1);
promise.then(() => {
console.info("Succeeded in putting value of 'test'.");
})
});
promise = preferences.flush();
promise.then(() => {
console.info("Succeeded in flushing.");
})
});
}
},
secondaryButton: {
......@@ -60,6 +60,6 @@ export default class FirstDialog{
}
)
}
return
return;
}
}
\ No newline at end of file
......@@ -12,33 +12,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog'
import hilog from '@ohos.hilog';
class Logger {
private domain: number
private prefix: string
private format: string = "%{public}s, %{public}s"
private domain: number;
private prefix: string;
private format: string = "%{public}s, %{public}s";
constructor(prefix: string) {
this.prefix = prefix
this.domain = 0xFF00
this.prefix = prefix;
this.domain = 0xFF00;
}
debug(...args: any[]) {
hilog.debug(this.domain, this.prefix, this.format, args)
hilog.debug(this.domain, this.prefix, this.format, args);
}
info(...args: any[]) {
hilog.info(this.domain, this.prefix, this.format, args)
hilog.info(this.domain, this.prefix, this.format, args);
}
warn(...args: any[]) {
hilog.warn(this.domain, this.prefix, this.format, args)
hilog.warn(this.domain, this.prefix, this.format, args);
}
error(...args: any[]) {
hilog.error(this.domain, this.prefix, this.format, args)
hilog.error(this.domain, this.prefix, this.format, args);
}
}
export default new Logger('[Screenshot]')
\ No newline at end of file
export default new Logger('[Screenshot]');
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册