Example #1
0
        private void setLineSegment(Pos2 pos, int length, List <YanagisawaPicLineSegment> segments)
        {
            System.Diagnostics.Debug.Assert(this.colorCurrent.Length == 4);
            int index = (this.width * this.getYExtracted(pos.y) + pos.x) * 4;
            // int index = pos.x * 4;
            var enumerator = segments.GetEnumerator();
            YanagisawaPicLineSegment segmentCurrent = enumerator.MoveNext() ? enumerator.Current : null;

            while (segmentCurrent != null && segmentCurrent.x < pos.x)
            {
                this.colorCurrent = segmentCurrent.color;
                segmentCurrent    = enumerator.MoveNext() ? enumerator.Current : null;
            }
            for (var indexPixel = 0; indexPixel < length; indexPixel++)
            {
                if (segmentCurrent != null && segmentCurrent.x <= pos.x + indexPixel)
                {
                    this.colorCurrent = segmentCurrent.color;
                    segmentCurrent    = enumerator.MoveNext() ? enumerator.Current : null;
                }
                for (var indexByte = 0; indexByte < this.colorCurrent.Length; indexByte++)
                {
                    this.bytesImageExtracted[index + indexByte] = this.colorCurrent[indexByte];
                }
                index += 4;
            }
        }
Example #2
0
        private void setPixel(Pos2 pos, byte[] color)
        {
            int index = (this.width * this.getYExtracted(pos.y) + pos.x) * 4;

            for (var indexByte = 0; indexByte < color.Length; indexByte++)
            {
                this.bytesImageExtracted[index + indexByte] = color[indexByte];
            }
        }
 public Pos2(Pos2 pos)
 {
     this.x = pos.x;
     this.y = pos.y;
 }
Example #4
0
 public void reset()
 {
     this.indexOffset = 0;
     this.posCurrent  = this.posStart.CloneDeep();
 }
Example #5
0
 public YanagisawaPicLightning(Pos2 posStart)
 {
     this.posStart   = posStart;
     this.posCurrent = posStart.CloneDeep();
 }
Example #6
0
        private bool readLightning(Pos2 pos, out YanagisawaPicLightning lightning)
        {
            lightning = new YanagisawaPicLightning(pos);

            long value = 0;

            if (!this.readBitsCompressed(1, out value))
            {
                return(false);
            }
            if (value == 0)
            {
                return(true);
            }

            bool needToExit = false;

            while (!needToExit)
            {
                if (!this.readBitsCompressed(2, out value))
                {
                    return(false);
                }
                var next = value;
                switch (next)
                {
                case 0x0:
                    if (!this.readBitsCompressed(1, out value))
                    {
                        return(false);
                    }
                    if (value == 1)
                    {
                        if (!this.readBitsCompressed(1, out value))
                        {
                            return(false);
                        }
                        var next2 = value;
                        lightning.addOffset(next2 == 0 ? -2 : 2);
                    }
                    else
                    {
                        needToExit = true;
                    }
                    break;

                case 0x1:
                    lightning.addOffset(-1);
                    break;

                case 0x2:
                    lightning.addOffset(0);
                    break;

                case 0x3:
                    lightning.addOffset(1);
                    break;
                }
            }
            return(true);
        }