Is there a way to add a diagonal line pattern through an image of bitmap data?

I'm trying to put diagonal lines through an image I have. It's a BitmapData object if that matters.

I'd like the diagonal lines to be white or transparent pixels.

I'm going to tag as watermark because it may be the same principle.

Answers


Yes, there is a suite of methods BitmapData offers for coloring pixels, rectangles and even other objects inheriting IBitmapDrawable (most inbuilt display objects).

The easiest way would probably be for you to draw the shape you want and then use draw() to place that shape over the existing data.


Thanks for everyone giving me direction. So far I've been able to create a diagonal line and repeat it to a variable width and height.

I still need to join the image and lines but I'm calling it a night.

var lineBitmapData:BitmapData;
var targetSprite:SpriteVisualElement;
var spriteVE:SpriteVisualElement = new SpriteVisualElement();
var fillSprite:Sprite = new Sprite();

// draw our diagonal line on a sprite
fillSprite.graphics.lineStyle(1, 0xFF0000);
fillSprite.graphics.moveTo(0, 10);
fillSprite.graphics.lineTo(10, 0);

// draw all the pixels into a bitmap data object 
lineBitmapData = new BitmapData(10, 10, true, 0x000000000000000000);
lineBitmapData.draw(fillSprite);

// create a new sprite and with the graphics object 
// draw a rectangle and fill it with a repeating bitmap data
targetSprite = new SpriteVisualElement();
targetSprite.graphics.beginBitmapFill(lineBitmapData, null, true);
targetSprite.graphics.drawRect(0, 0, width, height);
targetSprite.graphics.endFill();

// add 
//targetSprite.blendMode = BlendMode.ERASE;
spriteVE.addChild(targetSprite);

addElement(spriteVE);

Need Your Help

Eloquent hasManyThroughOne

laravel eloquent

Laravel 4.1 introduced the hasManyThrough relationship. This assumes 2 relating hasMany relationships. I however would like to retrieve the hasMany relationships of a belongsTo relationship instead.

Linux - created processes

linux shell process ssh ps

I'm new to Linux Shell and kind of stuck at an assignment: