flex作图
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
minWidth="1024" minHeight="768" xmlns:mx1="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import flash.geom.Matrix;
/*
画图形之前必要调用的函数(其中之一即可):
linestyle()、beginFill()、lineGradientStyle()、beginGradientFill()、beginBitmapFill()方法来设置线条样式和/或填充。
*/
//画矩形
private function rect(rectX:Number, rectY:Number, rectWidth:Number, rectHeight:Number):void{
rectBoxID.graphics.clear();
if(radioLineID.selected){ //线性
rectBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
}else if(radioGradientID.selected){ //渐变
var matr:Matrix = new Matrix();
matr.createGradientBox(20, 20, 0, 0, 0);
//the last parameter can selete three type: SpreadMethod.PAD or SpreadMethod.REFLECT or SpreadMethod.REPEAT.
rectBoxID.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x00FF00], [1, 1], [0x00, 0xFF], matr, SpreadMethod.REPEAT);
}else if(radioFullID.selected){ //填充
rectBoxID.graphics.beginFill(0xFF0000, 1.0);
}
rectBoxID.graphics.drawRect(rectX, rectY, rectWidth, rectHeight);
//
}
//画圆角矩形
private function circleRect(cRectX:Number, cRectY:Number, cRectWidth:Number, cRectHeight:Number, cRectDU:Number):void{
cRectBoxID.graphics.clear();
if(radioLineID.selected){ //线性
cRectBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
}else if(radioGradientID.selected){ //渐变
//the last parameter can selete three type: SpreadMethod.PAD or SpreadMethod.REFLECT or SpreadMethod.REPEAT.
cRectBoxID.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x0000FF], [1, 0.1], [0, 255], new Matrix(), SpreadMethod.PAD);
rectBoxID.graphics.endFill();
}else if(radioFullID.selected){ //填充
cRectBoxID.graphics.beginFill(0xFF0000, 1.0);
}
cRectBoxID.graphics.drawRoundRect(cRectX, cRectY, cRectWidth, cRectHeight, cRectDU);
}
//画直线
private function line(lineX:Number, lineY:Number):void{ //两个参数都表示从起始的位置坐标x、y相加这两个参数后值就是结束的x、y值
lineBoxID.graphics.clear();
if(radioLineID.selected){ //线性
lineBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
}else if(radioGradientID.selected){ //渐变
lineBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
lineBoxID.graphics.lineGradientStyle(GradientType.LINEAR, [0xFF0000, 0x0000FF], [1, 0.5], [0, 255], new Matrix(), SpreadMethod.PAD);
}else if(radioFullID.selected){ //(填充)直线不存在填充的,呵呵
lineBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
}
lineBoxID.graphics.lineTo(lineX, lineY);
}
//画曲线
private function cLine(endX:Number, endY:Number):void{
cLineBoxID.graphics.clear();
if(radioLineID.selected){ //线性
cLineBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
}else if(radioGradientID.selected){ //渐变
var matr:Matrix = new Matrix();
matr.createGradientBox(20, 20, 0, 0, 0);
cLineBoxID.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x00FF00, 0xFF0000], [0.2, 1, 1], [0, 128, 255], matr, SpreadMethod.REFLECT);
}else if(radioFullID.selected){ //填充
cLineBoxID.graphics.beginFill(0xFF0000);
}
cLineBoxID.graphics.curveTo(100, 80, endX, endY); //前两个参数表示弧度的偏移量,后两个参数表示结束点的x、y坐标
}
//画圆
private function circle(oX:Number, oY:Number, radius:Number):void{
circleBoxID.graphics.clear();
if(radioLineID.selected){ //线性
circleBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
}else if(radioGradientID.selected){ //渐变
var matr:Matrix = new Matrix();
matr.createGradientBox(20, 20, 0, 0, 0);
circleBoxID.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x00FF00, 0xFF0000], [0.2, 1, 1], [0, 128, 255], matr, SpreadMethod.REFLECT, "rgb", 0.7);
}else if(radioFullID.selected){ //填充
circleBoxID.graphics.beginFill(0xFF0000);
}
circleBoxID.graphics.drawCircle(oX, oY, radius);
}
//画椭圆
private function tCircle(x:Number, y:Number, tWidth:Number, tHeight:Number):void{
tCircleBoxID.graphics.clear();
if(radioLineID.selected){ //线性
tCircleBoxID.graphics.lineStyle(20, 0xFF0000, 1.0, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 100);
}else if(radioGradientID.selected){ //渐变
var matr:Matrix = new Matrix();
matr.createGradientBox(20, 20, 0, 0, 0);
//the last parameter can selete three type: SpreadMethod.PAD or SpreadMethod.REFLECT or SpreadMethod.REPEAT.
tCircleBoxID.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x00FF00], [1.0, 1.0], [0x00, 0xFF], matr, SpreadMethod.REPEAT);
}else if(radioFullID.selected){ //填充
tCircleBoxID.graphics.beginFill(0xFF0000);
}
tCircleBoxID.graphics.drawEllipse(x, y, tWidth, tHeight);
}
]]>
</fx:Script>
<!--画矩形-->
<mx1:Button id="rectButID" x="500" y="50" label="画矩形" click="rect(100, 20, 250, 50);"/>
<mx1:Box id="rectBoxID"/>
<!--画圆角矩形-->
<mx1:Button id="cRectButID" x="500" y="120" label="画圆角矩形" click="circleRect(100, 100, 300, 80, 50);"/>
<mx1:Box id="cRectBoxID"/>
<!--画直线-->
<mx1:Button id="lineButID" x="500" y="250" label="画直线" click="line(350, 0);"/>
<mx1:Box id="lineBoxID" x="50" y="250"/>
<!--画曲线-->
<mx1:Button id="cLineButID" x="500" y="350" label="画曲线" click="cLine(300, 0);"/>
<mx1:Box id="cLineBoxID" x="100" y="300"/>
<!--画圆-->
<mx1:Button id="circleButID" x="500" y="450" label="画圆" click="circle(250, 450, 50);"/>
<mx1:Box id="circleBoxID"/>
<!--画椭圆-->
<mx1:Button id="tCircleButID" x="500" y="550" label="画椭圆" click="tCircle(120, 520, 150, 50);"/>
<mx1:Box id="tCircleBoxID"/>
<mx1:RadioButton id="radioLineID" x="600" y="50" label="线性"/>
<mx1:RadioButton id="radioGradientID" x="750" y="50" label="渐变" selected="true"/>
<mx1:RadioButton id="radioFullID" x="900" y="50" label="填充"/>
</s:Application>
flex作图的更多相关文章
- 9款国内外垂直领域的在线作图工具:那些可以替代Visio的应用!【转】
http://www.csdn.net/article/2015-02-12/2823939 摘要:现在越来越多的创业公司都希望提升办公的效率,今天介绍的几款也能提升办公效率,不过它们都属于垂直领域的 ...
- flex 和bison的安装和使用
1.在ubutu上安装 yacc的命令: sudo apt-get install flex bison flex:词法分析器 flex是一个词法分析器.用来将一个.l文件生成一个.c程序文件.即生成 ...
- OpenCASCADE Expression Interpreter by Flex & Bison
OpenCASCADE Expression Interpreter by Flex & Bison eryar@163.com Abstract. OpenCASCADE provide d ...
- Flex 布局教程:语法篇
作者: 阮一峰 网页布局(layout)是CSS的一个重点应用. 布局的传统解决方案,基于盒状模型,依赖 display属性 + position属性 + float属性.它对于那些特殊布局非常不方便 ...
- Flex 布局教程:实例篇
该教程整理自 阮一峰Flexible教程 今天介绍常见布局的Flex写法.你会看到,不管是什么布局,Flex往往都可以几行命令搞定. 我的主要参考资料是Landon Schropp的文章和Solved ...
- CSS布局之div交叉排布与底部对齐--flex实现
最近在用wordpress写页面时,设计师给出了一种网页排布图样,之前从未遇到过,其在电脑上(分辨率大于768px)的效果图如下: 而在手机(分辨率小于等于768px)上要求这样排列: 我想到了两种方 ...
- Flexible 弹性盒子模型之flex
实例 让所有弹性盒模型对象的子元素都有相同的长度,忽略它们内部的内容: #main div { flex:1; } 复制 效果预览 浏览器支持 表格中的数字表示支持该属性的第一个浏览器的版本号. 紧跟 ...
- 信息系统实践手记6-JS调用Flex的性能问题一例
说明:信息系统实践手记系列是系笔者在平时研发中先后遇到的大小的问题,也许朴实和细微,但往往却是经常遇到的问题.笔者对其中比较典型的加以收集,描述,归纳和分享. 摘要:此文描述了笔者接触过的部分信息系统 ...
- flex自适应高度内容高度超出容器高度自动出现滚动条的问题
在容器中设置 flex-grow:2; overflow-y:auto;overflow-x:hidden;容器高度自适应. 内容高度不固定,无法出现滚动条,然后在容器中添加height:0,出现滚动 ...
随机推荐
- git常用命令简集
基础操作: 初始化git仓库: git init 提交到暂存区: git add “filename” 提交到分支: git commit -m "注释" 工作区状态: git s ...
- javascript 关于new()继承的笔记
近期的一些学习总结,如有错误不严谨地方,希望指正! 使用new操作符会有如下操作: 1.创建一个对象temp = {}, 2. temp.__proto__ = A.prototype, 3. A.c ...
- gitlab的仓库迁移到新的gitlab
1.下载原有gitlab源码 git clone http://gitlab.**.com/projectName gitlab地址替换成为新gitlab地址 git remote set-url o ...
- [C++] 用Xcode来写C++程序[1] 新建C++项目工程
用Xcode来写C++程序[1] 新建C++项目工程 第一节从新建工程并编译C++源码开始 新建工程 源码: // // main.cpp // YeHelloWorld // // Created ...
- Composer 的简介、安装及使用
Composer的简介 简单说,Composer 就是一个安装包管理工具,服务于 PHP 生态系统.它包括了两个部分:Composer 和 Packagist. Composer Composer 是 ...
- Springboot 设置session超时
使用版本 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring ...
- RTCM32编解码中的一些概念及相关文献阅读
1. IODC和 IODE —— 导航电文相关.iode/iodc是在GPS系统的ICD2中定义的参数,iode指星历数据事件,iodc指星钟数据事件. IOD 是 issue of data ,数 ...
- 题解 P1894 【[USACO4.2]完美的牛栏The Perfect Stall】
题面 农夫约翰上个星期刚刚建好了他的新牛棚,他使用了最新的挤奶技术.不幸的是,由于工程问题,每个牛栏都不一样.第一个星期,农夫约翰随便地让奶牛们进入牛栏,但是问题很快地显露出来:每头奶牛都只愿意在她们 ...
- 个人作业2——集大通APP案例分析
个人作业2——集大通APP案例分析 产品:集大通 我认为这个是我们学校的APP,我们应该支持一下. 一.个人体验 1.下载并使用,描述最简单直观的个人第一次上手体验. ①界面美观,可以感受到丰富的校园 ...
- jQuery获取radio选中项checked的几种方法
如何知道radio哪个选项被选中了,也就是获取checked的radio项.这是个很简单的任务,这里我总结了几个常用的方法,体验一下jQuery的灵活. 具体的 HTML 和 jQuery 代码可以右 ...