绘制椭圆很容易绘制,要旋转的话,可以试一下SetWorldTransform函数。
一个简单示例程序:
这个用GDI+做起来可能会更简单,因为GDI+中有一些矩阵运算的类。
artificial leather人造革
baseball leather棒球革
basketball leather篮球革
bellow leather风箱革
belt leather带皮
belting leather带革; 轮带
book-binding leather书面革
bottom leather底革
boxing-glove leather拳击手套革
buck leather(雄)鹿革
buckle leather带用革
buffed leather磨面革
butt leather底革
card leather梳革
case leather箱皮
charred leather皮炭
chamois leather麂皮
chrome leather铬革
chrome tanned leather铬鞣革
clothing leather服装革
combination tanned leather结合鞣制的革
combing leather梳刷革
cow leather牛皮
crown leather上等皮革
crup leather马臀革
crust leather坯革; 半硝革
cup leather制动缸皮碗
diaphragm leather隔膜革[皮]
dogskin leather狗皮(制的)革
dressing leather饰革
drum leather鼓皮
drycleanable leather耐干洗革
easy-care leather易保养革
embossed leather压花革
enamel leather漆皮
enamelled leather漆皮
fair leather集市皮革
fancy leather美术革, 装饰用革
finished leather成革; 整饰过的皮革
football leather足球革
football-helmet leather橄榄球头盔革
furniture leather家具革
garment leather衣服革
Russia(n) leather俄罗斯革
saddle leather鞍皮[革]
saffian leather山羊革; 摩洛哥革
scrap leather废皮; 碎皮
semi-aniline leather半苯胺革
semi-chrome leather混合铬鞣革
sheep leather(绵)羊革
shrink leather皱纹革
skirt leather植物鞣牛皮坯革
slick-surfaced leather光面皮革
soccerballleather足球革
softleather软革
soleleather底革
stirrup leather镫革
strop leather磨刀皮革
suede leather起毛皮革
sweat band leather(帽中)汗带皮
synthetic leather合成皮带
textile machinery leather纺织机用革
tie and dye leather扎染革
two-tone leather双色调革
upholstery leather装饰用皮革
upper leather面革
valve leather阀皮
vegetable tanned sole leather植物鞣鞋底革
velvet leather正绒面革
zirconium tanned leather锆鞣革
volleyball leather排球革
wash leather可洗皮革
washable chamois leather可洗麂皮
welting leather镶边革; 贴边革
white leather白革; 矾鞣革
制革工艺 专业术语
Ironning 熨平 (烫光)
Sudding 刮皮 推挤净面
Conditioning 调节 回潮
Thickness 皮厚度鞋面革
Upper 重革 (植鞣革)
Heavy leather 阳离子染色
Aniline leather 苯胺革
aniline finish 苯胺涂饰
Oiling 加油
Grease stain 油斑
Caging 转笼摔软
Toggling 绷板
Sulfited oil 亚硫酸化油
Antique finish 仿古涂饰
Imitation leather 人造革
Clothing(Garment) leather 服装革
Irregular pattern 不规则花纹
Color matching 调色
Fixine of dye 染料的
Fleshing 去肉
Shaving 削匀 削薄
Splitting 片皮
Wool grease 羊毛脂
Wool skin 绵羊皮
Emulsion 乳浊液 乳液
Ellagtannin 加水型分解丹宁
Elastin 弹性蛋白
Salt soluble protein 盐溶性蛋白
Dry salted hide 盐干板(皮)
Basic chromium salt 盐基性铬盐
Basic dye (dyestuff) 盐基性染料
Basicity 盐基度
Setting out 延伸
Wet salted hide(skin) 盐生皮
Curling 防腐 ,保存
Salt cured hide(skin) 盐腌皮
Trimming 修边
Salt stain 盐斑
Embossing 压花
Saw dusting 锯末回潮
Invoice 发票
Opening-up (皮纤维结构)松散
Surface active agent 表面活性剂
Cow hide 母牛皮
Leather 皮革
Fumiture leather 家具革
Tip (Top cap) 装饰革
Fatliquoring oiling 加脂
Casual shose 轻便鞋(运动)鞋
Hydrolysis 加水分解
Hydrolysable tannin 加水分解丹宁
Cascin finish 酪素涂饰
Cationic dye 阳离子染料
Calf skin 小牛皮
Beam 刮皮板
Soluble collagen 可溶性胶原
Color index 染色指南
Milling 干滚
Pasted drying(Pasting) 贴板干燥
Pasted leather (Corrected 贴板干燥革
Grease stain)
Hang drying 悬挂干燥
Crust leather 悬挂干燥革
Coloor matching 调色
Leather wear 皮革衣料
Kangaroo leather 袋鼠皮革
Metal complex dye(dyestuff) 金属染料
Reduction 还原
Drying oil 干性油
Country hide 乡村的原皮
Pigment 颜料膏
Pigment finish 颜料膏涂饰
Kid skin 小山羊皮
Kip skin 中牛皮
Grain pattern 粒纹图案
Cattle hide 成牛皮
Neats-foot oil 牛蹄油
Tallow 牛脂
Globular protein 球状蛋白质
Water absorption 吸水性
Killing 脱脂
Loose grain 松面
Levelling agent 均染剂
Grain 正面
Grain crcking test 表面列面试验
Shose cream 鞋油
Grub 牛氓幼虫
Glyceride 甘油脂
Glycerin(Glycerol) 甘油丙三醇
Cleaner 清洁剂(皮鞋)
Green hide 鲜皮
Glutaraldehyde 戊二醛
Glace kid 光面小山羊皮
Glazing 打光
Crockmeter 摩檫掉色试验
Crop 前肩背革 剪毛 半张底革
Clove 手套
Clove leather 手套革
Deer skin 鹿皮
Buck skin 鹿革
Color difference 颜色差
Curing 防腐(保存)处理
Humidity 湿度
Automobile leather (Car 汽车革
sheet leather)
Domestic hide and skin 本地皮 国产皮
Flexibility 曲扰性 柔韧性
Tempering (植物) 退鞣
Vegetable tannage 植物鞣 (法)
Break 里面褶纹
Fat 脂肪
Boarding 搓纹
Oxalic acid 草酸 已二酸
Fullness 丰满度
Sodium bicarbonate 碳酸氢钠 小苏打
Softness 柔软性
Astringency 收敛性
Condensed tannin 缩合丹宁
Resin tannage 树脂鞣 (法)
Shrink leather 皱纹革
Beamhouse process 准备工序
Beamhouse work 准备操作
Slaked lime 熟石灰
Epithelial tissue 皮上组织
Vegetable tannage 植物丹宁(鞣法)
Short pickling 快浸
Shoulder 颈肩部 ,边
Silicone resin paint 含硅树脂涂料
Zirconium tannage 铬鞣(法)
Vacumm durying 真空干燥
Pickling 浸酸
Dip dyeing 浸染
Syntan 合成植物鞣剂
Osmotic pressure 浸透压
Thinner 稀释剂
Water buffalo hide 水牛皮
Calcium hydroxide 氢氧化钙
Soium hydroxide 氢氧化钠
Hydrogen ion concentration 氢离子浓度
Hydrogen bond 氢键结合
Suede 正反绒革
Skiver 片茬
Shaving Splitting 片皮 剖层
Skin 小皮
Scouring (毛皮)脱脂
Stacker 搭马机
Stuffing 加脂
Steer 犍牛
Steer hide 犍牛皮
Staking 拉软
Spew (Spue) 油霜
Splitting 喷枪
Spray dyeing 喷染(法)
Spray coating 喷涂
Smooth 熨平 打光
Slunk 沉淀
Sulfonated oil 死胎皮
Cattle hide 磺化油
Upper 鞋面缝制
Lime pit 石灰槽
Liming 浸灰
Painting (Paint liming) 涂糊脱毛(法)
Lime stains (Lime-blast) 灰斑
Lime plte 灰皮
Soap 肥皂
Adhesive (Glue) 粘接剂
Setting out 伸展 推平
Semi aniline finish 半苯胺整饰
Dyeing 染色
Color fastness 染色牢度
Dyeing auxiliary 助染剂
Flieshing knife 刮肉刀
Shering 剪毛
Dye (Dyestuff) 染料
Sole leather 底革
Sloft leather 软革
Flexing endurance test 耐曲折试验
Drum 转古
Light fastness (Light 耐光性
resistance , Light stability)
Weather resistance ( 耐老化性
Weathering , Weatherproof)
Water resistance(Water proof) 耐水性
Heat resisting property 耐热性
Abrasion resistance 耐磨性
Deliming 脱灰
Depickling 脱酸
Degreasing 脱脂
Deannage (Deannin) 退鞣
Unhairing (Depilation,Dehairing) 脱毛
Sodium hydrogen carbonate 碳酸氢钠
Sodium carbonate 碳酸钠
Carbohydrate 碳水化合物
Elastic fiber 弹性纤维
Tanner 制革工人
Tannin 丹宁
Vegetable tanned leather 植物鞣革
Vegetable tannage 植物鞣(法)
Chrome leataer 铬鞣革
Chromium complex 铬盐络合 铬盐络合物
Chrome splits 兰板革
Chrome tanning(Chrome tannage) 铬鞣法
Hair 毛
Follicle mouth 毛孔
Fur 毛皮
Quebracho 坚木
Keratin 角蛋白
Gel 凝胶(体)冻胶
Raw hide and skin 原皮
Raw stock 原料皮
Bating 软化
Synthetic fatliquoring agen 合成加脂剂
Hard water 硬水
Synthetic tanning agent 合成鞣剂
Composition sole 合成皮革
Synthetic tanning 合成植物鞣剂
Synthetic leather 合成底
Enzyme 酶化剂
Enzyme unhairing 酶脱毛
Scleroprotein(Albuminoid) 硬蛋白质
Firmness 硬度
Mineral tannage 金属鞣法
Bristle 猪鬓 鬓毛
Coating 涂饰
Edge 包条 底边 包边
Collagen 胶原
Corium 真皮
Conditioner 调节器
Bacteria 细菌
Retannage 复鞣
Side 半张 片
Side leather 半张牛皮 一片牛皮
Ccirculator 植鞣循环剂
Guard hair 真毛 保护毛
Suspender 悬挂
Oxidation 氧化
Chromic oxide 氧化铬
Oxidation dye 氧化染料
Oxidative unhairing 氧化脱毛
Titanium oxide 二氧化钛
Industrial waste 生产废物
Acid dye(dyestuff) 酸性染料
Acidity 酸度
Sandwitch dyeing 夹层染色
Buffing paper(Sand paper) 砂纸
Goat or kid skin 山羊皮
Finishing 涂饰
Shaved weight 削匀革重
Protein 蛋白质
Chestnut 栗木
Sodium thiosulfate 硫代硫酸钠 大苏打
Cheeking 片头皮
Veininess 血管 痕 血筋
Tick 肩虱
Green hide 鲜皮
Neutralization 中和
Direct dye (dyestuff) 直接染料
Air permeability 透气性
Measuring machine 量革机
Glazing Ironning 打光
Lasting (Pulling over) 绷帮 装楦
Touch 手感
Fixing 固定
Iron stains 黑(铁)斑
Oiling 加油
Glove 手套
Glove leather 手套革
Swaber 刷浆 刷子
Natural dye 天燃料
Isoelectric point 等电点
Kerosene 煤油
Toxicity 毒性
Toggling 绷扳
Split 二层革
Suede split 二层反绒革
Pigment finish 颜料涂饰剂
Slaughter house 屠宰场
Topping 顶层涂饰
Top coating 顶涂
Wrinkle 皱纹 起皱
Drycleaning 干洗
Drum 转古
Drum dyeing 转古染色
Drum liming 转古脱毛(法)
Trypsin 胰蛋白酶
Trimming 修边(皮,耳,蹄,尾)
Paint 涂料
Dressing 整饰
Tunnel dryer (Conveyor dryer) 隧道干燥机
Sock lining 垫 后跟垫
Insole 内底
Nappa (leather) 全粒面软革
Nap finish] 软面革涂饰
Raw oil 天然植(动)物油
Tanning (Tannage) 鞣制
Ssoft water 软化水
Flesh side 肉面
Nitrocellulose finish 消化棉涂饰
Emulsion 乳化
Fatliquoring 乳化加脂
Papillary layer 乳头层
Nubuck 正绒面革
Case leather 箱包革
Thermoplastic resin 热可塑性树脂
Thermosetting resin 热硬化型树脂
Shrinkage temperature 收缩温度
Elongation at break 断裂伸长
Hide processer 倾斜转古
Hidroxyproline 羟基脯氨酸
Vibration staking machine 震动拉软机
Binder 粘合剂
Flaying (Skinning ,Take off) 剥皮
Peel adhesion strength ( 剥离强度
Peel bond strength)
Table dyeing (Brush dyeing) 涂刷染色
Water repellency 斥水性
Patent leather 漆革
Paddle 划槽
Paddle liming 划槽脱毛(法)
Buffing 磨革 起绒
Buffing dust 磨革革灰
Pcarlised leather 珍珠白涂饰
Bursting strength test 崩裂强度试验
Side 半张
Hand buff 修面革
Nonionic surfactant 非离子活性剂
Subcutaneous tissue 皮下组织
Tear strength 撕裂强度
Specific gravity 比重
Pit 池 ,槽
Tensile sttength 抗张强度
Beamhouse 准备车间
Bleaching 漂白
Epidermis 表皮
Handle 手感(革)
Fellmongering 去毛
Putrefaction 腐败
Primer (Priming agent) 底层涂饰剂
Bule 兰扳革
Full grain 全粒面
Full chrome leather 纯铬革鞣
Hair slip 掉毛
Base coat 底涂 底涂层
Staking 拉软
Belly 腹 腹边皮
Pelt 裸皮
Swelling 膨胀
Sodium sulfate 芒硝
Water proof finishing(finish) 防水加工
Water proofing agent 防水剂
Antifungal agent 防腐剂
Heat retaining property 保温性
Leather oil 皮革用油
Box finish
Boarding 搓纹
Baume 波美
Formalsehyde 戊二醛
Pretannage 预鞣
Masking agent 蒙囿剂
Matt finish 消光整饰
Whole hide 整张皮
Sammying 挤水
Wetting-back (Soaking) 回潮
Mineral oil 矿物油
Mimosa 荆树
Alum tannage (Alum dressing) 明矾鞣(法)
Mineral tannage agent 无机鞣剂
Hair root 毛根
Reticular layer 网状层
Hair follicle 毛囊
Wool grease 羊毛脂
Preliminary fatliquoring 预加脂
Lime splitting 片灰皮
Lacquer 涂漆
Lacquer finish 涂漆饰
Sodium sulfide 硫化钠
Sulfuric acid 硫酸
Ammonium sulfate 硫酸铵
Sulfated oil 硫酸化油
Sodium sulfate 硫酸钠
Phosphated oil 磷酸化油
Leather board 再生革(扳)
Retannage 复鞣
Rolling 打光 滚压
Wax finish 上蜡 蜡涂饰
Wattle 荆树 荆条
Toluene 甲苯
Pull-up 变色效应
Formodehyde 甲醛
Polishing 抛光
Matt 消光
Roll coater 滚涂机
Sanple 样品
Sand 金砂板
Oxalic acid 草酸
Acetone 丙醇
adhered 粘贴
adjust 调整
aluminum 铝
assembling 装配;成型
backing 涂层
back stitch 回针
base 底部
bating 酵解软化
bias 斜线
binding 沿条;包边
bottom 底部
braided 编成辫子形的(麻花状的)
break stitch 断针
buffing 磨皮
calendered 压延
carving 雕刻
cementing 胶接;上糊;粘合
cleaning 清洁;清洗
coated;coating 涂层;烤漆
coloration 染色
combining (使)结合;复合
conditioning 回湿
cooling 冷却
counter lasting 攀后帮
cut 切,剪
cutting 切断;裁断
dampproof 防潮
deformation 变形;走样
density 密度
depigmentation 褪色
design sketch 设计图
diamond 菱形
direction 方向
discharge print 拔色印刷
dry operation 干场作业
drying 干燥
electroplating 电镀
embroidery 刺绣;绣花
exposed 无掩蔽的
extruded 挤压;压出的
fabric 面料;布,织物
fast colours 不褪色;色泽牢固
finishing 修整;整饰;磨光
fixing 整理
flat 扁平的
fleshing (制革时)削肉
folding 叠边,卷边,拗边;修边
forepart lasting 腰帮
friction 摩擦;摩擦力
from 从
front 前面
galvanization 镀锌, 电镀
gluing 帖合;粘合
grading 分级
grind edge of sole 磨鞋边
handsewn 手工缝制
hard 硬的
hard 硬
hardness 硬度
heary 重
heat transfer 加热转移
heating&drying 加热烘干
height 高
inner box 内盒
insert 插入
insole staple on last 入中底于楦上
interior/outer 内/外部
jacquard 提花
jel print 胶体印刷
last slipping 脱楦
lasting 入楦;成型
left 左
length 长度
letter 文字
leveling 铲平
light 轻
loose thread 剪线头
match color 配色
measuring 量皮
mold prevention 防霉
non-crushable 耐皱的
operation 操作
oval 椭圆
packing 包装
painting 入漆,上油漆
patch 片
perforation 穿孔;打孔
picking 浸酸
pipping cord 衬条
plaid 格子
polishing 磨(抛, 擦, 打)光, 磨料
portion 一部分
pounding 整形
pre-shrunk 防缩
pressed 压
primering 药水处理
print;printing 印刷
provided 提供
pull-out 拔钉
pull-out last 拔楦
punching 冲孔
put-on last 入楦
rear 后面
repair cementing 补胶
repeated 重复
retanning,coloring 再鞣,染色
right 右
round 圆
rubberized 贴胶的,上胶的,涂胶的
rubber patch 滴塑
rubber label 滴唛
same 相同的
sanforized 经过预缩水处理过的
screen 屏蔽
self fabric pipping 本布包骨
setting 定型
setting out 张皮
shape 形状
shrink 收缩;缩水
siping 切沟
skiving 削皮
slugging 切口
small 小的
snaps 纽扣
soaking 浸水
sock laying 塞鞋垫
soft 软
sole laying 贴底
sole press 压底
splitting and shaving 起层及削里
sponge 发泡;海绵
squared 正方形
staking 铲软
stamp 印花;烫印
stitched;stitching 缝纫;针车
stripe 条纹
taffeta 平纹
tanning 鞣制
thick 厚的
thickness 厚度
thin 薄的
tight 紧
tissue paper 薄纸;塞纸
toe lasting 攀前帮
toe skiving 磨鞋头
topping
trimming and sorting 削整及分皮
turn 变;转动
twill 斜纹
unhairing 脱毛
volatilization 挥发
vulcanized 硫化
wash care information 洗涤说明
waxing 打蜡
weight 重量
wet operation 湿场作业
width 宽度
wrapping 攀帮
wringing 挤水
zigzag Z字型
artificial leather人造革
baseball leather棒球革
basketball leather篮球革
bellow leather风箱革
belt leather带皮
belting leather带革; 轮带
book-binding leather书面革
bottom leather底革
boxing-glove leather拳击手套革
buck leather(雄)鹿革
buckle leather带用革
buffed leather磨面革
butt leather底革
card leather梳革
case leather箱皮
charred leather皮炭
chamois leather麂皮
chrome leather铬革
chrome tanned leather铬鞣革
clothing leather服装革
combination tanned leather结合鞣制的革
combing leather梳刷革
cow leather牛皮
crown leather上等皮革
crup leather马臀革
crust leather坯革; 半硝革
cup leather制动缸皮碗
diaphragm leather隔膜革[皮]
dogskin leather狗皮(制的)革
dressing leather饰革
drum leather鼓皮
drycleanable leather耐干洗革
easy-care leather易保养革
embossed leather压花革
enamel leather漆皮
enamelled leather漆皮
fair leather集市皮革
fancy leather美术革, 装饰用革
finished leather成革; 整饰过的皮革
football leather足球革
football-helmet leather橄榄球头盔革
furniture leather家具革
garment leather衣服革
gas meter leather气表革
glace leather白鞣革
glove leather手套皮
hair-on leather带毛革
half leather半皮面装订, 半革装
harness leather马具革
hat leather制帽革
hat sweatband leather帽圈革
heavy leather厚革
heel leather(鞋)后跟皮
hunting leather粗绒面革
hydraulic leather水压机革(密封用革)
imitation leather充牛皮装订, 漆布装订, 人造革装订
industrial leather工业用革
iron tanned leather铁鞣革
japanned leather漆皮
kangaroo leather袋鼠革
kaspine leather开斯宾革
levant leather皱纹革; 摩洛哥革
light leather轻革
line leather马具革
lining leather衬里革
luggage leather箱包革
mountain leather石棉
napped leather绒毛皮革
oar leather桨革
oil seal leather油封革
oiled leather涂油革
oil-tanned leather油鞣革
organ-pipe leather风琴管革
packing leather皮碗
paper based artificial leather纸基人造革
patent leather漆皮
patent leather漆革
piano leather钢琴革
piston packing leather活塞填密皮
plated leather熨压皮革
portmanteau leather旅行皮包革
rein leather马具革
rock leather一种石棉
rolled leather轧制革
roller leather机轴革
rough-tanned leather粗鞣革
rubbing leathers纺搓条皮圈
Russia(n) leather俄罗斯革
saddle leather鞍皮[革]
saffian leather山羊革; 摩洛哥革
scrap leather废皮; 碎皮
semi-aniline leather半苯胺革
semi-chrome leather混合铬鞣革
sheep leather(绵)羊革
shrink leather皱纹革
skirt leather植物鞣牛皮坯革
slick-surfaced leather光面皮革
soccerballleather足球革
softleather软革
soleleather底革
stirrup leather镫革
strop leather磨刀皮革
suede leather起毛皮革
sweat band leather(帽中)汗带皮
synthetic leather合成皮带
textile machinery leather纺织机用革
tie and dye leather扎染革
two-tone leather双色调革
upholstery leather装饰用皮革
upper leather面革
valve leather阀皮
vegetable tanned sole leather植物鞣鞋底革
velvet leather正绒面革
zirconium tanned leather锆鞣革
volleyball leather排球革
wash leather可洗皮革
washable chamois leather可洗麂皮
welting leather镶边革; 贴边革
white leather白革; 矾鞣革
如何基于C#实现椭圆绘制
马燕鹏 王文新
通常所用的光栅显示器可看成是一个像素点阵的集合,绘图软件绘制椭圆就是在此集合中寻找最逼近椭圆弧的点并按给定颜色显示的过程。输入参数一般为椭圆的外接矩形而非椭圆方程,但可通过该矩形算出它的长、短半轴和椭圆中心,即得到了所绘椭圆的方程。
由于标准椭圆(中心在原点的椭圆)具有对称性,找到第一象限的逼近点根据对称关系就可得到其他象限的逼近点,所以绘制椭圆时先寻找对应标准椭圆的逼近点,然后平移回椭圆的中心,从而能够简化计算提高效率。
标准椭圆的方程为 ,即 。对其求导得,可见椭圆弧的斜率从0到。以斜率 即 为界把椭圆弧分成两部分,第一部分可得 , 的变化量小于的变化量,应以递增步长来确定,第二部分可得,的变化量小于的变化量,应以递增步长来确定。
对于第一部分,假设已知点为则下一点在其右方点或右下方点中选择离椭圆弧最近的点,而为右方点到椭圆弧的距离,为右下方点到椭圆弧的距离,通过做差:
可判断出所要选择的点,即:选择右方的点,选择右下方的点。根据所得到的利用上述思想推下一点即可得到与的递推关系式:
根据递推关系式和已知点利用循环就可得到第一部分所有的点,循环的条件为即。
对于第二部分,假设已知点为则下一点在其上方 点或左上方点中选择离椭圆弧最近的点,而为上方点到椭圆弧的距离,为左上方点到椭圆弧的距离,通过做差:
可判断出所要选择的点,即:选择上方的点,选择左上方的点。根据所得到的利用上述思想推下一点即可得到 与的递推关系式:
根据递推关系式和已知点利用循环就可得到第二部分所有的点,循环的条件为即。
通过分析可把绘制椭圆的功能封装到一个类(如TDrawEllipse)中,利用构造函数初始化要绘制椭圆的位图,利用公有方法Draw来绘制椭圆,该方法首先计算椭圆的长、短半轴和椭圆中心,然后调用私有方法PlotPartI和PlotPartII来绘制椭圆,利用只读属性Image得到绘制后的位图,实现的核心如下:
public class TDrawEllipse
{
private Bitmap image;//存储生成椭圆的位图
public Bitmap Image
{
get
{ return thisimage; //返回绘制好椭圆的位图 }
}
private int oX, oY, a, b;//存储椭圆的中心和长短半轴
private Color color;//存储椭圆的颜色
private void PlotPoints(int x, int y) //绘制坐标点
{
//由于算法是以(0,0)点为椭圆中心构造的,绘制椭圆时需要把传递的坐标
//平移到真正的椭圆中心(oX,oY)并绘制其它象限的像素点。
thisimageSetPixel(thisoX + x, thisoY + y, thiscolor);
thisimageSetPixel(thisoX - x, thisoY + y, thiscolor);
thisimageSetPixel(thisoX - x, thisoY - y, thiscolor);
thisimageSetPixel(thisoX + x, thisoY - y, thiscolor);
}
private void PlotPartI()//绘制第一部分
{
int x = 0, y = b;
int d = 2 b b - 2 a a b + a a;
while (b b x < a a y)
{
PlotPoints(x, y);
if (d < 0)
{ x = x + 1; d = d + 4 b b x + 2 b b; }
else
{ x = x + 1; y = y - 1;
d = d + 4 b b x + 2 b b - 4 a a y; }
}
}
private void PlotPartII()//绘制第二部分
{
int y = 0, x = a;
int d = 2 a a - 2 a b b + b b;
while (b b x >= a a y)
{
PlotPoints(x, y);
if (d < 0)
{ y = y + 1;d = d + 4 a a y + 2 a a; }
else
{ y = y + 1;x = x - 1;
d = d + 4 a a y + 2 a a - 4 b b x; }
}
}
public TDrawEllipse(Bitmap image)//构造函数,初始化绘制椭圆的位图
{
thisimage = image;
}
public void Draw(Rectangle rt, Color color)//绘制椭圆的函数
{
//参数 Rectangle rt是要绘制椭圆的外接矩形
//参数 Color color是要绘制椭圆的颜色
thisoX = rtLeft + rtWidth / 2;//计算椭圆的中心坐标
thisoY = rtTop + rtHeight / 2;
thisa = rtWidth / 2;//计算椭圆的长短半轴
thisb = rtHeight / 2;
thiscolor = color;
PlotPartI();//绘制第一部分
PlotPartII();//绘制第二部分
}
}
有了封装绘制椭圆功能的类之后,就可以在程序中进行实例化得到该类的一个对象,利用该对象调用Draw方法就可绘制出椭圆来,从而完成绘图系统中绘制椭圆功能的底层实现。以上代码在VSNET2005中编译通过运行正常。
应该这样吧:你可以参考改下背景,实现椭圆边框。
<style TYPE="text/css">
{font-size:12px; text-align:center; line-height:normal;}
clearf {float:none; clear:both; margin:0;}
clearf div {float:left; width:50px; height:20px; border:1px solid #666666;}
</style>
<script>
function showmenu(src)
{
documentgetElementById(src)stylebackground="#999999";
}
function hidemenu(src)
{
documentgetElementById(src)stylebackground="FFFFFF";
}
</script>
<div class="clearf">
<div id="t1" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t1')" onmouseout="hidemenu('t1')">1</a></div>
<div id="t2" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t2')" onmouseout="hidemenu('t2')">2</a></div>
<div id="t3" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t3')" onmouseout="hidemenu('t3')">3</a></div>
<div id="t4" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t4')" onmouseout="hidemenu('t4')">4</a></div>
</div>
<div class="clearf">
<div id="t5" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t5')" onmouseout="hidemenu('t5')">5</a></div>
<div id="t6" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t6')" onmouseout="hidemenu('t6')">6</a></div>
<div id="t7" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t7')" onmouseout="hidemenu('t7')">7</a></div>
<div id="t8" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t8')" onmouseout="hidemenu('t8')">8</a></div>
</div>
<div class="clearf">
<div id="t9" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t9')" onmouseout="hidemenu('t9')">9</a></div>
<div id="t10" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t10')" onmouseout="hidemenu('t10')">10</a></div>
<div id="t11" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t11')" onmouseout="hidemenu('t11')">11</a></div>
<div id="t12" style="background:#FFFFFF;"><a href="#" onmouseover="showmenu('t12')" onmouseout="hidemenu('t12')">12</a></div>
</div>
import javaapplet;
import javaawt;
import javaawtevent;
import javautil;
import javaxswing;
import javaawtgeom;
import javaio;
import javasqlConnection;
class Point implements Serializable
{
int x,y;
Color col;
int tool;
int boarder;
Point(int x, int y, Color col, int tool, int boarder)
{
thisx = x;
thisy = y;
thiscol = col;
thistool = tool;
thisboarder = boarder;
}
}
class paintboard extends Frame implements ActionListener,MouseMotionListener,MouseListener,ItemListener
{
int x = -1, y = -1;
int con = 1;//画笔大小
int Econ = 5;//橡皮大小
int toolFlag = 0;//toolFlag:工具标记
//toolFlag工具对应表:
//(0--画笔);(1--橡皮);(2--清除);
//(3--直线);(4--圆);(5--矩形);
Color c = new Color(0,0,0); //画笔颜色
BasicStroke size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);//画笔粗细
Point cutflag = new Point(-1, -1, c, 6, con);//截断标志
Vector paintInfo = null;//点信息向量组
int n = 1;
FileInputStream picIn = null;
FileOutputStream picOut = null;
ObjectInputStream VIn = null;
ObjectOutputStream VOut = null;
// 工具面板--画笔,直线,圆,矩形,多边形,橡皮,清除/
Panel toolPanel;
Button eraser, drLine,drCircle,drRect;
Button clear ,pen;
Choice ColChoice,SizeChoice,EraserChoice;
Button colchooser;
Label 颜色,大小B,大小E;
//保存功能
Button openPic,savePic;
FileDialog openPicture,savePicture;
paintboard(String s)
{
super(s);
addMouseMotionListener(this);
addMouseListener(this);
paintInfo = new Vector();
/各工具按钮及选择项/
//颜色选择
ColChoice = new Choice();
ColChoiceadd("black");
ColChoiceadd("red");
ColChoiceadd("blue");
ColChoiceadd("green");
ColChoiceaddItemListener(this);
//画笔大小选择
SizeChoice = new Choice();
SizeChoiceadd("1");
SizeChoiceadd("3");
SizeChoiceadd("5");
SizeChoiceadd("7");
SizeChoiceadd("9");
SizeChoiceaddItemListener(this);
//橡皮大小选择
EraserChoice = new Choice();
EraserChoiceadd("5");
EraserChoiceadd("9");
EraserChoiceadd("13");
EraserChoiceadd("17");
EraserChoiceaddItemListener(this);
////////////////////////////////////////////////////
toolPanel = new Panel();
clear = new Button("清除");
eraser = new Button("橡皮");
pen = new Button("画笔");
drLine = new Button("画直线");
drCircle = new Button("画圆形");
drRect = new Button("画矩形");
openPic = new Button("打开图画");
savePic = new Button("保存图画");
colchooser = new Button("显示调色板");
//各组件事件监听
clearaddActionListener(this);
eraseraddActionListener(this);
penaddActionListener(this);
drLineaddActionListener(this);
drCircleaddActionListener(this);
drRectaddActionListener(this);
openPicaddActionListener(this);
savePicaddActionListener(this);
colchooseraddActionListener(this);
颜色 = new Label("画笔颜色",LabelCENTER);
大小B = new Label("画笔大小",LabelCENTER);
大小E = new Label("橡皮大小",LabelCENTER);
//面板添加组件
toolPaneladd(openPic);
toolPaneladd(savePic);
toolPaneladd(pen);
toolPaneladd(drLine);
toolPaneladd(drCircle);
toolPaneladd(drRect);
toolPaneladd(颜色); toolPaneladd(ColChoice);
toolPaneladd(大小B); toolPaneladd(SizeChoice);
toolPaneladd(colchooser);
toolPaneladd(eraser);
toolPaneladd(大小E); toolPaneladd(EraserChoice);
toolPaneladd(clear);
//工具面板到APPLET面板
add(toolPanel,BorderLayoutNORTH);
setBounds(60,60,900,600); setVisible(true);
validate();
//dialog for save and load
openPicture = new FileDialog(this,"打开图画",FileDialogLOAD);
openPicturesetVisible(false);
savePicture = new FileDialog(this,"保存图画",FileDialogSAVE);
savePicturesetVisible(false);
openPictureaddWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ openPicturesetVisible(false); }
});
savePictureaddWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent e)
{ savePicturesetVisible(false); }
});
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ Systemexit(0);}
});
}
public void paint(Graphics g)
{
Graphics2D g2d = (Graphics2D)g;
Point p1,p2;
n = paintInfosize();
if(toolFlag==2)
gclearRect(0,0,getSize()width,getSize()height);//清除
for(int i=0; i<n ;i++){
p1 = (Point)paintInfoelementAt(i);
p2 = (Point)paintInfoelementAt(i+1);
size = new BasicStroke(p1boarder,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
g2dsetColor(p1col);
g2dsetStroke(size);
if(p1tool==p2tool)
{
switch(p1tool)
{
case 0://画笔
Line2D line1 = new Line2DDouble(p1x, p1y, p2x, p2y);
g2ddraw(line1);
break;
case 1://橡皮
gclearRect(p1x, p1y, p1boarder, p1boarder);
break;
case 3://画直线
Line2D line2 = new Line2DDouble(p1x, p1y, p2x, p2y);
g2ddraw(line2);
break;
case 4://画圆
Ellipse2D ellipse = new Ellipse2DDouble(p1x, p1y, Mathabs(p2x-p1x) , Mathabs(p2y-p1y));
g2ddraw(ellipse);
break;
case 5://画矩形
Rectangle2D rect = new Rectangle2DDouble(p1x, p1y, Mathabs(p2x-p1x) , Mathabs(p2y-p1y));
g2ddraw(rect);
break;
case 6://截断,跳过
i=i+1;
break;
default :
}//end switch
}//end if
}//end for
}
public void itemStateChanged(ItemEvent e)
{
if(egetSource()==ColChoice)//预选颜色
{
String name = ColChoicegetSelectedItem();
switch (name) {
case "black":
c = new Color(0,0,0);
break;
case "red":
c = new Color(255,0,0);
break;
case "green":
c = new Color(0,255,0);
break;
case "blue":
c = new Color(0,0,255);
break;
}
}
else if(egetSource()==SizeChoice)//画笔大小
{
String selected = SizeChoicegetSelectedItem();
switch (selected) {
case "1":
con = 1;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
break;
case "3":
con = 3;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
break;
case "5":
con = 5;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
break;
case "7":
con = 7;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
break;
case "9":
con = 9;
size = new BasicStroke(con,BasicStrokeCAP_BUTT,BasicStrokeJOIN_BEVEL);
break;
}
}
else if(egetSource()==EraserChoice)//橡皮大小
{
String Esize = EraserChoicegetSelectedItem();
if(Esize=="5")
{ Econ = 52; }
else if(Esize=="9")
{ Econ = 92; }
else if(Esize=="13")
{ Econ = 132; }
else if(Esize=="17")
{ Econ = 173; }
}
}
public void mouseDragged(MouseEvent e)
{
Point p1 ;
switch(toolFlag){
case 0://画笔
x = (int)egetX();
y = (int)egetY();
p1 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p1);
repaint();
break;
case 1://橡皮
x = (int)egetX();
y = (int)egetY();
p1 = new Point(x, y, null, toolFlag, Econ);
paintInfoaddElement(p1);
repaint();
break;
default :
}
}
public void mouseMoved(MouseEvent e) {}
public void update(Graphics g)
{
paint(g);
}
public void mousePressed(MouseEvent e)
{
Point p2;
switch(toolFlag){
case 3://直线
x = (int)egetX();
y = (int)egetY();
p2 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p2);
break;
case 4: //圆
x = (int)egetX();
y = (int)egetY();
p2 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p2);
break;
case 5: //矩形
x = (int)egetX();
y = (int)egetY();
p2 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p2);
break;
default :
}
}
public void mouseReleased(MouseEvent e)
{
Point p3;
switch(toolFlag){
case 0://画笔
paintInfoaddElement(cutflag);
break;
case 1: //eraser
paintInfoaddElement(cutflag);
break;
case 3://直线
x = (int)egetX();
y = (int)egetY();
p3 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p3);
paintInfoaddElement(cutflag);
repaint();
break;
case 4: //圆
x = (int)egetX();
y = (int)egetY();
p3 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p3);
paintInfoaddElement(cutflag);
repaint();
break;
case 5: //矩形
x = (int)egetX();
y = (int)egetY();
p3 = new Point(x, y, c, toolFlag, con);
paintInfoaddElement(p3);
paintInfoaddElement(cutflag);
repaint();
break;
default:
}
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void actionPerformed(ActionEvent e)
{
if(egetSource()==pen)//画笔
{toolFlag = 0;}
if(egetSource()==eraser)//橡皮
{toolFlag = 1;}
if(egetSource()==clear)//清除
{
toolFlag = 2;
paintInforemoveAllElements();
repaint();
}
if(egetSource()==drLine)//画线
{toolFlag = 3;}
if(egetSource()==drCircle)//画圆
{toolFlag = 4;}
if(egetSource()==drRect)//画矩形
{toolFlag = 5;}
if(egetSource()==colchooser)//调色板
{
Color newColor = JColorChoosershowDialog(this,"调色板",c);
c = newColor;
}
if(egetSource()==openPic)//打开图画
{
openPicturesetVisible(true);
if(openPicturegetFile()!=null)
{
int tempflag;
tempflag = toolFlag;
toolFlag = 2 ;
repaint();
try{
paintInforemoveAllElements();
File filein = new File(openPicturegetDirectory(),openPicturegetFile());
picIn = new FileInputStream(filein);
VIn = new ObjectInputStream(picIn);
paintInfo = (Vector)VInreadObject();
VInclose();
repaint();
toolFlag = tempflag;
}
catch(ClassNotFoundException IOe2)
{
repaint();
toolFlag = tempflag;
Systemoutprintln("can not read object");
}
catch(IOException IOe)
{
repaint();
toolFlag = tempflag;
Systemoutprintln("can not read file");
}
}
}
if(egetSource()==savePic)//保存图画
{
savePicturesetVisible(true);
try{
File fileout = new File(savePicturegetDirectory(),savePicturegetFile());
picOut = new FileOutputStream(fileout);
VOut = new ObjectOutputStream(picOut);
VOutwriteObject(paintInfo);
VOutclose();
}
catch(IOException IOe)
{
Systemoutprintln("can not write object");
}
}
}
}//end paintboard
public class Pb
{
public static void main(String args[])
{ new paintboard("画图程序"); }
}
欢迎分享,转载请注明来源:浪漫分享网
评论列表(0条)