Просмотр полной версии : Пунктирная линия пунктиром в 1px (Точечная)
Как нарисовать пунктирную линию с точками в 1px? Что-то у меня не получается, вроде бы и координаты использую только целочисленные и все равно флеш плеер их "размазывает".
Если переключить quality в low, то линий таки приобретают необходимый вид.
Пунктир.swf
import flash.display.CapsStyle;
import flash.display.LineScaleMode;
var dashSpace:int = 2;
var dashSize:int = 1;
var lineY:int = 50;
// line 1
this.graphics.lineStyle(0, 0x000000, 1, true, LineScaleMode.NONE, CapsStyle.NONE);
for (var i:int = 50; i < 200; i += dashSpace ) {
this.graphics.moveTo(i, lineY)
this.graphics.lineTo(i + dashSize, lineY);
i += dashSize;
}
// line 2
lineY = 80;
this.graphics.lineStyle(0, 0x000000, 1, false, LineScaleMode.NONE, CapsStyle.NONE);
for (i = 50; i < 200; i += dashSpace ) {
this.graphics.moveTo(i, lineY)
this.graphics.lineTo(i + dashSize, lineY);
i += dashSize;
}
Вообщем с линией у меня не получилось, сделал через фигуру:
import flash.display.CapsStyle;
import flash.display.LineScaleMode;
var dashSpace:int = 2;
var dashSize:int = 1;
var lineY:int = int(50);
// line 1
this.graphics.beginFill(0x000000, 1);
for (var i:int = 50; i < 200; i += dashSpace ) {
this.graphics.drawRect(i, lineY, dashSize, dashSize);
i += dashSize;
}
caseyryan
28.12.2012, 17:45
а если сделать растровую картинку 2 пикселя шириной 1 высотой, один сделать черным (ну или какой цвет там нужен), а другой другим цветом или прозрачный. И через lineBitmapStyle() задать стиль линии?
По-моему вариант гораздо удобнее.
caseyryan,
Да, это отличная идея!
am_devcorp
31.12.2012, 13:34
А как потом нарисовать эту линию?
public class Main extends Sprite {
[Embed(source="../res/Untitled-1.png")]
public var img:Class;
public function Main():void {
var bd:BitmapData =new img().bitmapData
this.graphics.lineBitmapStyle(bd)
this.graphics.lineTo(200,100)
}
}
ничего не рисует
(картинка нормальная, c beginBitmapFill работает нормально)
Обычный lineStyle надо задавать сначала. Как еще Вы укажите толщину, прозрачность и т.п.
lineBitmapStyle задает только параметры битмапной заливки линии. Для рисования собственно линии lineStyle обязателен. И всегда таким был.
Оу, не заметил lineBitmapStyle
Звездочка
package
{
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import flash.geom.Rectangle;
/* * * * * * * * * *
* *
* @author wolsh *
* *
\* * * * * * * * * */
public class Main extends Sprite
{
public function Main():void
{
// dash sample
var bd:BitmapData = new BitmapData(39, 1, true, 0x00000000);
bd.setPixel32(0, 0, 0xFF000000);
bd.fillRect(new Rectangle(4, 0, 20, 1), 0xFF000000);
bd.setPixel32(27, 0, 0xFF000000);
bd.fillRect(new Rectangle(31, 0, 5, 1), 0xFF000000);
// settings
var ang:Number = 142 * Math.PI / 180;
var thick:Number = 1;
var smooth:Boolean = true;
var scale:Number = 1;
// matrix for sample rotations
var matrix:Matrix = new Matrix();
matrix.createBox(scale, 1);
// draw star outline
this.graphics.moveTo(50, 150);
this.graphics.lineStyle(thick);
this.graphics.lineBitmapStyle(bd, matrix, true, smooth);
this.graphics.lineTo(350, 150);
matrix.rotate(ang);
this.graphics.lineStyle(thick);
this.graphics.lineBitmapStyle(bd, matrix, true, smooth);
this.graphics.lineTo(100, 330);
matrix.rotate(ang);
this.graphics.lineStyle(thick);
this.graphics.lineBitmapStyle(bd, matrix, true, smooth);
this.graphics.lineTo(200, 50);
matrix.rotate(ang);
this.graphics.lineStyle(thick);
this.graphics.lineBitmapStyle(bd, matrix, true, smooth);
this.graphics.lineTo(300, 330);
matrix.rotate(ang);
this.graphics.lineStyle(thick);
this.graphics.lineBitmapStyle(bd, matrix, true, smooth);
this.graphics.lineTo(50, 150);
}
}
}
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.